#include <bits/stdc++.h>
using namespace std;
int const N = 200100;
template <typename T>
inline bool uax(T &x, T y) {
  return (y > x) ? x = y, true : false;
}
template <typename T>
inline bool uin(T &x, T y) {
  return (y < x) ? x = y, true : false;
}
string to_string(char c) { return "'" + string(1, c) + "'"; }
string to_string(string s) { return '"' + s + '"'; }
string to_string(const char *s) { return to_string((string)s); }
template <typename A>
string to_string(A);
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ": " + to_string(p.second) + ")";
}
template <typename A>
string to_string(A v) {
  bool f = false;
  string r = "{";
  for (auto x : v) {
    if (f) r += ", ";
    r += to_string(x);
    f = true;
  }
  return r += "}";
}
template <typename A>
string to_string(vector<vector<A>> v) {
  string r;
  for (auto x : v) r += "\n" + to_string(x);
  return r;
}
void err(istream_iterator<string>) { cerr << endl; }
template <typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
  cerr << *it << " =: " << to_string(a) << "; ";
  err(++it, args...);
}
template <typename T>
void kek(T ans) {
  cout << ans << endl;
  exit(0);
}
int const mod = 1e9 + 7;
using pii = pair<int, int>;
long long INF = 1e18, NIN = -1 * INF;
struct Node {
  long long minv, lz;
  Node() : minv(), lz() {}
  friend Node operator+(const Node &lhs, const Node &rhs) {
    Node node;
    node.minv = max(lhs.minv, rhs.minv);
    return node;
  }
};
struct SegTree {
  vector<int> ss, ee;
  vector<Node> t;
  int n;
  SegTree(int n1) : ss(n1 << 2), ee(n1 << 2), t(n1 << 2) {
    n = n1;
    build(1, 1, n1);
    for (int x = 0; x < (n << 2); x++) t[x].minv = 0;
  }
  void build(int i, int l, int r) {
    ss[i] = l, ee[i] = r;
    if (l == r) {
      return;
    }
    int m = (l + r) >> 1;
    build((i + i), l, m);
    build((i + i + 1), m + 1, r);
  }
  inline void push(int i) {
    long long &lz = t[i].lz;
    if (lz == 0) {
      return;
    }
    long long len = ee[i] - ss[i] + 1;
    t[i].minv += lz;
    if (len > 1) {
      t[(i + i)].lz += lz;
      t[(i + i + 1)].lz += lz;
    }
    lz = 0;
  }
  inline void update(int i, int us, int ue, long long a) {
    if (us <= ss[i] && ee[i] <= ue) {
      t[i].lz += a;
      push(i);
      return;
    }
    push(i);
    if (ue < ss[i] || ee[i] < us) {
      return;
    }
    update((i + i), us, ue, a);
    update((i + i + 1), us, ue, a);
    t[i] = t[(i + i)] + t[(i + i + 1)];
  }
  inline Node ask(int i, int qs, int qe) {
    push(i);
    if (qs == ss[i] && qe == ee[i]) {
      return t[i];
    }
    if (qe <= ee[(i + i)]) {
      return ask((i + i), qs, qe);
    }
    if (qs >= ss[(i + i + 1)]) {
      return ask((i + i + 1), qs, qe);
    }
    return ask((i + i), qs, ee[(i + i)]) +
           ask((i + i + 1), ss[(i + i + 1)], qe);
  }
  void update(int L, int R, long long val) { return update(1, L, R, val); }
  long long ask(int L, int R) {
    if (L > n) return 0LL;
    return ask(1, L, R).minv;
  }
};
int add(int a, int b) {
  if (a + b >= mod) return a + b - mod;
  return a + b;
}
int mul(int a, int b) { return 1LL * a * b % mod; }
int power(int a, int b) {
  int re = 1;
  while (b) {
    if (b & 1) re = mul(re, a);
    a = mul(a, a);
    b >>= 1;
  }
  return re;
}
int fact[N], inv[N];
int ncr(int a, int b) {
  if (a < 0 || b < 0 || a < b) return 0;
  return mul(fact[a], mul(inv[a - b], inv[b]));
}
int ncr(pii a) { return ncr(a.first, a.second); }
void fac() {
  fact[1] = fact[0] = 1;
  for (int x = 2; x < N; x++) {
    fact[x] = mul(x, fact[x - 1]);
  }
  inv[N - 1] = power(fact[N - 1], mod - 2);
  for (int x = N - 2; x >= 0; x--) {
    inv[x] = mul(x + 1, inv[x + 1]);
  }
}
int main() {
  long long te;
  cin >> te;
  while (te--) {
    long long x, y, n;
    cin >> x >> y >> n;
    long long c1 = n / x;
    long long c2 = (c1 - 1) * x;
    c1 = c1 * x;
    if (c1 + y > n) {
      if (c2 < 0) {
        cout << y << endl;
      } else
        cout << (c2 + y) << endl;
    } else
      cout << c1 + y << endl;
  }
  return 0;
}
