While Mahmoud and Ehab were practicing for IOI, they found a problem which name was Longest common subsequence. They solved it, and then Ehab challenged Mahmoud with another problem.

Given two strings a and b, find the length of their longest uncommon subsequence, which is the longest string that is a subsequence of one of them and not a subsequence of the other.

A subsequence of some string is a sequence of characters that appears in the same order in the string, The appearances don't have to be consecutive, for example, strings "ac", "bc", "abc" and "a" are subsequences of string "abc" while strings "abbc" and "acb" are not. The empty string is a subsequence of any string. Any string is a subsequence of itself.


-----Input-----

The first line contains string a, and the second line — string b. Both of these strings are non-empty and consist of lowercase letters of English alphabet. The length of each string is not bigger than 10^5 characters.


-----Output-----

If there's no uncommon subsequence, print "-1". Otherwise print the length of the longest uncommon subsequence of a and b.


-----Examples-----
Input
abcd
defgh

Output
5

Input
a
a

Output
-1



-----Note-----

In the first example: you can choose "defgh" from string b as it is the longest subsequence of string b that doesn't appear as a subsequence of string a.

Source: codeforces | Difficulty: EASY
Tags: String algorithms

Constructive algorithms


Solutions:
a = input()
b = input()
if a == b:
	print(-1)
else:
	print(max(len(a), len(b)))


a = input()
b = input()
if len(a) == len(b) and a == b:
	print('-1')
else:
	print(str(max(len(a), len(b))))


import sys

def debug(x, table):
	for (name, val) in table.items():
		if x is val:
			print('DEBUG:{} -> {}'.format(name, val), file=sys.stderr)
			return None

def solve():
	a = input()
	b = input()
	if a == b:
		ans = -1
	else:
		ans = max(len(a), len(b))
	print(ans)
solve()


s = input()
t = input()
if s == t:
	print(-1)
else:
	print(max(len(s), len(t)))


s = input()
t = input()
if s != t:
	a = len(s)
	b = len(t)
	print(a if a > b else b)
else:
	print(-1)


string1 = input()
string2 = input()
if string1 != string2:
	print(max(len(string1), len(string2)))
else:
	print(-1)


n = list((x for x in input()))
n1 = list((x for x in input()))
if n1 == n:
	print(-1)
else:
	print(max(len(n1), len(n)))


a = input()
b = input()
if len(a) > len(b):
	print(len(a))
elif len(b) > len(a):
	print(len(b))
elif a > b:
	print(len(a))
elif b > a:
	print(len(b))
else:
	print(-1)


def ri():
	return map(int, input().split())
a = input()
b = input()
if a == b:
	print(-1)
else:
	print(max(len(a), len(b)))


def myf(s, m):
	if s == m:
		return -1
	else:
		return max(len(s), len(m))
s = input()
m = input()
res = myf(s, m)
print(res)


s = input()
t = input()
if s == t:
	print(-1)
elif len(s) >= len(t):
	print(len(s))
else:
	print(len(t))


a = input()
b = input()
there = []
for x in b:
	if x not in a:
		there.append(x)
if b != a:
	print(max(len(b), len(a)))
elif a == b:
	print(-1)
else:
	print(max(len(there) + 1, len(a)))


str1 = input()
str2 = input()
output = -1
if len(str1) > len(str2):
	output = len(str1)
elif len(str2) > len(str1):
	output = len(str2)
elif str1 != str2:
	output = len(str1)
else:
	output = -1
print(output)


import math
from collections import defaultdict, Counter, deque
INF = float('inf')

def gcd(a, b):
	while b:
		(a, b) = (b, a % b)
	return a

def primeFactor(n):
	if n % 2 == 0:
		return 2
	i = 3
	while i ** 2 <= n:
		if n % i == 0:
			return i
		i += 1
	return n

def main():
	str1 = input()
	str2 = input()
	l = max(len(str1), len(str2))
	match = 0
	res = l
	for i in range(min(len(str1), len(str2))):
		if str1[i] == str2[i]:
			match += 1
			res -= 1
		elif str1[i] != str2[i] and match:
			res += match
			match = 0
		elif str1[i] != str2[i] and match == 0:
			break
	if match > 0 and res > 0:
		res += match
	if res > 0:
		print(res)
	else:
		print(-1)
t = 1
for _ in range(t):
	main()


def long_unc_sub_seq(shorter, longer):
	if shorter == longer:
		return -1
	else:
		return max(len(shorter), len(longer))
str1 = input()
str2 = input()
print(long_unc_sub_seq(str2, str1))


(a, b) = (input(), input())
print([-1, max(len(a), len(b))][a != b])


s1 = input()
s2 = input()
n1 = len(s1)
n2 = len(s2)
if s1 == s2:
	print(-1)
else:
	print(max(n1, n2))


a = input()
b = input()
c = len(a)
d = len(b)
if a == b:
	print(-1)
elif c > d:
	print(c)
else:
	print(d)


a = input()
b = input()
l = list()
if len(a) != len(b):
	print(max(len(a), len(b)))
elif len(a) == len(b):
	if a != b:
		print(max(len(a), len(b)))
	else:
		print('-1')


x = input()
y = input()
cnt = 0
if len(x) == len(y):
	for i in range(len(y)):
		if y[i] in x[i]:
			cnt += 1
		else:
			break
	if cnt != len(x):
		print(len(y))
	else:
		print(-1)
else:
	print(max(len(y), len(x)))


s1 = input()
s2 = input()
if s1 == s2:
	print('-1')
else:
	print(max(len(s1), len(s2)))


import re
a = input()
b = input()
if a == b:
	print(-1)
	exit()
else:
	print(max(len(a), len(b)))
	exit()


import itertools

def sub_sequences(s: str) -> [str]:
	combs = []
	for l in range(1, len(s) + 1):
		combs.append(list(itertools.combinations(s, l)))
	result = []
	for c in combs:
		for t in c:
			result.append(''.join(t))
	return result
(a, b) = (input(), input())
if a == b:
	print(-1)
else:
	print(max(len(a), len(b)))


a = input()
b = input()
if a == b:
	print(-1)
else:
	count_a = len(a)
	count_b = len(b)
	if count_a >= count_b:
		print(count_a)
	else:
		print(count_b)


s1 = input()
s2 = input()
if s1 == s2:
	print(-1)
elif len(s1) > len(s2):
	print(len(s1))
else:
	print(len(s2))


a = str(input())
b = str(input())
if len(a) != len(b):
	print(max(len(a), len(b)))
elif a != b:
	print(len(a))
else:
	print(-1)


def main():
	(str1, str2) = (input(), input())
	print(-1 if str1 == str2 else max(len(str1), len(str2)))
main()


a = input()
b = input()
if a == b:
	print(-1)
	exit()
print(max(len(a), len(b)))


(a, b) = (input(), input())
if len(a) > len(b):
	(longest, shortest) = (a, b)
else:
	(longest, shortest) = (b, a)
if longest != shortest:
	print(len(longest))
else:
	print(-1)


x = input('')
y = input('')
if x == y:
	print('-1')
else:
	print(max(len(x), len(y)))


l = input('')
k = input('')
if len(l) == len(k):
	if l in k:
		print(-1)
	else:
		print(len(k))
else:
	print(max(len(l), len(k)))


st1 = input()
st2 = input()
l1 = len(st1)
l2 = len(st2)
if l1 > l2:
	print(l1)
elif l2 > l1:
	print(l2)
elif st1 == st2:
	print(-1)
else:
	print(l1)


gi = lambda : list(map(int, input().strip().split()))
(s, t) = (input(), input())
if s == t:
	print(-1)
else:
	print(max(len(s), len(t)))


a = input()
b = input()
(na, nb) = (len(a), len(b))
n = min(na, nb)
c = 0
for i in range(n):
	if a[i] == b[i]:
		c += 1
if na == nb and na == c:
	print(-1)
else:
	print(max(na, nb))


s = input()
a = input()
if len(s) == len(a):
	if s == a:
		print('-1')
	else:
		print(len(a))
else:
	print(max(len(s), len(a)))


import math
from collections import defaultdict, Counter, deque
INF = float('inf')

def gcd(a, b):
	while b:
		(a, b) = (b, a % b)
	return a

def primeFactor(n):
	if n % 2 == 0:
		return 2
	i = 3
	while i ** 2 <= n:
		if n % i == 0:
			return i
		i += 1
	return n

def main():
	str1 = input()
	str2 = input()
	if str1 != str2:
		print(max(len(str1), len(str2)))
	else:
		print(-1)
t = 1
for _ in range(t):
	main()


s = input()
s2 = input()
if s == s2:
	print(-1)
else:
	print(max(len(s), len(s2)))


x = input()
z = input()
if x == z:
	print('-1')
else:
	print(max(len(x), len(z)))


def read(type=int):
	return type(input())

def read_arr(type=int):
	return [type(token) for token in input().split()]
s = read(str)
r = read(str)
if len(s) > len(r):
	(s, r) = (r, s)
if s == r:
	print(-1)
else:
	print(len(r))


a = input()
b = input()
if a == b:
	print(-1)
elif b not in a or b in a:
	print(max(len(b), len(a)))


a = input()
b = input()
x = len(a)
y = len(b)
if a == b:
	print('-1')
else:
	print(max(x, y))


def longest_uncommon_ocuurence(a, b):
	if len(a) != len(b):
		return max(len(a), len(b))
	elif a != b:
		return len(a)
	else:
		return -1

def main():
	print(longest_uncommon_ocuurence(input(), input()))
main()


A = input()
B = input()
if len(A) < len(B):
	(A, B) = (B, A)
ans = len(A) if A != B else -1
print(ans)


x = input()
y = input()
n = len(x)
m = len(y)
i = 0
if n != m:
	if n > m:
		print(n)
	else:
		print(m)
else:
	while i < n and x[i] == y[i]:
		i += 1
	if i == n:
		print('-1')
	else:
		print(n)


n = input()
m = input()
if n == m:
	print(int(-1))
else:
	print(max(len(n), len(m)))


line1 = input()
line2 = input()
if len(line1) > len(line2):
	print(len(line1))
elif len(line2) > len(line1):
	print(len(line2))
elif line1 == line2:
	print(-1)
else:
	print(len(line1))


n = 0
a = input()
b = input()
if a == b:
	print(-1)
else:
	print(max(len(a), len(b)))


i = input
(a, b) = (i(), i())
(c, d) = (len(a), len(b))
print(-1 if a == b else [c, d][c < d])


import sys
fin = sys.stdin
fout = sys.stdout
s1 = fin.readline().strip()
s2 = fin.readline().strip()
if len(s1) != len(s2):
	fout.write(str(max(len(s1), len(s2))))
elif s1 == s2:
	fout.write('-1')
else:
	fout.write(str(len(s1)))


import sys, os
from math import sqrt, gcd, ceil, log, floor, sin, pi
from math import factorial as fact
from bisect import bisect, bisect_left
from collections import defaultdict, Counter, deque
from heapq import heapify, heappush, heappop
from itertools import permutations
input = sys.stdin.readline
read = lambda : list(map(int, input().strip().split()))
MOD = 10 ** 9 + 7

def main():
	a = input().strip()
	b = input().strip()
	if len(a) == len(b):
		if a == b:
			print(-1)
		else:
			print(len(a))
	else:
		print(max(len(a), len(b)))
main()


s1 = str(input())
s2 = str(input())
print(-1 if s1 == s2 else len(s1) if len(s1) > len(s2) else len(s2))


A = input()
B = input()
if A == B:
	print(-1)
else:
	print(max([len(A), len(B)]))


n = input()
m = input()
if n != m:
	c = max(len(n), len(m))
else:
	c = -1
print(c)


def longest(a, b):
	if len(a) > len(b):
		return len(a)
	elif len(a) == len(b):
		if a in b:
			return -1
		else:
			return len(a)
	else:
		return len(b)
a = input()
b = input()
print(longest(a, b))


a = input()
b = input()
l = max(len(a), len(b))
flag = 0
if len(a) == len(b):
	for i in range(l):
		if a[i] != b[i]:
			flag = 1
			print(l)
			break
	if flag == 0:
		print(-1)
else:
	print(l)


a = input()
b = input()
A = len(a)
B = len(b)
if a == b:
	print(-1)
else:
	print(max(A, B))


s = input()
ss = input()
if ss == s:
	print(-1)
else:
	print(max(len(s), len(ss)))


s = input()
t = input()
if s == t:
	print(-1)
else:
	x = len(s)
	y = len(t)
	print(max(x, y))


s = input()
s1 = input()
if s == s1:
	print(-1)
else:
	print(max(len(s), len(s1)))


a = list(input())
b = list(input())
m = len(a)
n = len(b)
if m != n:
	print(max(m, n))
elif a == b:
	print(-1)
else:
	print(m)


f = lambda : map(int, input().split())
a = input()
b = input()
print([max(len(a), len(b)), -1][a == b])


read = lambda : map(int, input().split())
(a, b) = (input(), input())
if a == b:
	print(-1)
else:
	print(max(len(a), len(b)))


import sys

def main(s1, s2):
	if not s1 and (not s2):
		return -1
	if not s1 and s2:
		return len(s2)
	if s1 and (not s2):
		return len(s1)
	if len(s1) != len(s2):
		return max(len(s1), len(s2))
	i = 0
	while i < len(s1):
		if s1[i] != s2[i]:
			return len(s1)
		else:
			i += 1
	return -1
for (e, line) in enumerate(sys.stdin.readlines()):
	if e == 0:
		s1 = line.strip()
	else:
		s2 = line.strip()
print(main(s1, s2))


stringOne = input()
stringTwo = input()
if stringOne == stringTwo:
	print(-1)
else:
	print(max(len(stringOne), len(stringTwo)))


a = str(input())
b = str(input())
c = 0
if a == b:
	print('-1')
elif len(a) > len(b):
	c = len(a)
	print(c)
else:
	c = len(b)
	print(c)


a = str(input().strip())
b = str(input().strip())
l1 = len(a)
l2 = len(b)
if l1 != l2:
	print(max(l1, l2))
elif a == b:
	print(-1)
else:
	print(l1)


(str1, str2) = (input(), input())
if str1 == str2:
	print(-1)
else:
	print(max(len(str2), len(str1)))


import sys
s1 = input()
s2 = input()
s11 = set((c for c in s1))
s22 = set((c for c in s2))
if len(s1) != len(s2):
	print(max(len(s1), len(s2)))
	sys.exit(0)
if s1 == s2:
	print(-1)
	sys.exit(0)
print(len(s1))


a = input()
b = input()
ls_a = []
ls_b = []
l = 0
while 1:
	if len(a) > len(b):
		if a not in b:
			print(len(a))
			break
		else:
			a.replace(a[len(a) - 1], '')
			l = -1
	elif b not in a:
		print(len(b))
		break
	else:
		b.replace(b[len(b) - 1], '')
		l = -1
	print(l)
	break


s1 = input()
s2 = input()
m = max(len(s1), len(s2))
dp = [0] * 100001
dp[0] = 0 if s1[0] == s2[0] else 1
for i in range(1, m):
	try:
		if s1[i] != s2[i]:
			dp[i] = dp[i - 1] + 1
	except:
		dp[i] = dp[i - 1] + 1
print(m) if max(dp) != 0 else print(-1)


a = input()
b = input()
A = len(a)
B = len(b)
if A > B:
	print(A)
elif B > A:
	print(B)
elif a != b:
	print(A)
else:
	print(-1)


from collections import Counter
st = input()
st2 = input()
a = Counter(st)
b = Counter(st2)
t = b - a
t2 = a - b
s = sum([t[i] for i in t.keys()])
s2 = sum([t2[i] for i in t2.keys()])
if s == s2 == 0:
	if st == st2:
		print(-1)
	else:
		print(len(st))
else:
	u = a & b
	print(max(s, s2) + sum([u[i] for i in u.keys()]))


a = input()
b = input()
l1 = len(a)
l2 = len(b)
if l1 > l2:
	print(l1)
elif l2 > l1:
	print(l2)
elif a == b:
	print(-1)
else:
	print(l1)


def longest_uncommon(s1, s2):
	if len(s1) > len(s2):
		return longest_uncommon(s2, s1)
	if len(s1) == 0 or len(s1) < len(s2):
		return len(s2)
	if s1 == s2:
		return -1
	else:
		return len(s2)
str1 = input()
str2 = input()
print(longest_uncommon(str1, str2))


x = input()
y = input()
if len(y) > len(x):
	print(len(y))
elif len(y) < len(x):
	print(len(x))
elif len(y) == len(x):
	if y == x:
		print(-1)
	else:
		print(len(x))


s1 = input()
s2 = input()
if s1 == s2:
	print(-1)
else:
	(l1, l2) = (len(s1), len(s2))
	if l1 > l2:
		print(l1)
	else:
		print(l2)


a = input()
b = input()

def lus(a, b):
	if len(a) > len(b):
		return len(a)
	elif len(b) > len(a):
		return len(b)
	elif a == b:
		return '-1'
	else:
		return len(a)
print(lus(a, b))


a = list(input())
b = list(input())
if len(a) > len(b):
	print(len(a))
elif len(b) > len(a):
	print(len(b))
elif len(a) == len(b) and a != b:
	print(len(a))
else:
	print(-1)


s = input()
s1 = input()
if len(s) < len(s1):
	r = s1
	s1 = s
	s = r
if s not in s1:
	print(len(s))
else:
	print(-1)


a = str(input())
b = str(input())
s1 = max(len(a), len(b))
if a == b:
	print(-1)
else:
	print(s1)


from sys import stdin, stdout
f = stdin.readline().strip()
s = stdin.readline().strip()
if f == s:
	stdout.write('-1')
else:
	stdout.write(str(max(len(s), len(f))))


import sys
import math
get_string = lambda : sys.stdin.readline().strip()
get_int_list = lambda : list(map(int, sys.stdin.readline().strip().split()))
get_int = lambda : int(sys.stdin.readline())
s = get_string()
t = get_string()
if s == t:
	print(-1)
else:
	print(max(len(s), len(t)))


s1 = input()
s2 = input()
l1 = len(s1)
l2 = len(s2)
if l1 != l2:
	print(max(l1, l2))
else:
	for i in range(l1):
		if s1[i] != s2[i]:
			print(l1)
			break
	else:
		print(-1)


a = str(input())
b = str(input())
c = list(b)
d = list(a)
if a == b:
	print(-1)
elif len(c) == 0 or len(d) == 0:
	print(-1)
else:
	print(max(len(c), len(d)))


(x, y) = (input(), input())
print([-1, max(len(x), len(y))][x != y])


def solve():
	a = input()
	b = input()
	if a != b:
		print(max(len(a), len(b)))
	else:
		print(-1)
solve()


import os
LOCAL_PC = 'n1amr' in os.path.expanduser('~')

def process_file(in_name, out_name):
	with open(in_name, 'r') as fin:
		with open(out_name, 'w') as fout:

			def read():
				return fin.readline().rstrip('\n')

			def write(*args, end='\n'):
				text = ' '.join(map(str, args)) + end
				fout.write(text)
				print(text, end='')
			t = int(fin.readline())
			for i in range(t):
				read()
				write('Case #{T}: \n'.format(T=i + 1), end='')
				solve(read, write)
				write()

def process_stdio():

	def read():
		return input()

	def write(*args, end='\n'):
		print(*args, end=end)
	solve(read, write)

def solve(input, print):
	(a, b) = [input() for _ in range(2)]
	if a == b:
		print(-1)
	else:
		print(max(len(a), len(b)))
if LOCAL_PC:
	in_name = __file__[:-3] + '.in'
	out_name = __file__[:-3] + '.out'
	process_file(in_name, out_name)
else:
	process_stdio()


a = input()
b = input()
while a == '' or b == '':
	a = input()
	b = input()
if a == b:
	print(-1)
elif len(a) > len(b):
	print(len(a))
else:
	print(len(b))


import sys
a = input()
b = input()
if a == b:
	print(-1)
	return
print(max(len(a), len(b)))


(strng1, strng2) = (input(), input())
if strng1 == strng2:
	print(-1)
elif len(strng1) > len(strng2):
	print(len(strng1))
else:
	print(len(strng2))


import math

def longsub(s, t):
	if s == t:
		return -1
	else:
		return max(len(s), len(t))
s = input()
t = input()
print(longsub(s, t))


import math, re, itertools as it
prime = lambda n: len([i for i in range(2, int(math.sqrt(n) + 1)) if n % i == 0]) == 0
gcd = lambda a, b: gcd(b, a % b) if b else a
fact = lambda x: x * fact(x - 1) if x else 1
bino = lambda n, k: fact(n) / fact(k) / fact(n - k)
fib11 = lambda n: 1 if n < 2 else fib11(n - 1) + fib11(n - 2)
fib01 = lambda n: 0 if n == 0 else 1 if n == 1 else fib01(n - 1) + fib01(n - 2)
sumofd = lambda x: x if x < 10 else sumofd(x // 10) + x % 10
a = input()
b = input()
if len(b) > len(a):
	print(len(b))
elif len(a) > len(b):
	print(len(a))
elif a != b:
	print(len(a))
else:
	print(-1)


a = input()
b = input()
len_a = len(a)
len_b = len(b)
if len_a != len_b:
	print(max(len_a, len_b))
elif a == b:
	print(-1)
else:
	print(len_a)


a = input()
b = input()
al = len(a)
bl = len(b)
if a == b:
	print(-1)
elif al > bl:
	print(al)
else:
	print(bl)


x = input()
y = input()
s_x = len(x)
s_y = len(y)
if x == y:
	print(-1)
else:
	print(max(s_x, s_y))


n = input()
m = input()
if n == m:
	print(-1)
else:
	a = len(n)
	b = len(m)
	print(max(a, b))


from __future__ import division, print_function
from fractions import Fraction
import sys
import os
from io import BytesIO, IOBase
from heapq import *
from math import gcd, factorial, floor, ceil
from copy import deepcopy
from collections import deque
from bisect import bisect_left as bl
from bisect import bisect_right as br
from bisect import bisect
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
if sys.version_info[0] < 3:
	(sys.stdin, sys.stdout) = (FastIO(sys.stdin), FastIO(sys.stdout))
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
from types import GeneratorType

def iterative(f, stack=[]):

	def wrapped_func(*args, **kwargs):
		if stack:
			return f(*args, **kwargs)
		to = f(*args, **kwargs)
		while True:
			if type(to) is GeneratorType:
				stack.append(to)
				to = next(to)
				continue
			stack.pop()
			if not stack:
				break
			to = stack[-1].send(to)
		return to
	return wrapped_func
mod = 10 ** 9 + 7

def inp():
	return sys.stdin.readline().rstrip('\r\n')

def out(var):
	sys.stdout.write(str(var))

def lis():
	return list(map(int, inp().split()))

def stringlis():
	return list(map(str, inp().split()))

def sep():
	return map(int, inp().split())

def strsep():
	return map(str, inp().split())

def zerolist(n):
	return [0] * n

def nextline():
	out('\n')

def testcase(t):
	for pp in range(t):
		solve(pp)

def printlist(a):
	for p in range(0, len(a)):
		out(str(a[p]) + ' ')

def google(p):
	print('Case #' + str(p) + ': ', end='')

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

def power(x, y, p):
	res = 1
	x = x % p
	if x == 0:
		return 0
	while y > 0:
		if y & 1 == 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res

def ncr(n, r):
	return factorial(n) // (factorial(r) * factorial(max(n - r, 1)))

def isPrime(n):
	if n <= 1:
		return False
	if n <= 3:
		return True
	if n % 2 == 0 or n % 3 == 0:
		return False
	i = 5
	while i * i <= n:
		if n % i == 0 or n % (i + 2) == 0:
			return False
		i = i + 6
	return True

def solve(case):
	a = inp()
	b = inp()
	if a == b:
		print(-1)
		return
	print(len(a) if len(a) >= len(b) else len(b))
testcase(1)


stringA = input()
stringB = input()
if stringA == stringB:
	print(-1)
else:
	print(len(stringA) if len(stringA) >= len(stringB) else len(stringB))


S = input()
T = input()
if S == T:
	print(-1)
elif len(S) > len(T):
	print(len(S))
else:
	print(len(T))


import os
import sys
a = input('')
b = input('')
if a == b:
	print('-1')
elif len(a) > len(b):
	print(len(a))
else:
	print(len(b))


a = input()
b = input()
lna = len(a)
lnb = len(b)
if lna != lnb:
	print(max(lna, lnb))
elif a != b:
	print(lna)
else:
	print(-1)


def Main():
	a = input()
	b = input()
	if a == b:
		print(-1)
	elif len(a) > len(b):
		print(len(a))
	else:
		print(len(b))
Main()


str1 = str(input())
str2 = str(input())
if len(str1) == len(str2):
	if str1 == str2:
		print('-1')
		exit()
print(len(str1) if len(str1) > len(str2) else len(str2))


s1 = input()
s2 = input()
if s1 == s2:
	print(-1)
elif s1 != s2:
	print(max(len(s1), len(s2)))


import itertools as it
a = input()
b = input()
print(-1 if a == b else max(len(a), len(b)))


a = input()
b = input()
la = len(a)
lb = len(b)
if a != b:
	print(max(la, lb))
else:
	print(-1)


s = input()
s1 = input()
print([max(len(s), len(s1)), -1][s == s1])


a = input()
b = input()
if a in b or b in a:
	if len(a) == len(b):
		print(-1)
	elif len(a) > len(b):
		print(len(a))
	elif len(b) > len(a):
		print(len(b))
elif len(a) == len(b):
	print(len(a))
elif len(a) > len(b):
	print(len(a))
elif len(b) > len(a):
	print(len(b))


def lucs(string_a, string_b):
	if string_a == string_b:
		return -1
	return max(len(string_a), len(string_b))
string_a = input()
string_b = input()
response = lucs(string_a, string_b)
print(response)


s = input()
b = input()
if s == b:
	print(-1)
else:
	print(max(len(s), len(b)))


from sys import stdin
max_val = int(10000000000000.0)
min_val = int(-10000000000000.0)

def read_int():
	return int(stdin.readline())

def read_ints():
	return [int(x) for x in stdin.readline().split()]

def read_str():
	return input()

def read_strs():
	return [x for x in stdin.readline().split()]
wa = read_str()
wb = read_str()
print('-1' if wa == wb else max(len(wa), len(wb)))


import math, sys
from collections import Counter, defaultdict, deque
from sys import stdin, stdout
input = stdin.readline
lili = lambda : list(map(int, sys.stdin.readlines()))
li = lambda : list(map(int, input().split()))
I = lambda : int(input())
S = lambda : input().strip()
a = S()
b = S()
if a == b:
	print(-1)
else:
	print(max(len(a), len(b)))


from sys import stdin, stdout
from collections import defaultdict
import heapq as hq

def get_int():
	return int(stdin.readline().strip())

def get_ints():
	return map(int, stdin.readline().strip().split())

def get_array():
	return list(map(int, stdin.readline().strip().split()))

def get_string():
	return stdin.readline().strip()
INF = 10000000000.0
a = get_string()
b = get_string()
if a == b:
	print(-1)
else:
	print(max(len(a), len(b)))


in1 = input()
in2 = input()
if in1 == in2:
	print('-1')
elif len(in1) > len(in2):
	print(len(in1))
else:
	print(len(in2))


n = input()
m = input()
a = len(n)
b = len(m)
if n == m:
	print('-1')
elif n != m:
	if a > b:
		print(a)
	elif b > a:
		print(b)
	else:
		print(a)


def read_input():
	x = input().strip()
	y = input().strip()
	if abs(len(x) - len(y)) == 0:
		if x == y:
			print(-1)
		else:
			print(len(x) if len(x) > len(y) else len(y))
	else:
		print(len(x) if len(x) > len(y) else len(y))
read_input()


def bla():
	a = input()
	b = input()
	if len(a) == len(b):
		if a == b:
			return -1
		else:
			return len(a)
	elif len(a) > len(b):
		return len(a)
	else:
		return len(b)
print(bla())


import sys
a = sys.stdin.readline()
b = sys.stdin.readline()
if a == b:
	print(-1)
else:
	print(max(len(a), len(b)) - 1)


def main():
	st1 = input()
	st2 = input()
	if st1 == st2:
		print(-1)
	elif len(st1) > len(st2):
		print(len(st1))
	else:
		print(len(st2))
main()


s = input()
n = input()
if s == n:
	print(-1)
else:
	print(max(len(n), len(s)))


a = input()
b = input()
aa = len(a)
bb = len(b)
if a == b:
	print(-1)
else:
	print(max(aa, bb))


def main():
	a = input()
	b = input()
	l = 0
	if a == b:
		print(-1)
	else:
		print(max(len(a), len(b)))
main()


import sys
input = sys.stdin.readline
s = input().strip()
t = input().strip()
if s == t:
	print(-1)
else:
	print(max(len(s), len(t)))


x = input()
y = input()
if x == y:
	print(-1)
else:
	length1 = len(x)
	length2 = len(y)
	if length1 > length2:
		print(length1)
	else:
		print(length2)


w1 = input()
w2 = input()
(n1, n2) = (len(w1), len(w2))
if n1 == n2:
	if w1 == w2:
		print(-1)
	else:
		print(n1)
elif n1 > n2:
	print(n1)
else:
	print(n2)


def R():
	return map(int, input().split())

def I():
	return int(input())

def S():
	return str(input())

def L():
	return list(R())
from collections import Counter
import math
import sys
from itertools import permutations
a = S()
b = S()
if a == b:
	print('-1')
else:
	print(max(len(a), len(b)))


strA = input()
strB = input()
if strA == strB:
	print('-1')
else:
	lenA = len(strA)
	lenB = len(strB)
	print(max(lenA, lenB))


str1 = input()
str2 = input()
le1 = len(str1)
le2 = len(str2)
if le1 > le2:
	print(le1)
elif le2 > le1:
	print(le2)
else:
	for j in range(le1, -1, -1):
		if str1[0:j] != str2[0:j]:
			print(j)
			break
		if j == 0:
			print(-1)


from collections import deque

def main():
	from sys import stdin
	lines = deque((line.strip() for line in stdin.readlines()))
	a = lines.popleft()
	b = lines.popleft()
	if a == b:
		print(-1)
	else:
		print(max(len(a), len(b)))
main()


def Solve():
	s = input()
	f = input()
	if s == f:
		print(-1)
	else:
		print(max(len(f), len(s)))
Solve()


Str1 = list(input())
Str2 = list(input())
if Str1 == Str2:
	print(-1)
else:
	print(max(len(Str1), len(Str2)))


def solution(a, b):
	if a == b:
		return -1
	return max(len(a), len(b))
a = input()
b = input()
print(solution(a, b))


import sys
read = lambda : sys.stdin.readline().strip()
write = lambda x: sys.stdout.write(x)
a = read()
b = read()
(la, lb) = (len(a), len(b))
if a == b:
	write('-1\n')
elif la > lb:
	write(str(la) + '\n')
else:
	write(str(lb) + '\n')


def solve(a, b):
	m = max(len(a), len(b))
	if len(a) != len(b):
		return m
	return m if a != b else -1
res = solve(input(), input())
print(res)


a = input()
b = input()
if not a.__contains__(b) or not b.__contains__(a):
	print(max(len(a), len(b)))
else:
	print('-1')


def run():
	import sys
	sys.stdin = open('/home/punit/Documents/Cpp Programs/input.txt', 'r')
	sys.stdout = open('/home/punit/Documents/Cpp Programs/output.txt', 'w')
	from math import ceil, sqrt, floor
s = input()
p = input()
if len(s) < len(p):
	(s, p) = (p, s)
if s == p:
	print(-1)
else:
	print(max(len(s), len(p)))


import sys
a = input()
b = input()
if a != b:
	print(max(len(a), len(b)))
else:
	print(-1)


import math
import sys

def ri():
	return input()

def ii():
	return int(input())

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

def mi():
	return list(map(int, input().split()))
a = ri()
b = ri()
if a == b:
	print(-1)
elif len(a) > len(b):
	print(len(a))
else:
	print(len(b))


word1 = input()
word2 = input()
if word1 == word2:
	print(-1)
else:
	print(max(len(word1), len(word2)))


from itertools import combinations

def solve():
	a = input()
	b = input()
	longest = -1
	c = 0
	if len(a) == max(len(a), len(b)):
		x = a
		y = b
	else:
		x = b
		y = a
	if a != b:
		print(len(x))
	else:
		print(-1)
solve()


(a, b) = (input().strip(), input().strip())
lenA = len(a)
lenB = len(b)
if lenA > lenB:
	print(lenA)
elif lenB > lenA:
	print(lenB)
elif a != b:
	print(lenA)
else:
	print(-1)


s = input()
v = input()
F = len(s)
S = len(v)
if F < S:
	F = S
if v == s:
	print(-1)
else:
	print(F)


import sys

class Solver(object):

	def run(self):
		a = input()
		b = input()
		if a == b:
			print('-1')
		else:
			print(max(len(a), len(b)))
Solver().run()


C1 = input()
C2 = input()
if C1 != C2:
	print(len(C1) if len(C1) >= len(C2) else len(C2))
else:
	print('-1')


x = input()
y = input()
print(x == y and -1 or max(len(x), len(y)))


def main():
	s1 = input()
	s2 = input()
	if s1 == s2:
		print(-1)
	elif len(s1) == len(s2) and s1 != s2:
		print(len(s1))
	else:
		print(max(len(s1), len(s2)))
main()


first_string = input()
second_string = input()
length_first = len(first_string)
length_second = len(second_string)
if first_string == second_string:
	print('-1')
else:
	print(max(length_first, length_second))


firstLine = input()
secondLine = input()
if firstLine == secondLine:
	print(-1)
else:
	l1 = len(firstLine)
	l2 = len(secondLine)
	if l1 > l2:
		print(l1)
	else:
		print(len(secondLine))


import sys
a = input()
b = input()
if a == b:
	print(-1)
	sys.exit()
print(max(len(a), len(b)))


import sys
a = input()
b = input()
r = 0
m = 0
n = 0
v = ''
s = ''
if len(a) == len(b) and a == b:
	r = -1
elif len(a) == len(b) and a != b:
	r = len(a)
else:
	m = max(len(a), len(b))
	r = m
print(r)


a = input()
b = input()
if b in a and a in b:
	print(-1)
elif len(a) >= len(b):
	print(len(a))
else:
	print(len(b))


a = input()
b = input()
if len(a) > len(b):
	print(len(a))
elif len(a) < len(b):
	print(len(b))
else:
	print(len(a) if not a.__eq__(b) else -1)


(s, p) = (str(input()), str(input()))
if len(s) != len(p):
	print(max(len(s), len(p)))
elif s == p:
	print(-1)
else:
	print(len(s))


string_1 = [char for char in input()]
string_2 = [char for char in input()]
uncom_seq_counter = 0
comm_seq_counter = 0
for i in range(0, max(len(string_1), len(string_2)), 1):
	if string_1[i:i + 1] != string_2[i:i + 1]:
		uncom_seq_counter += 1
	else:
		comm_seq_counter += 1
if uncom_seq_counter == 0:
	print(-1)
else:
	print(comm_seq_counter + uncom_seq_counter)


A = input()
B = input()
if A == B:
	print(-1)
elif A in B:
	print(len(B))
elif B in A:
	print(len(A))
else:
	print(max(len(A), len(B)))


def sol(str1, str2):
	if str1 not in str2:
		return len(str1)
	else:
		return -1
str1 = input()
str2 = input()
ans = -1
if len(str1) > len(str2):
	ans = sol(str1, str2)
else:
	ans = sol(str2, str1)
print(ans)


a = input()
b = input()
alen = len(a)
blen = len(b)
if a == b:
	print(-1)
else:
	print(max(alen, blen))


def longi_boi(a, b):
	if a == b:
		return -1
	else:
		return max(len(a), len(b))
a = input()
b = input()
print(longi_boi(a, b))


s = input().rstrip()
p = input().rstrip()
if s == p:
	print(-1)
else:
	print(max(len(s), len(p)))


a = input()
b = input()
if len(a) != len(b):
	print(len(max(a, b, key=lambda string: len(string))))
elif a == b:
	print(-1)
else:
	for i in range(len(a), -1, -1):
		if a[:i] not in b:
			print(len(a[:i]))
			break


def solution():
	text1 = input()
	text2 = input()
	if text1 == text2:
		print(-1)
	else:
		print(max(len(text1), len(text2)))
solution()


s1 = input()
s2 = input()
l1 = len(s1)
l2 = len(s2)
if l1 != l2:
	print(max(l1, l2))
else:
	count = 0
	for i in range(l1):
		if s1[i] == s2[i]:
			count += 1
	if count == l1:
		print(-1)
	else:
		print(l1)


def main():
	s1 = input()
	s2 = input()
	if s1 == s2:
		print(-1)
	elif len(s1) > len(s2):
		print(len(s1))
	else:
		print(len(s2))
main()


a = input()
b = input()
if a == b:
	print(-1)
else:
	a_len = len(a)
	b_len = len(b)
	print(a_len if a_len > b_len else b_len if a_len < b_len else b_len)


from math import ceil, sqrt, gcd, log, floor
from collections import deque

def ii():
	return int(input())

def si():
	return input()

def mi():
	return map(int, input().strip().split(' '))

def li():
	return list(mi())

def main():
	a = si()
	b = si()
	if a == b:
		print('-1')
	else:
		print(max(len(a), len(b)))
main()


def is_subsequence(sequence1, sequence2):
	return sequence1 != sequence2

def longest_subsequence(sequence1, sequence2):
	if is_subsequence(sequence1, sequence2):
		return max(len(sequence1), len(sequence2))
	return -1
(sequence1, sequence2) = (input(), input())
print(longest_subsequence(sequence1, sequence2))


s = input()
sx = input()
if s == sx:
	print(-1)
else:
	print(max(len(s), len(sx)))


def get_max_diff_len(a, b):
	if a == b:
		return -1
	elif len(a) > len(b):
		return len(a)
	elif len(b) > len(a):
		return len(b)
	elif len(a) == len(b) and a != b:
		return len(a)
	for i in range(len(a), 1, -1):
		j = 0
		while j + i <= len(a):
			if a[j:j + i - 1] not in b:
				return i
			j += 1
a = input()
b = input()
print(get_max_diff_len(a, b))


s_1 = input()
s_2 = input()
longest_seq = s_1 if len(s_1) > len(s_2) else s_2
shortest_seq = s_2 if len(s_1) > len(s_2) else s_1
first_c = shortest_seq[0]
if longest_seq == shortest_seq:
	print(-1)
elif first_c not in longest_seq:
	print(len(longest_seq))
else:
	print(len(longest_seq))


def biggest_non(s, t):
	if s == t:
		return -1
	elif len(s) > len(t):
		return len(s)
	else:
		return len(t)
s1 = input()
t1 = input()
print(biggest_non(s1, t1))


a = input()
b = input()
ans = 0
if a == b:
	ans = -1
else:
	ans = max(len(a), len(b))
print(ans)


def uncommon(a, b):
	if a == b:
		return -1
	return max(len(a), len(b))
A = input()
B = input()
print(uncommon(A, B))


def inp():
	return map(int, input().split())

def arr_inp():
	return [int(x) for x in input().split()]

def print_arr(arr):
	print(*arr, sep=' ')
(a, b) = (input(), input())
(min, max) = (b, a)
count = 0
if len(a) <= len(b):
	(min, max) = (a, b)
if a == b:
	print(-1)
else:
	print(len(max))


p = input()
s = input()
if len(p) > len(s):
	print(len(p))
elif len(s) > len(p):
	print(len(s))
if s == p:
	print(-1)
elif len(s) == len(p):
	print(len(s))


s = list(input().rstrip())
t = list(input().rstrip())
if s == t:
	print(-1)
else:
	print(max(len(s), len(t)))


s1 = input()
sl1 = len(s1)
s2 = input()
sl2 = len(s2)
if s1 == s2:
	print(-1)
else:
	x = sl1 if sl1 > sl2 else sl2
	print(x)


str_1 = str(input())
str_2 = str(input())
if str_1 != str_2:
	print(max(len(str_1), len(str_2)))
else:
	print(-1)


def longest_uncommon(a, b):
	i = 0
	if b == '' or a == '':
		return -1
	else:
		for j in range(len(a)):
			if b[i] == a[j]:
				i += 1
			if i == len(b):
				break
		if i == len(b):
			return -1
		else:
			return len(b)
a = input()
b = input()
print(max(longest_uncommon(a, b), longest_uncommon(b, a)))


import math, sys, itertools

def main():
	s1 = input()
	s2 = input()
	if len(s1) > len(s2):
		print(len(s1))
		sys.exit(0)
		sys.exit(0)
	if s1 == s2:
		print(-1)
	else:
		print(len(s2))
main()


from collections import deque
from collections import Counter
from itertools import permutations
import heapq

def counterExample():
	arr = [1, 3, 4, 1, 2, 1, 1, 3, 4, 3, 5, 1, 2, 5, 3, 4, 5]
	counter = Counter(arr)
	top_three = counter.most_common(3)
	print(top_three)
q = deque()

def main():
	a = input()
	b = input()
	max = None
	if a == b:
		print(-1)
	elif len(a) > len(b):
		print(len(a))
	else:
		print(len(b))
main()


import collections
import functools
str1 = input()
str2 = input()
if str1 == str2:
	print(-1)
else:
	print(max(len(str1), len(str2)))


import os
import re
import sys
from bisect import bisect, bisect_left, insort, insort_left
from collections import Counter, defaultdict, deque
from copy import deepcopy
from decimal import Decimal
from fractions import gcd
from io import BytesIO, IOBase
from itertools import accumulate, combinations, combinations_with_replacement, groupby, permutations, product
from math import acos, asin, atan, ceil, cos, degrees, factorial, hypot, log2, pi, radians, sin, sqrt, tan
from operator import itemgetter, mul
from string import ascii_lowercase, ascii_uppercase, digits

def inp():
	return int(input())

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

def instr():
	s = input()
	return list(s[:len(s)])

def invr():
	return map(int, input().split())

def main():
	a = input()
	b = input()
	n1 = len(a)
	n2 = len(b)
	res = -1
	if n1 != n2:
		print(max(n1, n2))
		sys.exit()
	for i in range(min(n1, n2)):
		if a[i] != b[i]:
			res = max(n1, n2)
			break
	print(res)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))

def input():
	return sys.stdin.readline().rstrip('\r\n')
main()


import math

def main():
	string = str(input())
	string2 = str(input())
	if len(string) == len(string2):
		if string != string2:
			print(len(string))
		else:
			print('-1')
	else:
		print(max(len(string), len(string2)))
	return
main()


(a, b) = (input(), input())
if a == b:
	print(-1)
while a != b:
	print(max(len(a), len(b)))
	break


a = input()
b = input()
soln = ''
if a == b:
	print(-1)
else:
	n1 = len(a)
	n2 = len(b)
	if n1 > n2:
		print(n1)
	else:
		print(n2)


def main():
	a = input()
	b = input()
	if a == b:
		print(-1)
	else:
		print(max(len(a), len(b)))
main()


def __starting_point():
	a = input()
	b = input()
	if a == b:
		print(-1)
	else:
		print(max(len(a), len(b)))
__starting_point()


x = input()
y = input()
lx = len(x)
ly = len(y)
if x == y:
	print(-1)
elif lx == ly:
	print(lx)
elif lx > ly:
	print(lx)
else:
	print(ly)


q = input()
w = input()
if q == w:
	print(-1)
else:
	print(max(len(q), len(w)))


(s1, s2) = (input(), input())
print([max(len(s1), len(s2)), '-1'][s1 == s2])


li = list(input())
li1 = list(input())
if li == li1:
	print(-1)
elif len(li) == len(li1):
	print(len(li))
elif len(li) > len(li1):
	print(len(li))
else:
	print(len(li1))


def solve(a, b):
	if a == b:
		return -1
	return max(len(a), len(b))
a = input()
b = input()
print(solve(a, b))


n = input()
s = input()
ans = 0
if n == s:
	print(-1)
else:
	print(max(len(s), len(n)))


import webbrowser
if True == False:
	url = input()
	while True:
		webbrowser.open(url)
else:
	a = input()
	b = input()
	if a == b:
		print(-1)
	else:
		print(max(len(a), len(b)))


S1 = input()
S2 = input()
if len(S1) != len(S2):
	print(max(len(S1), len(S2)))
elif S1 == S2:
	print(-1)
else:
	print(len(S1))


a = input().strip()
b = input().strip()
lena = len(a)
lenb = len(b)
if lena > lenb:
	print(lena)
elif lenb > lena:
	print(lenb)
elif a in b:
	print(-1)
else:
	print(lena)


s = input()
t = input()
sl = len(s)
st = len(t)
if sl != st:
	print(max(sl, st))
elif s == t:
	print(-1)
else:
	print(sl)


from collections import Counter
a = input()
b = input()
if Counter(a) == Counter(b):
	print(-1 if a == b else len(a))
else:
	print(len(a) if len(a) > len(b) else len(b))


import math
a = input()
b = input()
(la, lb) = (len(a), len(b))
if a == b:
	print(-1)
else:
	print(max(la, lb))


(a, b) = (input(), input())
(sa, sb) = (len(a), len(b))
if sa > sb:
	print(sa)
elif a != b:
	print(sb)
else:
	print(-1)


import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, random, time, copy, functools
sys.setrecursionlimit(10 ** 7)
inf = 10 ** 20
eps = 1.0 / 10 ** 10
mod = 10 ** 9 + 7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]

def LI():
	return [int(x) for x in sys.stdin.readline().split()]

def LI_():
	return [int(x) - 1 for x in sys.stdin.readline().split()]

def LF():
	return [float(x) for x in sys.stdin.readline().split()]

def LS():
	return sys.stdin.readline().split()

def I():
	return int(sys.stdin.readline())

def F():
	return float(sys.stdin.readline())

def S():
	return input()

def pf(s):
	return print(s, flush=True)

def main():
	s = S()
	t = S()
	if s == t:
		return -1
	return max(len(s), len(t))
print(main())


def r():
	return list(map(int, input().split()))
I = input
a = I()
b = I()
if a == b:
	print(-1)
else:
	print(max(len(a), len(b)))


str1 = str(input())
str2 = str(input())
if str1 == str2:
	print('-1')
elif len(str1) > len(str2):
	print(len(str1))
else:
	print(len(str2))


x = input()
y = input()
if x == y:
	print('-1')
else:
	l1 = len(x)
	l2 = len(y)
	if l1 >= l2:
		print(l1)
	else:
		print(l2)


def getLongest(a, b):
	if a == b:
		return -1
	elif len(a) > len(b):
		return len(a)
	else:
		return len(b)
a = input()
b = input()
print(getLongest(a, b))


s1 = input()
s2 = input()
if s1 == s2:
	print('-1')
if len(s1) > len(s2):
	print(len(s1))
if len(s1) < len(s2):
	print(len(s2))
if len(s1) == len(s2):
	if s1 != s2:
		print(len(s1))


a = input()
b = input()
c = 0
d = []
if a == b:
	print(-1)
else:
	print(max(len(a), len(b)))


def findSubsequence(string1, string2):
	if str(string1) == str(string2):
		return -1
	else:
		longest = max(len(string1), len(string2))
		return longest
string1 = input()
string2 = input()
print(findSubsequence(string1, string2))


a = input()
b = input()
l = []
l.append(a)
l.append(b)
l.sort(key=len)
if a == b:
	print(-1)
else:
	print(len(l[1]))


st1 = input()
st2 = input()
if len(st1) > len(st2):
	print(len(st1))
elif len(st2) > len(st1):
	print(len(st2))
elif st2 == st1:
	print(-1)
else:
	print(len(st2))


s = input()
w = input()
print('-1' if s == w else max(len(s), len(w)))


import sys
import math
get_string = lambda : sys.stdin.readline().strip()
get_int_list = lambda : list(map(int, sys.stdin.readline().strip().split()))
get_int = lambda : int(sys.stdin.readline())
s = get_string()
t = get_string()
if s == t:
	print(-1)
else:
	flag = False
	a = set(s)
	b = set(t)
	l = len(s)
	m = len(t)
	if l > m:
		for i in a:
			if i not in b:
				print(l)
				flag = True
				break
	else:
		for i in b:
			if i not in a:
				print(m)
				flag = True
				break
	if not flag:
		print(max(l, m))


p = input()
q = input()
if p == q:
	print(-1)
else:
	print(max(len(p), len(q)))


a = input()
b = input()
a1 = len(a)
b1 = len(b)
if a1 == b1:
	print('-1' if a == b else a1)
else:
	print(max(a1, b1))


import sys
import math
import bisect
import itertools
import random
import re

def main():
	s = input()
	t = input()
	if len(s) > len(t):
		print(len(s))
	elif len(s) < len(t):
		print(len(t))
	elif s == t:
		print(-1)
	else:
		print(len(s))
main()


w1 = input()
w2 = input()
if w1 == w2:
	print('-1')
else:
	print(max(len(w1), len(w2)))


s1 = input()
s2 = input()
i = 0
j = 0
c = 0
if len(s1) != len(s2) or s1 != s2:
	print(max(len(s1), len(s2)))
else:
	print(-1)


string1 = input()
string2 = input()
l1 = len(string1)
l2 = len(string2)
if l1 > l2:
	print(l1)
elif l2 > l1:
	print(l2)
elif l1 == l2:
	if string1 == string2:
		print(-1)
	else:
		print(l1)


(A, B) = (input(), input())
(la, lb) = (len(A), len(B))
if la != lb:
	print(max(la, lb))
elif A != B:
	print(la)
else:
	print(-1)


a = input()
b = input()
if a == b or b == a:
	print(-1)
elif a.__len__() > b.__len__():
	print(a.__len__())
else:
	print(b.__len__())


_str1 = input()
_str2 = input()
if _str1 == _str2:
	print('-1')
else:
	print(max([len(_str1), len(_str2)]))


v1 = []
v2 = []
x = input()
z = input()
if len(x) <= 10 ** 5 and len(z) <= 10 ** 5:
	for c1 in x:
		v1.append(c1)
	for c2 in z:
		v2.append(c2)
	if v1 == v2:
		print(-1)
	elif len(v1) > len(v2):
		print(len(v1))
	elif len(v1) < len(v2):
		print(len(v2))
	elif v1 > v2:
		print(len(v1))
	else:
		print(len(v2))


a = input().split()[0]
b = input().split()[0]
if a == b:
	print(-1)
else:
	print(max(len(a), len(b)))


from fractions import Fraction
import sys
import bisect
import heapq
from math import *
from collections import Counter as counter
from itertools import combinations as comb
from itertools import permutations as permutate
from bisect import bisect_left as bl
from bisect import bisect_right as br
from bisect import bisect
mod = 1000000007

def inp():
	return sys.stdin.readline().strip()

def out(var):
	sys.stdout.write(str(var))

def lis():
	return list(map(int, inp().split()))

def stringlis():
	return list(map(str, inp().split()))

def sep():
	return map(int, inp().split())

def strsep():
	return map(str, inp().split())

def graph(vertex):
	return [[] for i in range(0, vertex + 1)]

def zerolist(n):
	return [0] * n

def nextline():
	out('\n')

def testcase(t):
	for p in range(t):
		solve()

def printlist(a):
	for p in range(0, len(a)):
		out(str(a[p]) + ' ')

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

def power(a, b):
	ans = 1
	while b > 0:
		if b % 2 == 1:
			ans *= a
		a *= a
		b //= 2
	return ans

def createMatrix(rowCount, colCount, dataList):
	mat = []
	for i in range(rowCount):
		rowList = []
		for j in range(colCount):
			if dataList[j] not in mat:
				rowList.append(dataList[j])
		mat.append(rowList)
	return mat

def isprime(n):
	if n <= 1:
		return False
	if n <= 3:
		return True
	if n % 2 == 0 or n % 3 == 0:
		return False
	i = 5
	while i * i <= n:
		if n % i == 0 or n % (i + 2) == 0:
			return False
		i = i + 6
	return True
import collections

def minimalFilps1(bits):
	n = len(bits)
	flipsFromLeft = [0 for i in range(n)]
	flipsFromRight = [0 for i in range(n)]
	flips = 0
	for i in range(0, n, 1):
		if bits[i] == '1':
			flips = flips + 1
		flipsFromLeft[i] = flips
	flips = 0
	i = n - 1
	while i >= 0:
		if bits[i] == '0':
			flips = flips + 1
		i = i - 1
		flipsFromRight[i] = flips
	minFlips1 = sys.maxsize
	for i in range(1, n, 1):
		if flipsFromLeft[i - 1] + flipsFromRight[i] < minFlips1:
			minFlips1 = flipsFromLeft[i - 1] + flipsFromRight[i]
	return minFlips1

def minimalFilps(bits):
	n = len(bits)
	flipsFromLeft = [0 for i in range(n)]
	flipsFromRight = [0 for i in range(n)]
	flips = 0
	for i in range(0, n, 1):
		if bits[i] == '0':
			flips = flips + 1
		flipsFromLeft[i] = flips
	flips = 0
	i = n - 1
	while i >= 0:
		if bits[i] == '1':
			flips = flips + 1
		i = i - 1
		flipsFromRight[i] = flips
	minFlips = sys.maxsize
	for i in range(1, n, 1):
		if flipsFromLeft[i - 1] + flipsFromRight[i] < minFlips:
			minFlips = flipsFromLeft[i - 1] + flipsFromRight[i]
	return minFlips

def oddn(n):
	for i in range(2, n + 1):
		if i % 2 != 0 and n % i == 0:
			return i
	return 3
a = input()
b = input()
a = list(a)
b = list(b)
c = max(len(a), len(b))
d = 0
if a == b:
	d = -1
	print(d)
elif len(a) > len(b):
	print(len(a))
elif len(a) < len(b):
	print(len(b))
else:
	print(c)


def uncommon(a, b):
	if a == b:
		return -1
	return max(len(a), len(b))
a = input()
b = input()
print(uncommon(a, b))


str1 = input()
str2 = input()
len1 = len(str1)
len2 = len(str2)
if str1 == str2:
	print(-1)
else:
	print(max(len1, len2))


(a, b) = (input(), input())
(alen, blen, count) = (len(a), len(b), 0)
if alen == blen:
	for i in range(alen):
		for j in range(i, blen):
			if a[i] == b[j]:
				count += 1
				break
			else:
				break
	if count == alen:
		print('-1')
	else:
		print(alen)
else:
	print(max(alen, blen))


a = input()
b = input()
print(-1 if len(a) == len(b) and a in b else max(len(a), len(b)))


import math
import collections
import bisect
import heapq
import time
import random
import itertools
import sys
a = input()
b = input()
if a == b:
	print(-1)
elif len(a) > len(b):
	print(len(a))
else:
	print(len(b))


s = input()
d = input()
m = -1
if len(s) != len(d):
	m = max(len(s), len(d))
elif len(s) == len(d):
	for i in range(len(s)):
		if s[i] != d[i]:
			m = max(len(s), len(d))
print(m)


s = input()
d = input()
if s == d:
	print(-1)
else:
	print(max(len(s), len(d)))


a = list(input())
b = list(input())
if len(a) > len(b) and a != b:
	print(len(a))
if len(b) > len(a) and b != a:
	print(len(b))
if len(a) == len(b) and a != b:
	print(len(a))
if len(a) == len(b) and a == b:
	print(-1)


a = str(input())
b = str(input())
print(-1 if a == b else len(a) if len(b) < len(a) else len(b))


class CodeforcesTask766ASolution:

	def __init__(self):
		self.result = ''
		self.a = ''
		self.b = ''

	def read_input(self):
		self.a = input()
		self.b = input()

	def process_task(self):
		if self.a == self.b:
			self.result = '-1'
		else:
			self.result = str(max(len(self.a), len(self.b)))

	def get_result(self):
		return self.result
Solution = CodeforcesTask766ASolution()
Solution.read_input()
Solution.process_task()
print(Solution.get_result())


import sys
from math import sqrt
input = lambda : sys.stdin.readline()

def Main():
	a = input()
	b = input()
	if a == b:
		print(-1)
	else:
		print(max(len(a) - 1, len(b) - 1))
Main()


def uncommon():
	a = input()
	b = input()
	if a == b:
		print(-1)
	else:
		print(max(len(a), len(b)))
uncommon()


import itertools
import sys
s1 = input()
s2 = input()
if s1 == s2:
	print('-1')
else:
	print(max(len(s1), len(s2)))


first_string = input()
second_string = input()
if first_string == second_string:
	print(-1)
else:
	print(max(len(first_string), len(second_string)))


s = input()
s1 = input()
a = list(s)
b = list(s1)
if a == b:
	print(-1)
elif len(a) > len(b):
	print(len(a))
else:
	print(len(b))


s1 = input()
s2 = input()
n1 = int(len(s1))
n2 = int(len(s2))
if s1 == s2:
	print('-1')
else:
	x = n1 if n1 > n2 else n2
	print(x)


st1 = input()
st2 = input()
if st2 == st1:
	print(-1)
else:
	print(max(len(st1), len(st2)))


s_1 = input()
s_2 = input()
longest_seq = s_1 if len(s_1) > len(s_2) else s_2
shortest_seq = s_2 if len(s_1) > len(s_2) else s_1
first_c = shortest_seq[0]
if longest_seq == shortest_seq:
	print(-1)
elif first_c not in longest_seq:
	print(len(longest_seq))
else:
	j = 0
	word = ''
	for l in longest_seq:
		if l == shortest_seq[j]:
			word += l
			j += 1 if j < len(shortest_seq) - 1 else 0
	print(len(longest_seq))


def LUCS(a, b):
	if len(a) > len(b):
		if a in b:
			print(-1)
		else:
			print(len(a))
	elif b in a:
		print(-1)
	else:
		print(len(b))
a = str(input())
b = str(input())
LUCS(a, b)


s = input()
t = input()
if s == t:
	print(-1)
	exit(0)
print(max(len(s), len(t)))


def Seq():
	s1 = input()
	s2 = input()
	(l1, l2) = (len(s1), len(s2))
	if s1 == s2:
		return -1
	else:
		return max(l1, l2)
print(Seq())


l = input()
m = input()
if l == m:
	print(-1)
else:
	print(max(len(m), len(l)))


l1 = input()
l2 = input()
if len(l2) > len(l1):
	print(len(l2))
if len(l2) < len(l1):
	print(len(l1))
if len(l2) == len(l1):
	count = 0
	if l1 == l2:
		print('-1')
	else:
		print(len(l1))


first = input()
second = input()
m = ''
counter = 0

def compute(a, b):
	m = a[:]
	counter = len(m)
	if a == b:
		return -1
	for i in range(0, len(m)):
		if m not in b:
			return counter
		else:
			counter -= 1
			m = m[i:]
	return counter
print(max(compute(first, second), compute(second, first)))


import sys
from math import ceil, log, gcd, sqrt
RI = lambda : [int(x) for x in sys.stdin.readline().split()]
ri = lambda : sys.stdin.readline().strip()

def input():
	return sys.stdin.readline().strip()

def list2d(a, b, c):
	return [[c] * b for i in range(a)]

def list3d(a, b, c, d):
	return [[[d] * c for j in range(b)] for i in range(a)]

def list4d(a, b, c, d, e):
	return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]

def ceil(x, y=1):
	return int(-(-x // y))

def INT():
	return int(input())

def MAP():
	return map(int, input().split())

def LIST(N=None):
	return list(MAP()) if N is None else [INT() for i in range(N)]

def Yes():
	print('Yes')

def No():
	print('No')

def YES():
	print('Yes')

def NO():
	print('No')
INF = 10 ** 18
MOD = 10 ** 9 + 7
s = ri()
t = ri()
if s == t:
	print(-1)
else:
	print(max(len(s), len(t)))