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