At the store, the salespeople want to make all prices round.

In this problem, a number that is a power of $10$ is called a round number. For example, the numbers $10^0 = 1$, $10^1 = 10$, $10^2 = 100$ are round numbers, but $20$, $110$ and $256$ are not round numbers.

So, if an item is worth $m$ bourles (the value of the item is not greater than $10^9$), the sellers want to change its value to the nearest round number that is not greater than $m$. They ask you: by how many bourles should you decrease the value of the item to make it worth exactly $10^k$ bourles, where the value of $k$ — is the maximum possible ($k$ — any non-negative integer).

For example, let the item have a value of $178$-bourles. Then the new price of the item will be $100$, and the answer will be $178-100=78$.


-----Input-----

The first line of input data contains a single integer $t$ ($1 \le t \le 10^4$) — the number of test cases .

Each test case is a string containing a single integer $m$ ($1 \le m \le 10^9$) — the price of the item.


-----Output-----

For each test case, output on a separate line a single integer $d$ ($0 \le d < m$) such that if you reduce the cost of the item by $d$ bourles, the cost of the item will be the maximal possible round number. More formally: $m - d = 10^k$, where $k$ — the maximum possible non-negative integer.


-----Examples-----

Input
7
1
2
178
20
999999999
9000
987654321
Output
0
1
78
10
899999999
8000
887654321


-----Note-----

In the example:

$1 - 0 = 10^0$,

$2 - 1 = 10^0$,

$178 - 78 = 10^2$,

$20 - 10 = 10^1$,

$999999999 - 899999999 = 10^8$,

$9000 - 8000 = 10^3$,

$987654321 - 887654321 = 10^8$.

Note that in each test case, we get the maximum possible round number.

Difficulty: EASY
Tags: Constructive algorithms

Starter code:

Solutions:
fptr = open(0)
for _ in range(int(next(fptr))):
	n = next(fptr)
	print(int(n) - 10 ** (len(n) - 2))


import sys
input = sys.stdin.readline

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 map(int, input().split())
num_of_tests = inp()
for n in range(num_of_tests):
	num = inp()
	k = len(str(num)) - 1
	print(num - 10 ** k)


import sys

def y_a(sisend):
	return int(sisend)

def l_a(sisend):
	return list(map(int, sisend.split()))

def l_s(sisend):
	return list(map(str, sisend.split()))

def p_v_s(vastus):
	return sys.stdout.write(vastus)

def p_v_a(vastus):
	return sys.stdout.write(str(vastus))

def p_v_jar(vastus):
	return sys.stdout.write(' '.join(map(str, vastus)))

def p_v_alla(vastus):
	return sys.stdout.write('\n'.join(map(str, vastus)))
teste = y_a(sys.stdin.readline())
vastused = []
for i in range(teste):
	arv = y_a(sys.stdin.readline())
	k = len(str(arv))
	vastused.append(arv - 10 ** (k - 1))
p_v_alla(vastused)


nt = int(input())
ans = []
for i in range(nt):
	s = input()
	l = len(s)
	ans.append(str(int(s) - 10 ** (l - 1)))
print('\n'.join(ans))


t = int(input())
lst = []
for i in range(t):
	lst.append(input())
i = 0
for i in range(i, t):
	n = len(lst[i])
	lst[i] = int(lst[i])
	du = lst[i] - 10 ** (n - 1)
	print(du)


l = []
n = int(input())
for i in range(n):
	r = 0
	s = input()
	h = len(s) - 1
	r = int(s) - 10 ** h
	l.append(r)
for ele in l:
	print(ele)


for m in [*open(0)][1:]:
	print(int(m) - 10 ** (len(m) - 2))


for _ in [*open(0)][1:]:
	print(int(_) - 10 ** len(_[2:]))


for _ in [*open(0)][1:]:
	print(int(_) - 10 ** _[2:].__len__())


import sys
input = sys.stdin.readline
output = sys.stdout.write

def main():
	tests = int(input().rstrip())
	for i in range(tests):
		num = input().rstrip()
		l = len(num)
		num = int(num)
		ans = num - 10 ** (l - 1)
		output(str(ans))
		output('\n')
main()


import sys
input = sys.stdin.readline
for _ in range(int(input())):
	m = input().strip()
	n = int(m)
	k = len(m)
	a = n - 10 ** (k - 1)
	print(a)


import sys
input = sys.stdin.readline
t = int(input())
dp = [1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000]
for _ in range(t):
	n = list(input().rstrip())
	print(int(''.join(n)) - dp[len(n) - 1])


a = int(input())
b = []
for i in range(0, a):
	c = input()
	b.append(c)
for i in b:
	print(int(i) - 10 ** (len(i) - 1))


import sys
input = sys.stdin.readline
t = int(input())
for t in range(t):
	n = input()
	n = n[:len(n) - 1]
	l = len(n)
	n = int(n)
	ans = n - 10 ** (l - 1)
	print(ans)


k = int(input())
l = []
for i in range(k):
	l.append(input())
for n in l:
	x = len(n)
	print(int(n) - 10 ** (x - 1))


n = int(input())
list1 = []
i = 0
j = 0
count = 0
for i in range(0, n):
	m = int(input())
	list1.append(m)
list2 = []
for el in list1:
	count = len(str(el))
	rem = el - pow(10, count - 1)
	list2.append(rem)
for i in list2:
	print(i)


t = int(input())
ans = []
for i in range(t):
	n = input()
	k = len(n)
	ans.append(int(n) - 10 ** (k - 1))
for j in range(t):
	print(ans[j])


import sys
import math
linesPerTest = 1
testArguments = []
i = 0
totalLines = 1
while i <= totalLines:
	line = sys.stdin.readline().rstrip('\n')
	if i == 0:
		totalLines = linesPerTest * int(line)
	else:
		testArguments.append(line)
	i += 1
testCases = []
for j in range(0, len(testArguments), linesPerTest):
	testCases.append(testArguments[j:j + linesPerTest])

def f(testArguments):
	num = int(testArguments[0])
	digits = int(math.log10(num) + 1)
	target = 10 ** (digits - 1)
	return num - target
for testCase in testCases:
	print(f(testCase))


n = int(input())
anslist = []
for i in range(n):
	strnum = input()
	intnum = int(strnum)
	x = len(strnum)
	diff = intnum - 10 ** (x - 1)
	anslist.append(diff)
for ele in anslist:
	print(ele)


t = int(input())
list1 = []
for i in range(0, t):
	m = str(input())
	list1.append(m)
for j in range(0, t):
	x = list1[j]
	l = len(x)
	p = int(x)
	print(p - 10 ** (l - 1))


import sys
ncases = int(input())

def solve():
	s = int(input())
	posibles = [10 ** 0, 10 ** 1, 10 ** 2, 10 ** 3, 10 ** 4, 10 ** 5, 10 ** 6, 10 ** 7, 10 ** 8, 10 ** 9]
	valor = max([x for x in posibles if x <= s])
	res.append(s - valor)
res = []
for x in range(ncases):
	solve()
[print(n) for n in res]


import sys
from sys import stdin, stdout
from math import ceil, floor, sqrt, log, log2, log10
from collections import Counter
int_max = float('inf')
int_min = -float('inf')
mod = 10 ** 9 + 7
ANS = []
input = stdin.readline

def solve():
	pass
t = int(input())
for i in range(t):
	s = input().strip()
	n = len(s)
	print(int(s) - 10 ** (n - 1))


def roundx(n):
	return int(n) - 10 ** (len(n) - 1)
t = int(input())
arr0 = []
arr1 = []
for _ in range(t):
	arr1.append(roundx(input()))
for i in arr1:
	print(i)


t = int(input())
ans = []
for i in range(t):
	n = input()
	power = len(n) - 1
	ans.append(int(n) - 10 ** power)
for case in tuple(ans):
	print(case)


for n in [*open(0)][1:]:
	print(int(n) - 10 ** (len(n) - 2))


mo = open
inte = int
dai = len
for _ in [*mo(0)][1:]:
	print(inte(_) - 10 ** dai(_[2:]))


t = int(input())
A = []
for i in range(t):
	n = int(input())
	A.append(n)
for i in range(t):
	x = A[i]
	y = str(x)
	if x == 1:
		print(0)
	else:
		print(x - 10 ** (len(y) - 1))


n = int(input())
z = []
for i in range(n):
	m = int(input())
	k = 1
	while k <= m:
		k = k * 10
	z.append(m - k // 10)
for i in range(n):
	print(z[i])


import sys

def solve():
	inp = sys.stdin.readline
	n = int(inp())
	x = 1
	while x * 10 <= n:
		x *= 10
	print(n - x)

def main():
	for i in range(int(sys.stdin.readline())):
		solve()
main()


ans = []
for _ in range(int(input())):
	n = int(input())
	p = 1
	while p <= n:
		p *= 10
	p //= 10
	ans.append(n - p)
print('\n'.join(map(str, ans)))


def kil_(a):
	k = 10 ** (len(a) - 1)
	return int(a) - k

def kil(a):
	t = int(input())
	A = ''
	for i in range(t):
		A += str(kil_(a())) + '\n'
	print(A[:-1])

def ik():
	return input()
kil(ik)


out = []
for _ in range(int(input())):
	m = int(input())
	s = str(m)
	s1 = '1' + '0' * (len(s) - 1)
	out.append(m - int(s1))
for i in out:
	print(i)


import sys
input = sys.stdin.readline
for _ in range(int(input())):
	n = int(input())
	s = len(str(n))
	print(n - 10 ** (s - 1))


for s in [*open(0)][1:]:
	s = s.strip('\n')
	print(abs(pow(10, len(s) - 1) - int(s)))


import sys
input = sys.stdin.readline
ten = [10 ** i for i in range(9, -1, -1)]
for _ in range(int(input())):
	n = int(input())
	for t in ten:
		if n - t >= 0:
			print(n - t)
			break


for s in [*open(0)][1:]:
	print(int(s) - 1 * pow(10, len(s) - 1 - 1))


t = int(input())
arr = []
for i in range(t):
	arr.append(int(input()))
for i in arr:
	print(i - 10 ** (len(str(i)) - 1))


numbers = [0, *[10 ** i for i in range(10)]]
output = []
for i in range(int(input())):
	number = int(input())
	for i2 in reversed(numbers):
		if number >= i2:
			output.append(str(number - i2))
			break
print('\n'.join(output))


import sys
t = int(sys.stdin.readline().rstrip())

def exec_case():
	m = int(sys.stdin.readline().rstrip())
	k = 1
	while True:
		if m < 10:
			print(m - 1)
			return
		if m < 10 ** k:
			answer = m - 10 ** (k - 1)
			print(answer)
			return
		else:
			k += 1
for _ in range(t):
	exec_case()


def pow10(n):
	return pow(10, n)

def by(s: str):
	return len(s) - 1

def solution(vstr: str):
	k = by(vstr)
	return f'{int(vstr) - pow10(k)}'
t = int(input())
m = []
for _ in range(t):
	v = input()
	m.append(solution(str(v).strip()))
print('\n'.join(m))


a = []
for i in range(int(input())):
	a.append(int(input()))
for i in a:
	b = i - pow(10, len(str(i)) - 1)
	print(b)


import sys
lines = []
for line in sys.stdin:
	lines.append(line.strip())
for i in range(1, len(lines)):
	line = lines[i]
	if line == '1':
		print(0)
		continue
	first_digit = str(int(line[0]) - 1)
	if first_digit == '0':
		first_digit = ''
	ans = first_digit + line[1:]
	ans = str(int(ans))
	print(ans)


(a, list) = (int(input()), [])
for _ in range(a):
	(nums, i) = (int(input()), 1)
	while nums >= i:
		i *= 10
	if i > nums:
		list.append(nums - i // 10)
for k in list:
	print(k)


n = input()
n = int(n)
l = []
for i in range(0, n):
	l.append(input())
for x in l:
	p = len(x)
	x = int(x)
	print(x - 10 ** (p - 1))


def get_input():
	num_tests = int(input())
	tests = []
	for i in range(num_tests):
		tests.append(int(input()))
	return tests

def print_result(results):
	for res in results:
		print(res)

def round_down_num(x):
	folds = len(str(x)) - 1
	return x - 10 ** folds
tests = get_input()
result = []
for x in tests:
	result.append(round_down_num(x))
print_result(result)


a = int(input())
d = []
for i in range(1, a + 1):
	r = int(input())
	e = str(r)
	b = 10 ** (len(e) - 1)
	c = r - b
	d.append(c)
for z in d:
	print(z)


n = int(input())
ot = []
for i in range(n):
	a = int(input())
	q = 9
	while 0 < 1:
		if 10 ** q > a:
			q -= 1
		else:
			ot.append(a - 10 ** q)
			break
for i in range(len(ot)):
	print(ot[i])


from sys import stdin

def get_data(m):
	for cont in range(10):
		if 10 ** cont == m:
			return 0
		if 10 ** cont > m:
			less = 10 ** (cont - 1)
			break
	return m - less

def main():
	t = int(stdin.readline())
	for cont in range(t):
		m = int(stdin.readline())
		print(get_data(m))
main()


n = int(input())
list = []
while n > 0:
	a = input()
	if a == '1':
		list.append(0)
	else:
		l = len(a)
		list.append(int(a) - 10 ** (l - 1))
	n -= 1
for i in list:
	print(i)


import sys
input = sys.stdin.readline

def solve():
	n = int(input())
	x = 1
	while x <= n:
		x *= 10
	x //= 10
	print(n - x)
tc = int(input())
for i in range(tc):
	solve()


t = int(input())
result = []
for n in range(t):
	value = int(input())
	i = 0
	while 10 ** (i + 1) <= value:
		i += 1
	result.append(value - 10 ** i)
for i in range(t):
	print(result[i])


import sys
input = sys.stdin.readline
tc = int(input())
for _ in range(tc):
	num = int(input())
	pow = 0
	while num >= 10 ** pow:
		pow += 1
	print(num - 10 ** (pow - 1))


import math
inp_arr = [int(input()) for i in range(int(input()))]
pow_10 = [10 ** i for i in range(math.ceil(math.log10(max(inp_arr))) + 1)]
for number in inp_arr:
	print(min([number - i for i in pow_10 if number - i >= 0]))


numberofcases = int(input())
listofcases = []
for num in range(numberofcases):
	testcases = int(input())
	listofcases.append(testcases)
for item in listofcases:
	count = 0
	for x in range(0, 11):
		if item < 10 ** x:
			print(item - 10 ** (x - 1))
			break


t = int(input())
l = []
while t != 0:
	t = t - 1
	x = int(input())
	l.append(x)
for i in range(len(l)):
	const = 1
	while const <= l[i]:
		const = const * 10
	const = const // 10
	print(l[i] - const)


import math
test = int(input())
ans = []
for i in range(test):
	x = int(input())
	ans.append(int(x - math.pow(10, math.floor(math.log10(x)))))
for i in ans:
	print(i, sep=' ')


nums = int(input(''))
(lon, ans) = ([], [])
rounds = [10 ** g for g in range(10)]
for g in range(nums):
	a = int(input(''))
	lon.append(a)
for g in lon:
	if g in rounds:
		ans.append(0)
	else:
		rounds.append(g)
		rounds.sort()
		ans.append(g - rounds[rounds.index(g) - 1])
		rounds.remove(g)
for g in ans:
	print(g)


from math import *
ans = []
for _ in range(int(input())):
	m = int(input())
	ans += [m - 10 ** (round(log(m, 10)) if set(str(m)) == {'1', '0'} and str(m).count('1') == 1 else int(log(m, 10)))]
print(*ans, sep='\n')


n = int(input())
ans = []
for i in range(n):
	num = input()
	if len(num) == 1:
		ans.append(int(num) - 1)
		continue
	if num[0] == '1' and num.count('0') == len(num) - 1:
		ans.append(0)
	else:
		k = 1
		num = int(num)
		while k < num:
			k *= 10
		ans.append(int(num - k / 10))
for i in ans:
	print(i)


import math
n = int(input())
for i in range(n):
	precio = int(input())
	log_precio = math.log10(precio)
	log_redondeado = math.floor(log_precio)
	precio_redondeado = 10 ** log_redondeado
	diferencia = precio - precio_redondeado
	print(diferencia)


t = int(input())
for i in range(t):
	s = input()
	p = len(s)
	print(int(s) - pow(10, p - 1))


t = int(input())
for i in range(t):
	n = int(input())
	s = str(n)
	a = int('1' + '0' * (len(s) - 1))
	print(n - a)


for i in range(int(input())):
	n = input()
	k = '1' + (len(n) - 1) * '0'
	print(int(n) - int(k))


t = int(input())
for _ in range(t):
	m = input()
	print(int(m) - 10 ** (len(m) - 1))


result = []
for t in range(int(input())):
	n = int(input())
	p = 0
	lc = 0
	curr = 0
	while curr <= n:
		lc = curr
		curr = 10 ** p
		p += 1
	result.append(n - lc)
for i in result:
	print(i)


count = int(input())
for i in range(count):
	next = input()
	min_power = len(next) - 1
	result = int(next) - 10 ** min_power
	print(result)


for i in range(int(input())):
	cost = int(input())
	max_round = int('1' + '0' * (len(str(cost)) - 1))
	print(cost - max_round)


t = int(input())
for i in range(t):
	a = input()
	print(int(a) - 10 ** (len(a) - 1))


t = int(input())
for i in range(t):
	n = input()
	length = len(n)
	temp = 10 ** (length - 1)
	print(int(n) - temp)


t = int(input())
for i in range(t):
	n = input()
	print(int(n) - pow(10, len(n) - 1))


t = int(input())
for i in range(t):
	m = input()
	n_zeros = len(m)
	print(int(m) - pow(10, n_zeros - 1))


n = int(input())
answer = []
for i in range(n):
	number = int(input())
	test_number = 0
	pow = 1
	while test_number <= number:
		test_number = 10 ** pow
		pow += 1
	answer.append(number - test_number / 10)
for value in answer:
	print(int(value))


for _ in range(int(input())):
	m = int(input())
	print(m - 10 ** (len(str(m)) - 1))


t = int(input())
for i in range(t):
	s = input()
	d = int(s)
	print(d - 10 ** (len(s) - 1))


n = int(input())
a = []
s = 0
for i in range(n):
	m = int(input())
	a.append(m)
for i in range(n):
	if a[i] < 10:
		print(a[i] - 1)
	else:
		while a[i] >= 10 ** s:
			s += 1
		print(a[i] - 10 ** (s - 1))
		s = 0


MAX_PRICE = 1000000000
n = int(input())
m = {0: 1, 1: 1, 2: 10, 3: 100, 4: 1000, 5: 10000, 6: 100000, 7: 1000000, 8: 10000000, 9: 100000000, 10: 1000000000}
for _ in range(n):
	p = input()
	price = int(p)
	print(price - m[len(p)])


n = int(input())
for i in range(n):
	m = input()
	lenm = len(m)
	nearhn = int(m) - pow(10, lenm - 1)
	print(nearhn)


t = int(input())
for i in range(t):
	m = input()
	m1 = int(m)
	print(m1 - 10 ** (len(m) - 1))


for i in range(int(input())):
	m = input()
	x = 10 ** (len(m) - 1)
	print(int(m) - x)


t = int(input())
for _ in range(t):
	n = input()
	k = len(n) - 1
	print(int(n) - 10 ** k)


i = int(input())
for k in range(i):
	t = input()
	x = len(t)
	if int(t) == 0:
		print(0)
	else:
		ans = int(t) - 10 ** (x - 1)
		print(ans)


def solve():
	n = int(input())
	l = len(str(n))
	print(n - 10 ** (l - 1))
for _ in range(int(input())):
	solve()


for _ in range(int(input())):
	n = int(input())
	L = len(str(n))
	print(n - 10 ** (L - 1))


from math import *
N = int(input())
for i in range(0, N):
	M = int(input())
	X = int(log10(M))
	print(M - 10 ** X)


def potencia(n):
	dec = 0
	p = 1
	while n > dec:
		dec = 10 ** p
		p += 1
		if n < dec:
			d = n - dec // 10
			return d
		if n == dec:
			return 0
subtracoes = []
t = int(input())
for a in range(t):
	m = int(input())
	subtracoes.append(potencia(m))
for b in subtracoes:
	print(b)


import math
for i in range(int(input())):
	a = int(input())
	b = len(str(a)) - 1
	print(a - 10 ** b)


def Solver():
	num = input()
	dig = len(num)
	print(int(num) - 10 ** (dig - 1))
for _ in range(int(input())):
	Solver()


n = int(input())
for _ in range(n):
	x = input()
	if x == '1':
		print(0)
	else:
		l = len(x)
		print(int(x) - 10 ** (l - 1))


for i in range(int(input())):
	s = str(input())
	arr = list(s.strip(' '))
	print(int(s) - 10 ** (len(arr) - 1))


cases = int(input())
for case in range(cases):
	m = int(input())
	m_copy = m
	k = 0
	while m_copy // 10:
		k += 1
		m_copy = m_copy // 10
	d = m - 10 ** k
	print(d)