#include <bits/stdc++.h>
using namespace std;
int main() {
  long long TC, T;
  cin >> TC;
  for (T = 1; T <= TC; T++) {
    long long a, b, c;
    cin >> a >> b >> c;
    long long temp = (c / a) * a;
    if (temp + b > c) {
      temp = temp - (a - b);
    } else {
      temp = temp + b;
    }
    cout << temp << '\n';
  }
  return 0;
}
