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