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