#include <bits/stdc++.h>
using namespace std;
int mod = 1e9 + 7;
void readFile() {}
long long int power(long long int a, long long int b) {
  long long int ans = 1;
  while (b > 0) {
    if (b & 1) ans = ans * a;
    a *= a;
    b = b >> 1;
  }
  return ans;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  readFile();
  int t;
  cin >> t;
  while (t--) {
    long long int x, y, n;
    cin >> x >> y >> n;
    long long int s = 0, e = n;
    long long int ans = 0;
    while (s <= e) {
      long long int mid = s + (e - s) / 2;
      long long int exp = x * mid + y;
      if (exp == n) {
        ans = exp;
        break;
      } else if (exp < n) {
        s = mid + 1;
        ans = exp;
      } else
        e = mid - 1;
    }
    cout << ans << '\n';
  }
}
