#include <bits/stdc++.h>
using namespace std;
void solve() {
  int x, y, n;
  cin >> x >> y >> n;
  int max = (n / x) * x;
  if (max + y > n) {
    max = max - x + y;
  } else {
    max += y;
  }
  cout << max << "\n";
}
int main() {
  int t;
  cin >> t;
  while (t--) solve();
  return 0;
}
