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