#include <bits/stdc++.h>
using namespace std;
int M = 1000000007;
map<long long int, long long int> mp;
set<long long> s1, s2;
vector<long long> v, w;
long long int m, n, c, d, i, j, k, l, r, x, t, y, u, b;
string s, p, q;
char ch, ck;
int main() {
  ios ::sync_with_stdio(false);
  cin.tie(0);
  cin >> t;
  while (t--) {
    cin >> x >> y >> n;
    d = 0;
    l = 0;
    c = n / x;
    r = c * x;
    l = (c - 1) * x;
    if ((r + y) <= n)
      cout << r + y << endl;
    else {
      cout << l + y << endl;
    }
  }
}
