#include <bits/stdc++.h>
inline int read() {
  int num = 0, f = 1;
  char c = getchar();
  while (c < 48 || c > 57) {
    if (c == '-') f = -1;
    c = getchar();
  }
  while (c >= 48 && c <= 57)
    num = (num << 3) + (num << 1) + (c ^ 48), c = getchar();
  return num * f;
}
int main() {
  int T = read();
  while (T--) {
    int x = read(), y = read(), n = read();
    int a = (n - y) / x;
    printf("%d\n", a * x + y);
  }
  getchar();
  return 0;
}
