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