#include <bits/stdc++.h>
using namespace std;
void solve() {
  int x, y, n;
  cin >> x >> y >> n;
  int ans = n / x * x + y;
  if (ans > n) ans -= x;
  cout << ans << '\n';
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  if (fopen("codeforces"
            ".inp",
            "r")) {
    freopen(
        "codeforces"
        ".inp",
        "r", stdin);
    freopen(
        "codeforces"
        ".out",
        "w", stdout);
  }
  int t;
  cin >> t;
  while (t--) solve();
}
