#include <bits/stdc++.h>
using namespace std;
string get_bin(long long int n) {
  string s = "";
  while (n > 0) {
    s += ('0' + n % 2);
    n /= 2;
  }
  reverse(s.begin(), s.end());
  return s;
}
long long int bin_to_dec(string s) {
  long long int ans = 0;
  for (auto ch : s) {
    ans *= 2;
    ans += (ch - '0');
  }
  return ans;
}
void PrintVector(vector<int> v, int n) {
  for (int i = 0; i < n; i++) {
    cout << v[i] << " ";
  }
  cout << endl;
}
int no_of_primeFactors(int n) {
  int count = 0;
  while (n % 2 == 0) {
    count++;
    n = n / 2;
  }
  for (int i = 3; i <= sqrt(n); i = i + 2) {
    while (n % i == 0) {
      count++;
      n = n / i;
    }
  }
  if (n > 2) count++;
  return count;
}
long long int gcd(int a, int b) {
  if (a == 0) return b;
  return gcd(b % a, a);
}
long long int lcm(int a, int b) { return (a / gcd(a, b) * b); }
long long int pwr(long long int base, long long int expo, long long int m) {
  if (base == 0) return 0LL;
  if (expo == 0) return (1LL % m);
  if ((expo & 1) == 0) {
    long long int temp = pwr(base, expo >> 1, m);
    return (temp * temp) % m;
  }
  return ((base % m) * pwr(base, expo - 1, m)) % m;
}
int main(int argc, char const *argv[]) {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  ;
  int t;
  cin >> t;
  while (t--) {
    long long int x, y, n;
    cin >> x >> y >> n;
    int rem = y % x;
    int app = n / x, ans = 0;
    for (int i = max(0, app - 10); i <= app + 10; i++) {
      if (i * x + rem > n) {
        ans = (i - 1) * x + rem;
        break;
      }
    }
    cout << ans << endl;
  }
  return 0;
}
