#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
const long long INF = 1e18;
void solve() {
  int x, y, n, ans = 0;
  cin >> x >> y >> n;
  if ((n % x) == y) {
    cout << n << "\n";
    return;
  } else if ((n % x) > y) {
    cout << max(0, n - ((n % x) - y)) << "\n";
  } else {
    cout << max(0, n + (y - (n % x)) - x) << "\n";
  }
}
int main() {
  int cases = 1;
  scanf("%d", &cases);
  while (cases--) {
    solve();
  }
  return 0;
}
