#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long int n, x, y, ans;
  int t;
  cin >> t;
  while (t--) {
    cin >> x >> y >> n;
    if (n % x == 0) {
      if (y != 0)
        ans = ((n / x) - 1) * x + y;
      else
        ans = n;
      cout << ans << "\n";
    } else {
      ans = (n / x) * x + y;
      if (ans > n) ans -= x;
      cout << ans << "\n";
    }
  }
  return 0;
}
