# cook your dish here
t = int(input())
for i in range(t):
N , X = map(int , input().split())
price = N * X
price = str(price)
price = list(price)
if price[0] > 0 and len(price) == 5:
print("YES")
else:
print("NO")
We could simple have checked if price was greater than the largest four digit number, (9 999), and smaller than the smallest six digit number, (100 000).
# cook your dish here
for _ in range(int(input())):
n,x=map(int,input().split())
n=n*x
if((n>9999)and(n<100000)):
print('yes')
else:
print('no')