#include <bits/stdc++.h>
using namespace std;
const int maxn = 200 + 10;
const int maxm = 1e4 + 10;
int main() {
  int t;
  scanf("%d", &t);
  while (t--) {
    long long x, y, n;
    scanf("%lld %lld %lld", &x, &y, &n);
    long long k;
    k = (n - y) / x * x + y;
    printf("%lld\n", k);
  }
  return 0;
}
