#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    long long int x, y, n, t, l, z = 0;
    cin >> x >> y >> n;
    if (n % x == y)
      cout << n << endl;
    else if (n <= x) {
      cout << y << endl;
    } else if (n % x < y) {
      t = n - (n % x) - x + y;
      cout << t << endl;
    } else {
      l = n - (n % x) + y;
      cout << l << endl;
    }
  }
}
