#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ii = pair<ll, ll>;
void in(ll &x);
void work() {
  ll x, y, n;
  in(x);
  in(y);
  in(n);
  ll divi = n / x, modulo = n % x;
  ll ans = -1;
  if (modulo >= y) {
    ans = divi * x + y;
  } else {
    ans = (divi - 1) * x + y;
  }
  printf("%lld\n", ans);
  return;
}
int main() {
  ll nQ;
  in(nQ);
  while (nQ--) work();
  return 0;
}
void in(ll &x) {
  bool neg = false;
  register ll c;
  x = 0;
  c = getchar();
  if (c == '-') {
    neg = true;
    c = getchar();
  }
  for (; c > 47 && c < 58; c = getchar()) x = (x << 1) + (x << 3) + c - 48;
  if (neg) x *= -1;
}
