#include <bits/stdc++.h>
using namespace std;
string tostr(long long a) {
  stringstream rr;
  rr << a;
  return rr.str();
}
long long pow(long long c, long long d) { return d == 0 ?: c * pow(c, d - 1); }
long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }
long long lcm(long long a, long long b) { return ((a * b) / gcd(a, b)); }
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  long long t, z = 0;
  cin >> t;
  while (t--) {
    long long n, m, k, i, j, x, y, p = 0, s = 0, h, f = 0;
    cin >> x >> y >> n;
    long long l = 0, r = n;
    while (l <= r) {
      m = (l + r) / 2;
      s = x * m + y;
      if (s <= n) {
        l = m + 1;
        h = m;
      } else {
        r = m - 1;
      }
    }
    cout << x * h + y << endl;
  }
  return 0;
}
