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