#include <bits/stdc++.h>
using namespace std;
void test() {
  long long x, y, n;
  cin >> x >> y >> n;
  long long ans = n / x;
  long long finans = (ans * x) + y;
  if (finans <= n)
    cout << finans << "\n";
  else {
    finans = ((ans - 1) * x) + y;
    cout << finans << "\n";
  }
}
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long t;
  cin >> t;
  while (t--) test();
  return 0;
}
