#include <bits/stdc++.h>
const int N = 1e5 + 100;
const int M = 1e6 + 100;
const long long oo = 2e18;
long long n, m, k, t, q, h, a, b, d, c, e, w, x, y, z;
using namespace std;
void solve() {
  cin >> x >> y >> n;
  int l = 0, r = n;
  while (l <= r) {
    int mid = (l + r) / 2;
    if (mid * x + y > n)
      r = mid - 1;
    else if (mid * x + y <= n) {
      z = mid * x + y;
      l = mid + 1;
    }
  }
  cout << z << endl;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  q = 1;
  cin >> q;
  while (q--) solve();
  return 0;
}
