#include <bits/stdc++.h>
using namespace std;
int gcd(int a, int b) {
  if (b == 0) {
    return a;
  } else {
    return gcd(b, a % b);
  }
}
int lcm(int a, int b) { return (a * b) / (gcd(a, b)); }
void solve() {
  int x, y, n;
  cin >> x >> y >> n;
  int a1 = n - y;
  int ans = a1 / x;
  ans *= x;
  ans += y;
  cout << ans;
  cout << endl;
}
int32_t main() {
  cin.tie(0);
  cout.tie(0);
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ;
  int t;
  t = 1;
  cin >> t;
  while (t--) {
    solve();
  }
}
