#include <bits/stdc++.h>
using namespace std;
int main() {
  int T;
  cin >> T;
  while (T--) {
    long long x, y, n, a, b;
    cin >> x >> y >> n;
    a = n / x;
    b = (a * x) + y;
    if (b > n) {
      b -= x;
    }
    cout << b << endl;
  }
  return 0;
}
