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