#include <bits/stdc++.h>
using namespace std;
void solve() {
  int x, y, n;
  cin >> x >> y >> n;
  int k = n / x;
  int ans = INT_MAX;
  while (ans > n) {
    ans = x * (k--) + y;
  }
  cout << ans << "\n";
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int t = 1;
  cin >> t;
  for (int i = 1; i <= t; i++) {
    solve();
  }
  return 0;
}
