#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
const int inf = 1e18 + 1;
bool sortbyse(const pair<int, int> &a, const pair<int, int> &b) {
  return (a.second < b.second);
}
bool cmp(pair<long long, long long> a, pair<long long, long long> b) {
  if (a.first > b.first) return 1;
  if (a.first < b.first) return 0;
  return a.second < b.second;
}
void solve() {
  long long x, y, n;
  cin >> x >> y >> n;
  long long s = n / x;
  long long t = n % x;
  if (t >= y)
    cout << n - (t - y);
  else {
    s--;
    s *= x;
    s += y;
    if (s <= n && s > 0)
      cout << s;
    else
      cout << 0;
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int q;
  q = 1;
  cin >> q;
  while (q--) {
    solve();
    cout << endl;
  }
  return 0;
}
