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