#include <bits/stdc++.h>
using namespace std;
using ll = long long;
void fast() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
}
int main() {
  fast();
  ll n, k, l, t, u;
  cin >> t;
  while (t--) {
    cin >> n >> k >> l;
    u = (l - k) / n;
    cout << (n * u) + k << '\n';
  }
  return 0;
}
