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