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