#include <bits/stdc++.h>
long long t, x, y, n;
int main() {
  std::ios::sync_with_stdio(false);
  std::cin >> t;
  for (long long i = 1; i <= t; ++i) {
    std::cin >> x >> y >> n;
    long long temp = n / x;
    if (temp * x + y <= n) {
      std::cout << temp * x + y << std::endl;
    } else {
      std::cout << (temp - 1) * x + y << std::endl;
    }
  }
  return 0;
}
