You are given three integers $x, y$ and $n$. Your task is to find the maximum integer $k$ such that $0 \le k \le n$ that $k \bmod x = y$, where $\bmod$ is modulo operation. Many programming languages use percent operator % to implement it.

In other words, with given $x, y$ and $n$ you need to find the maximum possible integer from $0$ to $n$ that has the remainder $y$ modulo $x$.

You have to answer $t$ independent test cases. It is guaranteed that such $k$ exists for each test case.


-----Input-----

The first line of the input contains one integer $t$ ($1 \le t \le 5 \cdot 10^4$) — the number of test cases. The next $t$ lines contain test cases.

The only line of the test case contains three integers $x, y$ and $n$ ($2 \le x \le 10^9;~ 0 \le y < x;~ y \le n \le 10^9$).

It can be shown that such $k$ always exists under the given constraints.


-----Output-----

For each test case, print the answer — maximum non-negative integer $k$ such that $0 \le k \le n$ and $k \bmod x = y$. It is guaranteed that the answer always exists.


-----Example-----
Input
7
7 5 12345
5 0 4
10 5 15
17 8 54321
499999993 9 1000000000
10 5 187
2 0 999999999

Output
12339
0
15
54306
999999995
185
999999998



-----Note-----

In the first test case of the example, the answer is $12339 = 7 \cdot 1762 + 5$ (thus, $12339 \bmod 7 = 5$). It is obvious that there is no greater integer not exceeding $12345$ which has the remainder $5$ modulo $7$.
[{"code": "ntest = int(input())\nfor testcase in range(ntest):\n    x, y, n = list(map(int, input().split()))\n    t = (n - y) // x * x + y\n    print(t)\n", "passed": true, "time": 0.22, "memory": 14220.0, "status": "done"}, {"code": "def read_int():\n    return int(input())\n\n\ndef read_ints():\n    return list(map(int, input().split(' ')))\n\n\nt = read_int()\nfor case_num in range(t):\n    x, y, n = read_ints()\n    ans = n // x * x + y\n    if ans > n:\n        ans -= x\n    print(ans)\n", "passed": true, "time": 0.16, "memory": 14308.0, "status": "done"}, {"code": "for _ in range(int(input())):\n    x,y,n=map(int,input().split())\n    k=(n-y)//x*x+y\n    print(k)", "passed": true, "time": 0.24, "memory": 14092.0, "status": "done"}, {"code": "tests = int(input())\nfor _ in range(tests):\n    x, y, n = list(map(int, input().split()))\n    f = n // x * x\n    if f + y <= n:\n        print(f + y)\n    else:\n        print(f - x + y)\n", "passed": true, "time": 0.14, "memory": 14136.0, "status": "done"}, {"code": "for _ in range(int(input())):\n    x, y, n = list(map(int, input().split()))\n    ans = y\n    dif = n - ans\n    dif %= x\n    ans = n - dif\n    print(ans)\n", "passed": true, "time": 0.22, "memory": 14224.0, "status": "done"}, {"code": "t=int(input())\nfor you in range(t):\n    l=input().split()\n    x=int(l[0])\n    y=int(l[1])\n    n=int(l[2])\n    z=(n-y)//x\n    print(z*x+y)\n", "passed": true, "time": 0.22, "memory": 14340.0, "status": "done"}, {"code": "def main():\n    t = int(input())\n    for i in range(t):\n        solve()\n\ndef solve():\n    x, y, n = list(map(int, input().split(\" \")))\n\n    if n % x >= y:\n        print((n // x) * x + y)\n    else:\n        print((n // x - 1) * x + y)\n\nmain()\n\n", "passed": true, "time": 0.14, "memory": 14372.0, "status": "done"}, {"code": "\ntt = int(input())\n\nfor loop in range(tt):\n\n    x,y,n = list(map(int,input().split()))\n\n    tmp = n // x * x + y\n    if tmp > n:\n        tmp -= x\n\n    print (tmp)\n", "passed": true, "time": 0.22, "memory": 14116.0, "status": "done"}, {"code": "T = int(input())\nfor _ in range(T):\n    x, y, n = list(map(int, input().split()))\n    ans = (n // x)*x + y\n    while(ans > n):\n        ans -= x\n    print(ans)\n", "passed": true, "time": 0.28, "memory": 14136.0, "status": "done"}, {"code": "import sys\n\ninp = [int(x) for x in sys.stdin.read().split()]; ii = 0\n\nttt = inp[ii]; ii += 1\nfor _ in range(ttt):\n\tx, y, n = inp[ii: ii + 3]; ii += 3\n\trem = y % x\n\tprint((n - rem) // x * x + rem)", "passed": true, "time": 0.14, "memory": 14248.0, "status": "done"}, {"code": "import sys\nimport math\nimport itertools\nimport functools\nimport collections\nimport operator\nimport fileinput\nimport copy\n\nORDA = 97  # a\ndef ii(): return int(input())\ndef mi(): return map(int, input().split())\ndef li(): return [int(i) for i in input().split()]\ndef lcm(a, b): return abs(a * b) // math.gcd(a, b)\ndef revn(n): return str(n)[::-1]\ndef dd(): return collections.defaultdict(int)\ndef ddl(): return collections.defaultdict(list)\ndef sieve(n):\n    if n < 2: return list()\n    prime = [True for _ in range(n + 1)]\n    p = 3\n    while p * p <= n:\n        if prime[p]:\n            for i in range(p * 2, n + 1, p):\n                prime[i] = False\n        p += 2\n    r = [2]\n    for p in range(3, n + 1, 2):\n        if prime[p]:\n            r.append(p)\n    return r\ndef divs(n, start=1):\n    r = []\n    for i in range(start, int(math.sqrt(n) + 1)):\n        if (n % i == 0):\n            if (n / i == i):\n                r.append(i)\n            else:\n                r.extend([i, n // i])\n    return r\ndef divn(n, primes):\n    divs_number = 1\n    for i in primes:\n        if n == 1:\n            return divs_number\n        t = 1\n        while n % i == 0:\n            t += 1\n            n //= i\n        divs_number *= t\ndef prime(n):\n    if n == 2: return True\n    if n % 2 == 0 or n <= 1: return False\n    sqr = int(math.sqrt(n)) + 1\n    for d in range(3, sqr, 2):\n        if n % d == 0: return False\n    return True\ndef convn(number, base):\n    newnumber = 0\n    while number > 0:\n        newnumber += number % base\n        number //= base\n    return newnumber\ndef cdiv(n, k): return n // k + (n % k != 0)\ndef ispal(s):\n    for i in range(len(s) // 2 + 1):\n        if s[i] != s[-i - 1]:\n            return False\n    return True\n\n\nfor _ in range(ii()):\n    x, y, n = mi()\n    print(((n - y) // x) * x + y)", "passed": true, "time": 0.14, "memory": 14272.0, "status": "done"}, {"code": "t = int(input())\nfor _ in range(t):\n    x,y,n = map(int,input().split())\n    k = y\n    k += ((n-y)//x)*x\n    print(k)", "passed": true, "time": 0.23, "memory": 14332.0, "status": "done"}, {"code": "for nt in range(int(input())):\n\tx,y,n = map(int,input().split())\n\tr = n%x\n\tif r==y:\n\t\tprint (n)\n\t\tcontinue\n\tif y<r:\n\t\tprint (n-(r-y))\n\t\tcontinue\n\tprint (n-(x)+(y-r))", "passed": true, "time": 0.14, "memory": 14204.0, "status": "done"}, {"code": "for _ in range(int(input())):\n    x,y,n=list(map(int,input().split()))\n    z=n//x\n    p = n%x\n    if p>=y:\n        print(z*x+y)\n    else:\n        print((z-1)*x+y)\n", "passed": true, "time": 0.14, "memory": 14232.0, "status": "done"}, {"code": "for _ in range(int(input())):\n    x, y, n = list(map(int, input().split()))\n    z = (n - y) // x\n    print(x * z + y)", "passed": true, "time": 0.15, "memory": 14280.0, "status": "done"}, {"code": "t = int(input())\nfor _ in range(t):\n\tx, y, n = map(int, input().split())\n\n\tma = (n//x)*x\n\n\tif ma + y <= n:\n\t\tans = ma + y\n\telse:\n\t\tans = ma - x + y\n\n\tprint(ans)", "passed": true, "time": 0.14, "memory": 14104.0, "status": "done"}, {"code": "# for _ in range(1):\nfor _ in range(int(input())):\n    x, y, n = map(int, input().split())\n    # n = int(input())\n    # arr = list(map(int, input().split()))\n    # s = input()\n    r = n % x\n    if r < y:\n        n -= n % x + 1\n    n -= n % x - y\n    print(n)", "passed": true, "time": 0.14, "memory": 14252.0, "status": "done"}, {"code": "def solve():\n    x, y, n = map(int, input().split())\n    k = n % x\n    if k >= y:\n        print(n - k + y)\n    else:\n        print(n - x - k + y)\n\n\n[solve() for i in range(int(input()))]", "passed": true, "time": 0.14, "memory": 14328.0, "status": "done"}, {"code": "a=int(input())\nfor i in range(a):\n    x,y,n=list(map(int,input().split()))\n    r=(n//x)*x\n    if(r+y<=n):\n        print(r+y)\n    else:\n        print(max(r-x+y,y))\n", "passed": true, "time": 0.14, "memory": 14128.0, "status": "done"}, {"code": "for _ in range(int(input())):\n    x,y,n=map(int,input().split())\n    ans=(n//x)*x\n    ans+=y\n    if ans>n:\n        ans-=x\n    print(ans)    ", "passed": true, "time": 0.14, "memory": 14288.0, "status": "done"}, {"code": "\n\nfor _ in range(int(input())):\n\ta,b,c=map(int,input().split())\n\n\tcan=c%a\n\n\tif(can>=b):\n\t\tprint((c//a)*a+b)\n\telse:\n\t\tprint((c//a-1)*a+b)", "passed": true, "time": 0.14, "memory": 14368.0, "status": "done"}, {"code": "for _ in range(int(input())):\n    x, y, n = map(int, input().split())\n    if n % x < y:\n        print(x * (n // x - 1) + y)\n    else:\n        print(x * (n // x) + y)", "passed": true, "time": 0.14, "memory": 14076.0, "status": "done"}, {"code": "import bisect\nimport sys\nimport math\ninput = sys.stdin.readline\nimport functools\n\nfrom collections import defaultdict\n\n############ ---- Input Functions ---- ############\n\ndef inp():\n    return(int(input()))\ndef inlt():\n    return(list(map(int,input().split())))\ndef insr():\n    s = input()\n    return(list(s[:len(s) - 1]))\ndef invr():\n    return(list(map(int,input().split())))\n\n############ ---- Solution ---- ############\n\ndef solve(case):\n    [x, y, n] = inlt()\n    res = (n // x) * x + y\n    if res > n:\n        res -= x\n    return res\n    \n\nif len(sys.argv) > 1 and sys.argv[1].startswith(\"input\"):\n    f = open(\"./\" + sys.argv[1], 'r')\n    input = f.readline\n\nT = inp()\nfor i in range(T):\n    res = solve(i+1)\n    print(str(res))\n", "passed": true, "time": 0.14, "memory": 14264.0, "status": "done"}, {"code": "import sys\n# from collections import defaultdict\nt=1\nt=int(input())\nfor i in range(t):\n    # n=int(input())\n    x,y,n=list(map(int,sys.stdin.readline().strip().split()))\n    # a,b,c,d=list(sys.stdin.readline().strip().split())\n    # n,k=list(map(int,sys.stdin.readline().strip().split()))\n    \n    a=(n//x)*x+y\n    b=((n//x)-1)*x+y\n    \n    if(a<=n):\n        print(a)\n    else:\n        print(b)", "passed": true, "time": 0.14, "memory": 14288.0, "status": "done"}, {"code": "# Created by: WeirdBugsButOkay\n# 28-06-2020, 20:05:31\n\nimport math\n\ndef solve() :\n    x, y, n = list(map(int, input().split()))\n    rem = n // x\n    rem *= x\n    rem += y\n    if rem > n :\n        rem -= x\n    print(rem)\n\nt = 1\nt = int(input())\nfor _ in range (0, t) :\n    solve()\n", "passed": true, "time": 0.14, "memory": 14076.0, "status": "done"}]