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