AtCoder Beginner Contest 144 - 9x9

Having learned the multiplication table, Takahashi can multiply two integers between 1 and 9 (inclusive) together. He cannot do any other calculation.
Given are two integers A and B.
If Takahashi can calculate A \times B, print the result; if he cannot, print -1 instead.

-----Constraints-----
 - 1 \leq A \leq 20
 - 1 \leq B \leq 20
 - All values in input are integers.

-----Input-----
Input is given from Standard Input in the following format:
A B

-----Output-----
If Takahashi can calculate A \times B, print the result; if he cannot, print -1.

-----Sample Input-----
2 5

-----Sample Output-----
10

2 \times 5 = 10.

Source: atcoder | Difficulty: EASY


Solutions:
(a, b) = map(int, input().split())
if a <= 9 and b <= 9:
	print(int(a * b))
else:
	print(-1)


(a, b) = list(map(int, input().split()))
if a >= 10 or b >= 10:
	print('-1')
else:
	print(a * b)


(N, M) = map(int, input().split(' '))
if N >= 10 or M >= 10:
	print(-1)
else:
	print(N * M)


(A, B) = map(int, input().split())
if max(A, B) >= 10:
	print(-1)
else:
	print(A * B)


(A, B) = [int(n) for n in input().split()]
print(A * B if A <= 9 and B <= 9 else -1)


(A, B) = map(int, input().split())
print(A * B) if A < 10 and B < 10 else print(-1)


(A, B) = map(int, input().split())
if max(A, B) > 9:
	print(-1)
else:
	print(A * B)


(a, b) = map(int, input().split())
if a > 9 or b > 9:
	print('-1')
else:
	print(a * b)


(a, b) = (int(x) for x in input().split())
if a >= 10 or b >= 10:
	print(-1)
else:
	print(a * b)


(A, B) = list(map(int, input().split()))
if 1 <= A <= 9 and 1 <= B <= 9:
	print(A * B)
else:
	print(-1)


(a, b) = [int(i) for i in input().split()]
print(a * b if a < 10 and b < 10 else -1)


try:
	(a, _, b) = input()
except:
	(a, b) = (1, -1)
print(int(a) * int(b))


s = input()
(a, b) = map(int, s.split())
print([a * b, -1][len(s) > 3])


import sys
readline = sys.stdin.readline
sys.setrecursionlimit(10 ** 8)
mod = 10 ** 9 + 7
INF = 10 ** 18
eps = 10 ** (-7)
(a, b) = map(int, input().split())
if a < 10 and b < 10:
	print(a * b)
else:
	print(-1)


(a, b) = map(str, input().split())
print(int(a) * int(b) if len(a) == len(b) == 1 else '-1')


(n, m) = map(int, input().split())
if n <= 9 and m <= 9:
	print(n * m)
else:
	print(-1)


(a, b) = map(int, input().split())
print(a * b if a < 10 > b else -1)


(n, m) = map(int, input().split())
if n < 10 and m < 10:
	print(n * m)
else:
	print(-1)


(A, B) = (int(x) for x in input().split())
print(A * B if A < 10 and B < 10 else -1)


(x, y) = map(int, input().split())
print(x * y if x < 10 and x > 0 and (y < 10) and (y > 0) else -1)


(A, B) = map(int, input().split())
if A > 9 or B > 9:
	print(-1)
else:
	print(A * B)


(n, m) = map(int, input().split())
if n > 9 or m > 9:
	print(-1)
else:
	print(m * n)


(x, y) = map(int, input().split())
if x > 9 or y > 9:
	print(-1)
	exit(0)
else:
	print(x * y)


(a, b) = input().split()
print(-1 if len(a) > 1 or len(b) > 1 else int(a) * int(b))


(a, b) = map(int, input().split())
print([-1, a * b][a < 10 and b < 10])


(x, n) = map(int, input().split())
if n > 9 or x > 9:
	print(-1)
else:
	print(n * x)


(a, b) = map(int, input().split())
print('{}'.format(a * b if a < 10 and b < 10 else -1))


(S, T) = map(int, input().split())
if S <= 9 and T <= 9:
	print(S * T)
else:
	print(-1)


(a, b) = map(int, input().split())
print((a <= 9 and b <= 9) and a * b or -1)


(A, B) = map(int, input().split())
if A >= 10 or B >= 10:
	print(-1)
else:
	print(A * B)


(A, B) = map(int, input().split())
Ans = -1
if (A < 10) & (B < 10):
	Ans = A * B
print(Ans)


(a, b) = [int(n) for n in input().split()]
print(a * b if 1 <= a <= 9 and 1 <= b <= 9 else '-1')


(a, _, b, *c) = input()
print(-(c != []) or int(a) * int(b))


(n, m) = map(int, input().split())
print(-1) if n >= 10 or m >= 10 else print(n * m)


(x, y) = map(int, input().split())
if x <= 9 and y <= 9:
	print(x * y)
else:
	print(-1)


(a, b) = map(int, input().split())
print(a * b if max(a, b) <= 9 else -1)


(a, b) = map(int, input().split())
if a >= 10 or b >= 10:
	print(-1)
	exit()
print(a * b)


(N, M) = map(int, input().split())
if N < 10 and M < 10:
	print(N * M)
else:
	print('-1')


s = input()
(a, b) = map(int, s.split())
print(a * b if len(s) < 4 else -1)


(N, K) = map(int, input().split())
if N > 9 or K > 9:
	print(-1)
else:
	print(N * K)


(a, b) = [int(i) for i in input().split()]
if a > 9 or b > 9:
	print(-1)
else:
	print(a * b)


(X, Y) = [int(x) for x in input().split()]
print((-1, X * Y)[max(X, Y) <= 9])


def multiply(a, b):
	return a * b if a < 10 and b < 10 else -1
print(multiply(*map(int, input().split())))


(a, b) = sorted(map(int, input().split()))
print(a * b if b <= 9 else -1)


(a, b) = map(int, input().split())
ans = -1
if a <= 9 and b <= 9:
	ans = a * b
print(ans)


(a, _, b, *c) = input()
print(-(len(c) > 0) or int(a) * int(b))


(a, s) = map(int, input().split())
print(a * s) if a <= 9 and s <= 9 else print(-1)


(N, M) = map(int, input().split())
print('-1' if N > 9 or M > 9 else N * M)


(X, Y) = map(int, input().split())
ans = X * Y if X <= 9 and Y <= 9 else -1
print(ans)


(a, b) = map(int, input().split())
ans = a * b
if a > 9 or b > 9:
	ans = -1
print(ans)


from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(500000)
INF = float('inf')
(YES, Yes, yes, NO, No, no) = ('YES', 'Yes', 'yes', 'NO', 'No', 'no')
(dy4, dx4) = ([0, 1, 0, -1], [1, 0, -1, 0])
(dy8, dx8) = ([0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1])

def inside(y, x, H, W):
	return 0 <= y < H and 0 <= x < W

def ceil(a, b):
	return (a + b - 1) // b

def sum_of_arithmetic_progression(s, d, n):
	return n * (2 * s + (n - 1) * d) // 2

def gcd(a, b):
	if b == 0:
		return a
	return gcd(b, a % b)

def lcm(a, b):
	g = gcd(a, b)
	return a / g * b

def solve():
	(A, B) = list(map(int, input().split()))
	if 1 <= A <= 9 and 1 <= B <= 9:
		print(A * B)
	else:
		print(-1)

def main():
	solve()

def __starting_point():
	main()
__starting_point()


(n, m) = map(int, input().split())
print(n * m if max(n, m) < 10 else -1)


(a, b) = list(map(int, input().split()))
print(a * b if 0 < a < 10 and 0 < b < 10 else -1)


(A, B) = map(int, input().split())
print(A * B) if len(str(A)) == 1 and len(str(B)) == 1 else print(-1)


S = input().replace(' ', '*')
print([-1, eval(S)][len(S) < 4])


(A, B) = map(int, input().split())
if A > 9 or B > 9:
	print(-1)
	exit()
print(A * B)


(a, b) = map(int, input().split())
f = 0 < a < 10 and 0 < b < 10
print(a * b if f is True else '-1')


(A, B) = input().split()
print(int(A) * int(B) if len(A) == 1 & len(B) == 1 else -1)


s = input()
if len(s) > 3:
	print(-1)
else:
	print(eval(s.replace(' ', '*')))


(a, b) = input().split()
a1 = len(a)
b1 = len(b)
if a1 > 1 or b1 > 1:
	print(-1)
else:
	print(int(a) * int(b))


N = list(map(int, input().strip().split()))
state = -1
if N[0] >= 1 and N[0] <= 9 and (N[1] >= 1) and (N[1] <= 9):
	state = N[0] * N[1]
print(state)


l = list(map(int, input().split()))
a = l[0]
b = l[1]
if a > 9 or a < 1 or b > 9 or (b < 1):
	print(-1)
else:
	print(a * b)


(A, B) = map(int, input().split())
ans = A * B
if A > 9 or B > 9:
	ans = -1
print(ans)