#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  ;
  cin.tie(NULL);
  cout.tie(NULL);
  int n, m, j, k;
  cin >> n;
  while (n--) {
    cin >> m >> j >> k;
    long long r = (((k - j) / m) * m) + j;
    cout << r << endl;
  }
}
