#include <bits/stdc++.h>
using namespace std;
void solve() {
  int x, y, n;
  cin >> x >> y >> n;
  int k = (n / x) * x + y;
  if (k <= n) {
    cout << k;
  } else {
    cout << k - x;
  }
  cout << endl;
}
int main() {
  int test_cases;
  cin >> test_cases;
  while (test_cases--) {
    solve();
  }
}
