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