#include <bits/stdc++.h>
using namespace std;
long long int n, m;
long long int arr[3000000];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  ;
  long long int TESTS, q, a, s, b, l, r, c, k, p, h, w, d, x, y, z, xs, ys, t;
  TESTS = 1;
  cin >> TESTS;
  while (TESTS--) {
    cin >> x >> y >> n;
    long long int num = n / x;
    (num * x + y <= n) ? cout << num * x + y << "\n"
                       : cout << num * x + y - x << "\n";
  }
  return 0;
}
