#include <bits/stdc++.h>
using namespace std;
using namespace std;
vector<long long>::iterator ptr;
long long count = 0;
long long cache[10004];
long long dp[200005] = {0};
long long cnt[200005] = {0};
long long a[200005] = {0};
long long b[200005] = {0};
long long r[200005] = {0};
long long pr(long long n) {
  if (n % 2 == 0) {
    return 2;
  }
  for (long long i = 3; i <= sqrt(n); i = i + 2) {
    if (n % i == 0) return i;
  }
  if (n > 2) return n;
}
long long power(long long x, unsigned long long y) {
  if (y == 0)
    return 1;
  else if (y % 2 == 0)
    return power(x, y / 2) * power(x, y / 2);
  else
    return x * power(x, y / 2) * power(x, y / 2);
}
vector<vector<long long> > ans(500005);
long long v[200005] = {0};
long long p = 0;
long long an = 0;
long long m;
set<long long> leaf;
void dfs(long long x, long long p) {
  v[x] = 1;
  if (p > m) {
    return;
  }
  for (long long i = 0; i < ans[x].size(); i++) {
    if (!v[ans[x][i]]) {
      if (b[ans[x][i] - 1])
        dfs(ans[x][i], p + 1);
      else
        dfs(ans[x][i], 0);
    }
  }
  if (ans[x].size() == 1 && x != 1) {
    an++;
  }
}
long long mt[200005];
vector<long long> pos;
long long kadane(long long a[], long long n) {
  mt[n] = {0};
  long long ans = 0, mg = a[0], p[n];
  for (long long i = 0; i < n; i++) {
    if (i == 0)
      mt[0] = a[0];
    else if (i > 0) {
      mt[i] = max(mt[i - 1] + a[i], a[i]);
    }
    mg = max(mg, mt[i]);
  }
  return max(mg, ans);
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long t;
  cin >> t;
  while (t--) {
    long long n = 0, q = 0, x = 0, y = 0, ans = 0, l[4] = {0}, b, d, k;
    char c;
    cin >> x >> y >> n;
    long long r = n % x;
    if (r == y)
      ans = n;
    else {
      q = (n / x);
      if (r > y) {
        ans = q * (x) + y;
      } else {
        ans = (q - 1) * (x) + y;
      }
    }
    cout << ans << "\n";
  }
  return 0;
}
