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