import sys
# 给定整数n,总能找到满足两个非负整数 x 和 y:
# 满足 x + y == n, 且 |x的数字和 - y的数字和| <= 1
# 1. n 为偶数, 则 x = y = n // 2, 数字和之差 == 0
# 2. n 为奇数, 则 x == n // 2, y == x+1
# 2.1 若 y 的个位数不为0, 数字和之差 == 1,如 x==198, y==199,可以直接返回
# 2.2 否则,需要按位划分,每一位尽可能平分到 x 和 y
def get_close_xy(n_str):
x_str, y_str = [], []
switch = True # 优先分配较大的部分
for char_digit in n_str:
digit = int(char_digit)
half = digit // 2
if digit % 2 == 0:
x_str.append(str(half))
y_str.append(str(half))
else:
if switch:
x_str.append(str(half + 1))
y_str.append(str(half))
else:
x_str.append(str(half))
y_str.append(str(half + 1))
switch = not switch # 下次优先分配给另一个数
x = int("".join(x_str)) if x_str else 0
y = int("".join(y_str)) if y_str else 0
return x, y
t = int(sys.stdin.readline())
for _ in range(t):
n = int(sys.stdin.readline())
x = n // 2
if n % 2 == 0: # n 为偶数
print(x, x)
else:
y = x + 1
if y % 10 != 0: # n 为奇数,且 y 没有进位
print(x, y)
else:
# 按位划分
x, y = get_close_xy(str(n))
print(x, y)