#include <bits/stdc++.h>
using namespace std;
void parr(long long int arr[], long long int n, string name) {
  long long int i;
  for (i = 0; i < n; i++) cout << arr[i] << " ";
  cout << "\n";
}
template <typename T>
void p(T x, string name = " ") {
  cout << name << " : " << x << "\n";
}
int32_t main() {
  long long int t;
  cin >> t;
  while (t--) {
    long long int x, y, n;
    cin >> x >> y >> n;
    long long int r = n % x;
    long long int ans = n;
    if (r == y) {
      ans = n;
    } else if (r < y) {
      ans -= x;
      ans += y - r;
    } else if (r > y) {
      ans -= r - y;
    }
    cout << ans << endl;
  }
}
