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