#include <bits/stdc++.h>
using namespace std;
int a[1005];
void solve() {
  int x, y, n;
  cin >> x >> y >> n;
  if (n % x >= y)
    cout << (n / x) * x + y << endl;
  else
    cout << (n / x - 1) * x + y << endl;
}
int main() {
  int t;
  cin >> t;
  while (t--) {
    solve();
  }
}
