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