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$.

Difficulty: introductory

Starter code:

Solutions:
ntest = int(input())
for testcase in range(ntest):
    x, y, n = list(map(int, input().split()))
    t = (n - y) // x * x + y
    print(t)


def read_int():
    return int(input())


def read_ints():
    return list(map(int, input().split(' ')))


t = read_int()
for case_num in range(t):
    x, y, n = read_ints()
    ans = n // x * x + y
    if ans > n:
        ans -= x
    print(ans)


for _ in range(int(input())):
    x,y,n=map(int,input().split())
    k=(n-y)//x*x+y
    print(k)

tests = int(input())
for _ in range(tests):
    x, y, n = list(map(int, input().split()))
    f = n // x * x
    if f + y <= n:
        print(f + y)
    else:
        print(f - x + y)


for _ in range(int(input())):
    x, y, n = list(map(int, input().split()))
    ans = y
    dif = n - ans
    dif %= x
    ans = n - dif
    print(ans)


t=int(input())
for you in range(t):
    l=input().split()
    x=int(l[0])
    y=int(l[1])
    n=int(l[2])
    z=(n-y)//x
    print(z*x+y)


from bisect import bisect_left as bl
from bisect import bisect_right as br
from heapq import heappush,heappop
import math
from collections import *
from functools import reduce,cmp_to_key
import sys
input = sys.stdin.readline
M = mod = 998244353
def factors(n):return sorted(set(reduce(list.__add__, ([i, n//i] for i in range(1, int(n**0.5) + 1) if n % i == 0))))
def inv_mod(n):return pow(n, mod - 2, mod)
 
def li():return [int(i) for i in input().rstrip('\n').split()]
def st():return input().rstrip('\n')
def val():return int(input().rstrip('\n'))
def li2():return [i for i in input().rstrip('\n')]
def li3():return [int(i) for i in input().rstrip('\n')]


for _ in range(val()):
    a,b,n = li()
    temp = n//a
    ans = b + a*temp
    if ans > n:
        ans -= a
    print(ans)

def main():
    t = int(input())
    for i in range(t):
        solve()

def solve():
    x, y, n = list(map(int, input().split(" ")))

    if n % x >= y:
        print((n // x) * x + y)
    else:
        print((n // x - 1) * x + y)

main()




tt = int(input())

for loop in range(tt):

    x,y,n = list(map(int,input().split()))

    tmp = n // x * x + y
    if tmp > n:
        tmp -= x

    print (tmp)


T = int(input())
for _ in range(T):
    x, y, n = list(map(int, input().split()))
    ans = (n // x)*x + y
    while(ans > n):
        ans -= x
    print(ans)


import sys
import random
from math import *
 
def input():
    return sys.stdin.readline().strip()
 
def iinput():
    return int(input())

def finput():
    return float(input())

def tinput():
    return input().split()

def linput():
    return list(input())
 
def rinput():
    return map(int, tinput())

def fiinput():
    return map(float, tinput())
 
def rlinput():
    return list(map(int, input().split()))
def trinput():
    return tuple(rinput())

def srlinput():
    return sorted(list(map(int, input().split())))

def NOYES(fl):
    if fl:
        print("NO")
    else:
        print("YES")
def YESNO(fl):
    if fl:
        print("YES")
    else:
        print("NO")
    
def main():  
    #n = iinput()
    #k = iinput() 
    #m = iinput() 
    #n = int(sys.stdin.readline().strip()) 
    #n, k = rinput()
    #n, m = rinput()
    #m, k = rinput()
    #n, k, m = rinput()
    #n, m, k = rinput()
    #k, n, m = rinput()
    #k, m, n = rinput() 
    #m, k, n = rinput()
    #m, n, k = rinput()
    #q = srlinput()
    #q = linput()
    x, y, n = rinput()
    res = n - y
    print(x * (res // x) + y)

    
for inytd in range(iinput()):
    main()

import sys

inp = [int(x) for x in sys.stdin.read().split()]; ii = 0

ttt = inp[ii]; ii += 1
for _ in range(ttt):
	x, y, n = inp[ii: ii + 3]; ii += 3
	rem = y % x
	print((n - rem) // x * x + rem)

import sys
import math
import itertools
import functools
import collections
import operator
import fileinput
import copy

ORDA = 97  # a
def ii(): return int(input())
def mi(): return map(int, input().split())
def li(): return [int(i) for i in input().split()]
def lcm(a, b): return abs(a * b) // math.gcd(a, b)
def revn(n): return str(n)[::-1]
def dd(): return collections.defaultdict(int)
def ddl(): return collections.defaultdict(list)
def sieve(n):
    if n < 2: return list()
    prime = [True for _ in range(n + 1)]
    p = 3
    while p * p <= n:
        if prime[p]:
            for i in range(p * 2, n + 1, p):
                prime[i] = False
        p += 2
    r = [2]
    for p in range(3, n + 1, 2):
        if prime[p]:
            r.append(p)
    return r
def divs(n, start=1):
    r = []
    for i in range(start, int(math.sqrt(n) + 1)):
        if (n % i == 0):
            if (n / i == i):
                r.append(i)
            else:
                r.extend([i, n // i])
    return r
def divn(n, primes):
    divs_number = 1
    for i in primes:
        if n == 1:
            return divs_number
        t = 1
        while n % i == 0:
            t += 1
            n //= i
        divs_number *= t
def prime(n):
    if n == 2: return True
    if n % 2 == 0 or n <= 1: return False
    sqr = int(math.sqrt(n)) + 1
    for d in range(3, sqr, 2):
        if n % d == 0: return False
    return True
def convn(number, base):
    newnumber = 0
    while number > 0:
        newnumber += number % base
        number //= base
    return newnumber
def cdiv(n, k): return n // k + (n % k != 0)
def ispal(s):
    for i in range(len(s) // 2 + 1):
        if s[i] != s[-i - 1]:
            return False
    return True


for _ in range(ii()):
    x, y, n = mi()
    print(((n - y) // x) * x + y)

t = int(input())
for _ in range(t):
    x,y,n = map(int,input().split())
    k = y
    k += ((n-y)//x)*x
    print(k)

for nt in range(int(input())):
	x,y,n = map(int,input().split())
	r = n%x
	if r==y:
		print (n)
		continue
	if y<r:
		print (n-(r-y))
		continue
	print (n-(x)+(y-r))

for _ in range(int(input())):
    x,y,n=list(map(int,input().split()))
    z=n//x
    p = n%x
    if p>=y:
        print(z*x+y)
    else:
        print((z-1)*x+y)


for _ in range(int(input())):
    x, y, n = list(map(int, input().split()))
    z = (n - y) // x
    print(x * z + y)

t = int(input())
for _ in range(t):
	x, y, n = map(int, input().split())

	ma = (n//x)*x

	if ma + y <= n:
		ans = ma + y
	else:
		ans = ma - x + y

	print(ans)

# for _ in range(1):
for _ in range(int(input())):
    x, y, n = map(int, input().split())
    # n = int(input())
    # arr = list(map(int, input().split()))
    # s = input()
    r = n % x
    if r < y:
        n -= n % x + 1
    n -= n % x - y
    print(n)

def solve():
    x, y, n = map(int, input().split())
    k = n % x
    if k >= y:
        print(n - k + y)
    else:
        print(n - x - k + y)


[solve() for i in range(int(input()))]

a=int(input())
for i in range(a):
    x,y,n=list(map(int,input().split()))
    r=(n//x)*x
    if(r+y<=n):
        print(r+y)
    else:
        print(max(r-x+y,y))


for _ in range(int(input())):
    x,y,n=map(int,input().split())
    ans=(n//x)*x
    ans+=y
    if ans>n:
        ans-=x
    print(ans)    



for _ in range(int(input())):
	a,b,c=map(int,input().split())

	can=c%a

	if(can>=b):
		print((c//a)*a+b)
	else:
		print((c//a-1)*a+b)

for _ in range(int(input())):
    x, y, n = map(int, input().split())
    if n % x < y:
        print(x * (n // x - 1) + y)
    else:
        print(x * (n // x) + y)

import bisect
import sys
import math
input = sys.stdin.readline
import functools

from collections import defaultdict

############ ---- Input Functions ---- ############

def inp():
    return(int(input()))
def inlt():
    return(list(map(int,input().split())))
def insr():
    s = input()
    return(list(s[:len(s) - 1]))
def invr():
    return(list(map(int,input().split())))

############ ---- Solution ---- ############

def solve(case):
    [x, y, n] = inlt()
    res = (n // x) * x + y
    if res > n:
        res -= x
    return res
    

if len(sys.argv) > 1 and sys.argv[1].startswith("input"):
    f = open("./" + sys.argv[1], 'r')
    input = f.readline

T = inp()
for i in range(T):
    res = solve(i+1)
    print(str(res))


import sys
# from collections import defaultdict
t=1
t=int(input())
for i in range(t):
    # n=int(input())
    x,y,n=list(map(int,sys.stdin.readline().strip().split()))
    # a,b,c,d=list(sys.stdin.readline().strip().split())
    # n,k=list(map(int,sys.stdin.readline().strip().split()))
    
    a=(n//x)*x+y
    b=((n//x)-1)*x+y
    
    if(a<=n):
        print(a)
    else:
        print(b)

# Created by: WeirdBugsButOkay
# 28-06-2020, 20:05:31

import math

def solve() :
    x, y, n = list(map(int, input().split()))
    rem = n // x
    rem *= x
    rem += y
    if rem > n :
        rem -= x
    print(rem)

t = 1
t = int(input())
for _ in range (0, t) :
    solve()