#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  for (int i = 0; i < t; i++) {
    long int x, y, n;
    cin >> x >> y >> n;
    long int div = n / x;
    if ((div * x + y) <= n) {
      cout << (div * x + y) << endl;
    } else {
      div -= 1;
      cout << (div * x + y) << endl;
    }
  }
}
