Santa Claus decided to disassemble his keyboard to clean it. After he returned all the keys back, he suddenly realized that some pairs of keys took each other's place! That is, Santa suspects that each key is either on its place, or on the place of another key, which is located exactly where the first key should be. 

In order to make sure that he's right and restore the correct order of keys, Santa typed his favorite patter looking only to his keyboard.

You are given the Santa's favorite patter and the string he actually typed. Determine which pairs of keys could be mixed. Each key must occur in pairs at most once.


-----Input-----

The input consists of only two strings s and t denoting the favorite Santa's patter and the resulting string. s and t are not empty and have the same length, which is at most 1000. Both strings consist only of lowercase English letters.


-----Output-----

If Santa is wrong, and there is no way to divide some of keys into pairs and swap keys in each pair so that the keyboard will be fixed, print «-1» (without quotes).

Otherwise, the first line of output should contain the only integer k (k ≥ 0) — the number of pairs of keys that should be swapped. The following k lines should contain two space-separated letters each, denoting the keys which should be swapped. All printed letters must be distinct.

If there are several possible answers, print any of them. You are free to choose the order of the pairs and the order of keys in a pair.

Each letter must occur at most once. Santa considers the keyboard to be fixed if he can print his favorite patter without mistakes.


-----Examples-----
Input
helloworld
ehoolwlroz

Output
3
h e
l o
d z

Input
hastalavistababy
hastalavistababy

Output
0

Input
merrychristmas
christmasmerry

Output
-1

Difficulty: MEDIUM

Solutions:
s1 = input()
s2 = input()
d = {}
for i in range(len(s1)):
	if d.get(s1[i], -1) == -1:
		if d.get(s2[i], -1) == -1:
			d[s1[i]] = s2[i]
			d[s2[i]] = s1[i]
		else:
			print(-1)
			exit()
	elif d[s1[i]] != s2[i] or d.get(s2[i], -1) != s1[i]:
		print(-1)
		exit()
ss = set()
ans = []
for x in d:
	if d[x] != x and x not in ss:
		ans.append(x + ' ' + d[x])
		ss.add(x)
		ss.add(d[x])
print(len(ans))
for x in ans:
	print(x)


s1 = input()
s2 = input()
ans = 0
d = {}
for i in range(len(s1)):
	(t, k) = (s1[i], s2[i])
	if t not in d.keys() and k not in d.keys():
		d[t] = k
		d[k] = t
		if k != t:
			ans += 1
	elif t in d.keys() and k in d.keys() and (d[k] == t) and (d[t] == k):
		continue
	else:
		ans = -1
		break
if ans > 0:
	print(ans)
	keys = []
	for (key, val) in d.items():
		if key != val and val not in keys:
			print('{} {}'.format(key, val))
			keys.append(key)
else:
	print(ans)


from copy import copy

def change(a, b, t):
	v = []
	for l in t:
		if l == a:
			v.append(b)
		elif l == b:
			v.append(a)
		else:
			v.append(l)
	return v
s = list(map(str, input()))
t = list(map(str, input()))
d = []
trash = []
for i in range(len(s)):
	if s[i] != t[i] and s[i] not in trash and (t[i] not in trash):
		d.append([s[i], t[i]])
		trash.append(s[i])
		trash.append(t[i])
		t = change(s[i], t[i], t)
if s != t:
	print(-1)
else:
	print(len(d))
	for x in d:
		print(x[0], x[1], sep=' ')


a = input()
b = input()
c = []
d = []
if a == b:
	print('0')
else:
	l = len(a)
	a = list(a)
	b = list(b)
	i = 0
	flag = 0
	while i < len(a):
		if a[i] == b[i]:
			p = a[i]
			q = b[i]
			j = 0
			while j < len(a):
				if a[j] == q or a[j] == p:
					a[j] = 0
				if b[j] == p or b[j] == q:
					b[j] = 0
				j += 1
			j = 0
			while j < len(a):
				if a[j] == 0 and b[j] != 0:
					flag = 1
					break
				elif a[j] != 0 and b[j] == 0:
					flag = 1
					break
				j += 1
		elif a[i] != b[i]:
			p = a[i]
			q = b[i]
			j = 0
			while j < len(a):
				if a[j] == p and b[j] == p:
					flag = 1
					break
				if a[j] == q and b[j] == q:
					flag = 1
					break
				if a[j] == q or a[j] == p:
					a[j] = 0
				if b[j] == p or b[j] == q:
					b[j] = 0
				j += 1
			if flag == 1:
				break
			j = 0
			while j < len(a):
				if a[j] == 0 and b[j] != 0:
					flag = 1
					break
				elif a[j] != 0 and b[j] == 0:
					flag = 1
					break
				j += 1
			if flag == 1:
				break
			else:
				c.append(p)
				d.append(q)
		i += 1
	if flag == 1:
		print('-1')
	else:
		print(len(c))
		for i in range(0, len(c)):
			print(c[i], d[i])


from collections import defaultdict
s = input()
p = input()
d = defaultdict(list)
b = defaultdict(list)
t = {}
for i in range(len(s)):
	d[s[i]].append(p[i])
	b[p[i]].append(s[i])
r = 'YES'
for c in d:
	if len(set(d[c])) != 1:
		r = 'NO'
		break
	elif d[c][0] != c:
		t[c] = d[c][0]
for c in b:
	if len(set(b[c])) != 1:
		r = 'NO'
		break
a = []
m = set()
l = 0
if r == 'YES':
	for c in t:
		if t[c] in t:
			if t[t[c]] != c:
				r = 'NO'
				break
		if c not in m:
			l += 1
			a.append([c, t[c]])
			m.add(c)
			m.add(t[c][0])
if r == 'NO':
	print(-1)
else:
	print(l)
	for i in range(len(a)):
		print(a[i][0], a[i][1])


s = input()
s1 = input()
d = {}
s2 = set()
gg = 0
for i in range(len(s)):
	if s[i] == s1[i]:
		if s[i] in d and d[s[i]] != s[i]:
			print(-1)
			exit(0)
		if s[i] in s2:
			continue
		gg += 1
		s2.add(s[i])
		d[s[i]] = s[i]
		continue
	if s[i] in d and d[s[i]] != s1[i] or (s1[i] in d and d[s1[i]] != s[i]):
		print(-1)
		exit(0)
	d[s[i]] = s1[i]
	d[s1[i]] = s[i]
print((len(d) - gg) // 2)
for i in d:
	if i in s2:
		continue
	print(i, d[i])
	s2.add(i)
	s2.add(d[i])


a = input()
b = input()
alph = [0] * 26
for i in range(26):
	alph[i] = chr(97 + i)
ans = []
for i in range(len(a)):
	if a[i] != alph[ord(b[i]) - 97]:
		if alph[ord(a[i]) - 97] == a[i] and alph[ord(b[i]) - 97] == b[i]:
			alph[ord(a[i]) - 97] = b[i]
			alph[ord(b[i]) - 97] = a[i]
			ans.append((a[i], b[i]))
		else:
			print(-1)
			return
for i in range(len(b)):
	if a[i] != alph[ord(b[i]) - 97]:
		print(-1)
		return
print(len(ans))
for i in range(len(ans)):
	print(ans[i][0], ans[i][1])


def solution(str1, str2):
	chars = {}
	revChars = {}
	for idx in range(0, len(str1)):
		if str1[idx] != str2[idx]:
			if str1[idx] not in chars and str2[idx] not in revChars and (str2[idx] not in chars) and (str1[idx] not in revChars):
				chars[str1[idx]] = str2[idx]
				revChars[str2[idx]] = str1[idx]
			elif str1[idx] in chars:
				if chars[str1[idx]] != str2[idx]:
					print('-1')
					return
			elif str1[idx] in revChars:
				if revChars[str1[idx]] != str2[idx]:
					print('-1')
					return
			else:
				print('-1')
				return
		elif str1[idx] in chars:
			if chars[str1[idx]] != str2[idx]:
				print('-1')
				return
		elif str1[idx] in revChars:
			if revChars[str1[idx]] != str2[idx]:
				print('-1')
				return
		else:
			chars[str1[idx]] = str2[idx]
			revChars[str1[idx]] = str2[idx]
	answers = {}
	for (key, val) in chars.items():
		if key != val:
			answers[key] = val
	print('{}'.format(len(answers)))
	for (key, val) in answers.items():
		print('{} {}'.format(key, val))
	return
str1 = input()
str2 = input()
solution(str1, str2)


a = input()
b = input()
ans = {}
t = True
for i in range(len(a)):
	if a[i] in ans.keys():
		if ans[a[i]] != b[i]:
			t = False
	if b[i] in ans.keys():
		if ans[b[i]] != a[i]:
			t = False
	else:
		ans[a[i]] = b[i]
		ans[b[i]] = a[i]
if t:
	an = []
	for i in ans.keys():
		if i != ans[i] and i not in an and (ans[i] not in an):
			an.append(i)
			an.append(ans[i])
	print(len(an) // 2)
	for i in range(0, len(an) - 1, 2):
		print(an[i], an[i + 1])
else:
	print(-1)


import sys
line1 = list(input())
line2 = list(input())
d = dict()
for i in range(len(line1)):
	s1 = line1[i]
	s2 = line2[i]
	if s1 in d.keys():
		if s2 != d[s1]:
			print(-1)
			sys.exit()
	elif s2 in d.keys():
		if s1 != d[s2]:
			print(-1)
			sys.exit()
	else:
		d[s1] = s2
		d[s2] = s1
if len(set(d.keys())) != len(set(d.values())):
	print(-1)
else:
	l = set()
	ans = []
	for i in d.keys():
		if i not in l and d[i] not in l and (d[i] != i):
			ans.append([i, d[i]])
			l.add(i)
			l.add(d[i])
	print(len(ans))
	for i in ans:
		print(i[0], i[1])


s = input()
t = input()
(fin, used, ln) = ([[]], [], 0)
for i in range(len(s)):
	if not (s[i] in used or t[i] in used) and fin.count([s[i], t[i]]) + fin.count([t[i], s[i]]) == 0:
		used += [s[i], t[i]]
		fin += [[s[i], t[i]]]
		if s[i] != t[i]:
			ln += 1
	elif (s[i] in used or t[i] in used) and fin.count([s[i], t[i]]) + fin.count([t[i], s[i]]) == 0:
		print(-1)
		break
else:
	if ln == 0:
		print(0)
	else:
		print(ln)
		for i in range(1, len(fin)):
			if fin[i][0] != fin[i][1]:
				print(fin[i][0], fin[i][1])


a = input()
b = input()
c = []
d = []
e = []
for i in range(len(a)):
	if a[i] != b[i] and (not [a[i], b[i]] in c) and (not [b[i], a[i]] in c):
		if a[i] in d or b[i] in d or b[i] in e or (a[i] in e):
			print(-1)
			c = 1
			break
		c.append([a[i], b[i]])
		if not a[i] in d:
			d.append(a[i])
			d.append(b[i])
	elif a[i] == b[i] and a[i] in d:
		print(-1)
		c = 1
		break
	elif a[i] == b[i] and (not a[i] in e):
		e.append(a[i])
if c != 1:
	print(len(c))
	for i in range(len(c)):
		print(c[i][0], c[i][1])


def main():
	a = input()
	b = input()
	keyboard = dict()
	for i in range(ord('a'), ord('z') + 1):
		keyboard[chr(i)] = ' '
	index = 1
	size = 0
	out = ''
	size = 0
	for i in range(len(a)):
		if a[i] != b[i]:
			if keyboard[a[i]] == ' ' and keyboard[b[i]] == ' ':
				keyboard[a[i]] = b[i]
				keyboard[b[i]] = a[i]
				size += 1
				out += a[i] + ' ' + b[i] + '\n'
			elif not (keyboard[a[i]] == b[i] and keyboard[b[i]] == a[i]):
				print(-1)
				return 0
		elif keyboard[a[i]] == ' ':
			keyboard[a[i]] = a[i]
		elif keyboard[a[i]] != a[i]:
			print(-1)
			return 0
	print(size)
	if size > 0:
		print(out)
main()


import sys
s = input()
t = input()
st1 = []
st2 = []
checked = []
right = []
for i in range(len(s)):
	if s[i] in checked and t[i] not in checked:
		print('-1')
		sys.exit()
	if s[i] not in checked and t[i] in checked:
		print('-1')
		sys.exit()
	if s[i] in right and t[i] not in right:
		print('-1')
		sys.exit()
	if s[i] not in right and t[i] in right:
		print('-1')
		sys.exit()
	if s[i] not in st1 and s[i] not in st2:
		if t[i] not in st1 and t[i] not in st2:
			if s[i] != t[i]:
				checked.append(s[i])
				checked.append(t[i])
				st1.append(s[i])
				st2.append(t[i])
			else:
				right.append(s[i])
				right.append(t[i])
	if s[i] == t[i]:
		if s[i] in st1 or s[i] in st2:
			print('-1')
			sys.exit()
		elif t[i] in st1 or t[i] in st2:
			print('-1')
			sys.exit()
	if s[i] in st2:
		if st1[st2.index(s[i])] != t[i]:
			print('-1')
			sys.exit()
	if s[i] in right or t[i] in right:
		if s[i] != t[i]:
			print('-1')
			sys.exit()
print(len(st1))
for i in range(len(st1)):
	print(st1[i], end=' ')
	print(st2[i])


class CodeforcesTask748BSolution:

	def __init__(self):
		self.result = ''
		self.pattern = ''
		self.real = ''

	def read_input(self):
		self.pattern = input()
		self.real = input()

	def process_task(self):
		if self.pattern == self.real:
			self.result = '0'
		else:
			mapping = {}
			remapping = {}
			wrong = False
			for x in range(len(self.pattern)):
				if self.pattern[x] in mapping:
					if mapping[self.pattern[x]] != self.real[x]:
						wrong = True
						break
				elif self.real[x] not in mapping:
					mapping[self.pattern[x]] = self.real[x]
					if self.real[x] not in remapping:
						remapping[self.real[x]] = self.pattern[x]
					elif remapping[self.real[x]] != self.pattern[x]:
						wrong = True
						break
				elif mapping[self.real[x]] != self.pattern[x]:
					wrong = True
					break
			if not wrong:
				self.result = '{0}\n{1}'.format(len(['{0} {1}'.format(key, value) for (key, value) in mapping.items() if key != value]), '\n'.join(['{0} {1}'.format(key, value) for (key, value) in mapping.items() if key != value]))
			else:
				self.result = '-1'

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


import os
import sys
from io import BytesIO, IOBase

def main():
	s = list(input())
	t = list(input())
	d = dict()
	visited = set()
	for i in range(len(s)):
		if s[i] == t[i] and s[i] not in d:
			visited.add(s[i])
			continue
		elif s[i] == t[i]:
			print(-1)
			exit()
		elif s[i] in d and t[i] in d and (d[s[i]] == t[i]) and (d[t[i]] == s[i]):
			continue
		elif s[i] not in d and t[i] not in d and (s[i] not in visited) and (t[i] not in visited):
			d[s[i]] = t[i]
			d[t[i]] = s[i]
			visited.add(s[i])
			visited.add(t[i])
		else:
			print(-1)
			exit()
	print(len(d.values()) // 2)
	visited.clear()
	for i in d:
		if i in visited:
			continue
		visited.add(i)
		print(i, d[i])
		visited.add(d[i])

def nouse0():
	a = 420
	b = 420
	print(f'i am nitish{(a + b) // 2}')

def nouse1():
	a = 420
	b = 420
	print(f'i am nitish{(a + b) // 2}')

def nouse2():
	a = 420
	b = 420
	print(f'i am nitish{(a + b) // 2}')
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))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def nouse3():
	a = 420
	b = 420
	print(f'i am nitish{(a + b) // 2}')

def nouse4():
	a = 420
	b = 420
	print(f'i am nitish{(a + b) // 2}')

def nouse5():
	a = 420
	b = 420
	print(f'i am nitish{(a + b) // 2}')
main()


import sys
string1 = input()
string2 = input()
st1 = []
st2 = []
checked = []
right = []
for i in range(len(string1)):
	a = []
	if string1[i] in checked and string2[i] not in checked:
		print('-1')
		sys.exit()
	if string1[i] not in checked and string2[i] in checked:
		print('-1')
		sys.exit()
	if string1[i] in right and string2[i] not in right:
		print('-1')
		sys.exit()
	if string1[i] not in right and string2[i] in right:
		print('-1')
		sys.exit()
	if string1[i] not in st1 and string1[i] not in st2:
		if string2[i] not in st1 and string2[i] not in st2:
			if string1[i] != string2[i]:
				checked.append(string1[i])
				checked.append(string2[i])
				st1.append(string1[i])
				st2.append(string2[i])
			else:
				right.append(string1[i])
				right.append(string2[i])
	if string1[i] == string2[i]:
		if string1[i] in st1 or string1[i] in st2:
			print('-1')
			sys.exit()
		elif string2[i] in st1 or string2[i] in st2:
			print('-1')
			sys.exit()
	if string1[i] in st2:
		if st1[st2.index(string1[i])] != string2[i]:
			print('-1')
			sys.exit()
	if string1[i] in right or string2[i] in right:
		if string1[i] != string2[i]:
			print('-1')
			sys.exit()
print(len(st1))
for i in range(len(st1)):
	print(st1[i], end=' ')
	print(st2[i])


import sys
s = input()
t = input()
d = {}
for i in range(len(s)):
	if s[i] not in d and t[i] not in d:
		d[s[i]] = t[i]
		d[t[i]] = s[i]
	elif s[i] in d and d[s[i]] != t[i] or (t[i] in d and d[t[i]] != s[i]):
		print(-1)
		sys.exit()
res = {}
for i in d:
	if i != d[i] and i not in res and (d[i] not in res):
		res[i] = d[i]
print(len(res))
for i in res:
	print(i, res[i])


def main():
	n = input()
	m = input()
	o = []
	a = [-1 for x in range(26)]
	ca = ord('a')
	for i in range(len(n)):
		if n[i] == m[i]:
			if a[ord(n[i]) - ca] == -1 or a[ord(n[i]) - ca] == ord(n[i]) - ca:
				a[ord(n[i]) - ca] = ord(n[i]) - ca
			else:
				print(-1)
				return
		elif a[ord(n[i]) - ca] == -1:
			o += [[n[i], m[i]]]
			a[ord(n[i]) - ca] = ord(m[i]) - ca
			if a[ord(m[i]) - ca] == -1:
				a[ord(m[i]) - ca] = ord(n[i]) - ca
			else:
				print(-1)
				return
		elif a[ord(n[i]) - ca] == ord(m[i]) - ca:
			if a[ord(m[i]) - ca] == ord(n[i]) - ca:
				pass
			else:
				print(-1)
				return
		else:
			print(-1)
			return
	print(len(o))
	for i in o:
		print(*i)
main()


s = input()
t = input()
n = len(s)
sz = {}
ans = 0
tans = []
for i in range(n):
	try:
		if sz[s[i]] != t[i]:
			ans = -1
			break
	except KeyError:
		sz[s[i]] = t[i]
	try:
		if sz[t[i]] != s[i]:
			ans = -1
			break
	except KeyError:
		sz[t[i]] = s[i]
if ans == -1:
	print(ans)
else:
	for el in list(sz.items()):
		if el[0] != el[1]:
			if el[0] not in tans:
				tans.append(el[0])
				tans.append(el[1])
	ans = len(tans) // 2
	print(ans)
	for i in range(0, len(tans), 2):
		print(tans[i], tans[i + 1])


s = input('')
t = input('')
li1 = []
li2 = []
out = 0
mis = []
mis2 = []
kis = []
n = 0
for i in range(0, len(s)):
	li1.append(s[n])
	n += 1
n = 0
for i in range(0, len(t)):
	li2.append(t[n])
	n += 1
n = 0
for i in range(0, len(t)):
	if li2[n] == li1[n]:
		if li1[n] in mis or li2[n] in mis:
			print('-1')
			quit()
		else:
			kis.append(li1[n])
			kis.append(li2[n])
			n += 1
	elif li1[n] in mis or li2[n] in mis:
		if li1[n] in mis and li2[n] in mis:
			mis21 = li1[n] + li2[n]
			if mis21 in mis2 or mis21[::-1] in mis2:
				n += 1
			else:
				print('-1')
				quit()
		else:
			print('-1')
			quit()
	elif li1[n] in kis or li2[n] in kis:
		print('-1')
		quit()
	else:
		mis.append(li1[n])
		mis.append(li2[n])
		mis21 = li1[n] + li2[n]
		mis2.append(mis21)
		out += 1
		n += 1
n = 2
d = len(mis)
d = d / 2 - 1
for i in range(0, int(d)):
	mis.insert(n, '\n')
	n += 3
n = 1
d = len(mis)
for i in range(0, int(d)):
	mis.insert(n, ' ')
	n += 4
mis = ''.join(mis)
print(out)
print(mis)


s = input()
t = input()
d1 = {}
d2 = {}
for i in range(len(s)):
	if s[i] not in d1 and s[i] not in d2:
		if t[i] in d1 or t[i] in d2:
			print(-1)
			break
		d1.update({s[i]: t[i]})
		d2.update({t[i]: s[i]})
	elif s[i] in d1:
		if d1[s[i]] != t[i]:
			print(-1)
			break
	elif d2[s[i]] != t[i]:
		print(-1)
		break
else:
	counter = 0
	for i in d1.keys():
		if d1[i] != i:
			counter += 1
	print(counter)
	for i in d1.keys():
		if d1[i] != i:
			print('{} {}'.format(i, d1[i]))


q = input()
w = input()
l = len(q)
a = []
s = [0 for i in range(0, 130)]
t = []
for i in range(0, l):
	if q[i] == w[i]:
		t.append(q[i])
for i in range(0, l):
	if q[i] != w[i]:
		a.append([q[i], w[i]])
		s[ord(q[i])] += 1
		s[ord(w[i])] += 1
		c = q[i]
		if (q[i] in t) | (w[i] in t):
			s[0] = 10
		q = q.replace(q[i], w[i])
		w = w.replace(c, w[i])
if max(s) > 1:
	print(-1)
else:
	print(len(a))
	for i in a:
		print(i[0], i[1])


first = input()
second = input()
diff = {}
if first == second:
	print(0)
	exit()
i = 0
while i < len(first):
	if first[i] != second[i] and second[i] not in diff.keys() and (second[i] not in diff.values()) and (first[i] not in diff.keys()) and (first[i] not in diff.values()):
		diff[first[i]] = second[i]
	i += 1
for key in diff.keys():
	second = second.replace(key, '$').replace(diff[key], key).replace('$', diff[key])
if first == second:
	print(len(diff.keys()))
	for key in diff.keys():
		print('{} {}'.format(key, diff[key]))
else:
	print(-1)


def areBidirectionalDictionaries(s1, s2):
	d = {}
	other = {}
	perfect = set()
	for (i, j) in zip(s1, s2):
		if i != j:
			if i in d and d[i] != j or (j in d and d[j] != i) or i in perfect or (j in perfect):
				print('-1')
				return
			if j not in d:
				d[i] = j
				other[j] = i
		elif i in d or i in other:
			print('-1')
			return
		else:
			perfect.add(i)
	if len(d) != len(set(d.values())):
		print('-1')
		return
	print(len(d))
	for (i, j) in d.items():
		print(str(i) + ' ' + str(j))
s1 = input()
s2 = input()
areBidirectionalDictionaries(s1, s2)


s = input()
s1 = input()
mistake = False
d = dict()
ans = []
for i in range(len(s)):
	if s[i] != s1[i]:
		if s[i] in d and s1[i] in d:
			if not (d[s[i]] == s1[i] and d[s1[i]] == s[i]):
				mistake = True
				break
		elif s[i] in d or s1[i] in d:
			mistake = True
			break
		else:
			d[s[i]] = s1[i]
			d[s1[i]] = s[i]
	else:
		if s[i] in d and d[s[i]] != s[i]:
			mistake = True
			break
		d[s[i]] = s[i]
if mistake:
	print(-1)
else:
	ans = []
	last = set()
	for elem in d:
		if elem not in last and elem != d[elem]:
			ans.append([elem, d[elem]])
		last.add(elem)
		last.add(d[elem])
	print(len(ans))
	for elem in ans:
		print(*elem)


word1 = input()
word2 = input()
pool = {}
matched = set()
nonmatched = set()
for (l1, l2) in zip(word1, word2):
	if l1 != l2:
		nonmatched.add(l1)
		nonmatched.add(l2)
		if l1 in pool and pool[l1] != l2:
			print(-1)
			exit()
		if l2 in pool and pool[l2] != l1:
			print(-1)
			exit()
		if l1 not in pool and l2 not in pool:
			pool[l1] = l2
		if l2 not in pool:
			pool[l2] = l1
		if l1 in matched or l2 in matched:
			print(-1)
			exit()
	else:
		matched.add(l1)
		if l1 in nonmatched or l2 in nonmatched:
			print(-1)
			exit()
if not pool:
	print(0)
else:
	print(len(pool) // 2)
	vals = []
	for (key, val) in pool.items():
		if key not in vals:
			print(key, val)
			vals.append(val)


s1 = input()
s2 = input()
n = len(s1)
d = dict()
possible = 1
count = 0
for i in range(n):
	if s1[i] in d:
		if s2[i] != d[s1[i]]:
			possible = 0
	elif s2[i] in d:
		possible = 0
	else:
		d[s1[i]] = s2[i]
		d[s2[i]] = s1[i]
		if s1[i] != s2[i]:
			count += 1
arr = []
if possible == 1:
	print(count)
	for k in d:
		if not k in arr and k != d[k]:
			print(k + ' ' + d[k])
			arr.append(d[k])
else:
	print(-1)


S1 = input()
S2 = input()
s1 = []
s2 = []
c = 0
for i in range(len(S1)):
	k = 0
	if S1[i] != S2[i]:
		for j in range(len(s1)):
			if S1[i] == s1[j] and s2[j] == S2[i] or (S1[i] == s2[j] and s1[j] == S2[i]):
				k = 1
				break
			elif S1[i] == s1[j] and s2[j] != S2[i] or (S1[i] == s2[j] and s1[j] != S2[i]) or (S1[i] != s2[j] and S2[i] == s1[j]) or (S1[i] != s1[j] and S2[i] == s2[j]):
				k = 2
				break
	else:
		for j in range(len(s1)):
			if S1[i] == s1[j] and s2[j] != S2[i] or (S1[i] == s2[j] and s1[j] != S2[i]) or (S1[i] != s2[j] and S2[i] == s1[j]) or (S1[i] != s1[j] and S2[i] == s2[j]):
				k = 2
				break
	if k == 2:
		c = 1
		break
	if k == 0:
		s1.append(S1[i])
		s2.append(S2[i])
if c == 1:
	print(-1)
else:
	k = 0
	for i in range(len(s1)):
		if s1[i] != s2[i]:
			k = k + 1
	print(k)
	for i in range(len(s1)):
		if s1[i] != s2[i]:
			print(s1[i], s2[i])


s1 = input()
s2 = input()
a = [[0] * 2 for i in range(29)]
used = [-1] * 29
good = 1
c = 0
for i in range(len(s2)):
	if good == 0:
		break
	if s2[i] != s1[i]:
		if used[ord(s2[i]) - ord('a')] == -1 and used[ord(s1[i]) - ord('a')] == -1:
			used[ord(s2[i]) - ord('a')] = ord(s1[i]) - ord('a')
			used[ord(s1[i]) - ord('a')] = ord(s2[i]) - ord('a')
			a[c][0] = s1[i]
			a[c][1] = s2[i]
			c += 1
		elif used[ord(s2[i]) - ord('a')] != ord(s1[i]) - ord('a'):
			good = 0
	elif used[ord(s2[i]) - ord('a')] == -1:
		used[ord(s2[i]) - ord('a')] = ord(s1[i]) - ord('a')
	elif used[ord(s2[i]) - ord('a')] != ord(s1[i]) - ord('a'):
		good = 0
if good == 0:
	print(-1)
else:
	print(c)
	for i in range(c):
		print(a[i][0], a[i][1])


s1 = input()
s2 = input()
dic = {}
dic2 = {}
for i in range(0, len(s1)):
	if s1[i] != s2[i]:
		if (s1[i], s2[i]) not in dic and (s2[i], s1[i]) not in dic:
			dic[s1[i], s2[i]] = 1
	else:
		dic2[s1[i]] = 1
for i in dic:
	if i[0] in dic2 or i[1] in dic2:
		print(-1)
		exit()
	else:
		dic2[i[0]] = 1
		dic2[i[1]] = -1
print(len(dic))
for i in dic:
	print('%s %s' % (i[0], i[1]))


a = input()
b = input()
n = len(a)
ans = []
match = {}
flag = 0
for i in range(n):
	if a[i] in match:
		if match[a[i]] != b[i]:
			flag = 1
			break
	if b[i] in match:
		if match[b[i]] != a[i]:
			flag = 1
			break
	if a[i] != b[i] and a[i] not in match:
		ans.append(a[i] + ' ' + b[i])
	match[a[i]] = b[i]
	match[b[i]] = a[i]
if flag == 1:
	print(-1)
else:
	print(len(ans))
	for x in ans:
		print(x)


word1 = [str(i) for i in input()]
word2 = [str(i) for i in input()]
backup = word1
backup2 = word2
already = []
final_list = []
bool = True
for x in range(len(word1)):
	if word1 == word2:
		print(0)
		bool = False
		break
	if word1[x] in already:
		continue
	elif word1[x] == word2[x]:
		already.append(word1[x])
	else:
		baseline = word1[x]
		baseline2 = word2[x]
		increment = 0
		for letter in word1:
			if letter == baseline and word2[word1.index(letter)] == baseline2:
				increment += 1
		if increment == word1.count(baseline) and increment == word2.count(baseline2):
			final_list.append([baseline, baseline2])
			already.append(baseline)
			already.append(baseline2)
for y in range(len(final_list)):
	swapping_letters = final_list[y]
	for x in range(len(word1)):
		if backup2[x] == swapping_letters[0]:
			backup2.pop(x)
			backup2.insert(x, swapping_letters[1])
		elif backup2[x] == swapping_letters[1]:
			backup2.pop(x)
			backup2.insert(x, swapping_letters[0])
if bool == True:
	if len(final_list) == 0 or backup2 != backup:
		print(-1)
	else:
		print(len(final_list))
		for item in final_list:
			print(' '.join(item))


def getindex(ch):
	return ord(ch) - ord('a')
s = input()
t = input()
ch = [chr(ord('a') + i) for i in range(26)]
appear = [0 for i in range(26)]
ok = 1
total = -1
res = []
for i in range(len(s)):
	nows = ch[getindex(s[i])]
	if nows != t[i]:
		total += 1
		res.append((s[i], t[i]))
		(ch[getindex(s[i])], ch[getindex(t[i])]) = (t[i], s[i])
		if appear[getindex(s[i])] or appear[getindex(t[i])]:
			ok = 0
			print(-1)
			break
		appear[getindex(s[i])] = appear[getindex(t[i])] = 1
if ok:
	for i in range(len(s)):
		nows = ch[getindex(s[i])]
		if nows != t[i]:
			ok = 0
			break
	if ok:
		print(total + 1)
		for i in range(total + 1):
			print(res[i][0], res[i][1])
	else:
		print(-1)


s = input()
t = input()
d = {}
l = []
ans = 0
for i in range(len(s)):
	if s[i] != t[i] and s[i] not in d and (t[i] not in d) and (s[i] not in l) and (t[i] not in l):
		d[s[i]] = t[i]
		d[t[i]] = s[i]
		ans += 1
	elif s[i] != t[i]:
		if t[i] in d and s[i] != d[t[i]] or (s[i] in d and d[s[i]] != t[i]) or s[i] in l or (t[i] in l):
			ans = -1
			break
	if s[i] == t[i]:
		if s[i] in d:
			ans = -1
			break
		l.append(s[i])
print(ans)
if ans != -1:
	a = []
	for elems in d:
		if d[elems] not in a:
			print(elems, d[elems])
			a.append(elems)


s1 = input()
s2 = input()
n = len(s1)
changes = {}
changesprinted = {}
t = {}
for i in range(n):
	if s1[i] != s2[i]:
		changes[s1[i]] = s2[i]
		if s1[i] not in changes.values():
			changesprinted[s1[i]] = s2[i]
	if not t.get(s2[i]):
		t[s2[i]] = set()
	t[s2[i]].add(s1[i])
b = []
for i in t:
	for k in t[i]:
		b.append(k)
if len(set(b)) < len(b) or len(set(t.keys())) < len(t.keys()):
	print(-1)
	exit()
for i in t:
	if len(t[i]) > 1:
		print(-1)
		exit()
s1_proper = ''
for i in range(n):
	if s1[i] == s2[i]:
		s1_proper += s1[i]
		continue
	for j in changes:
		if j == s2[i]:
			s1_proper += changes[j]
			break
		elif changes[j] == s2[i]:
			s1_proper += j
			break
if s1_proper != s1:
	print(-1)
else:
	print(len(changesprinted))
	for i in changesprinted:
		print(i, changesprinted[i])


before = input()
after = input()
length = len(before)
stock = {}
answer = []
for l in range(length):
	if before[l] != after[l] and stock.get(after[l], 0) == 0 and (stock.get(before[l], 0) == 0):
		answer.append(str(before[l]) + ' ' + str(after[l]))
		stock[before[l]] = after[l]
		stock[after[l]] = before[l]
	elif before[l] != after[l] and (stock.get(after[l], 0) == -1 or stock.get(before[l], 0) == -1):
		print(-1)
		break
	elif before[l] != after[l]:
		if stock.get(before[l], 0) != after[l] or stock.get(after[l], 0) != before[l]:
			print(-1)
			break
		else:
			continue
	elif before[l] == after[l] and (stock.get(after[l], 0) not in (0, -1) or stock.get(before[l], 0) not in (0, -1)):
		print(-1)
		break
	else:
		stock[before[l]] = -1
		stock[after[l]] = -1
else:
	anslen = len(answer)
	print(anslen)
	for a in answer:
		print(a)


s = str(input())
t = str(input())
change = dict()
used = []
b = 0
if len(s) != len(t):
	change[s[0]] = {'a', 'b', 'c'}
for i in range(len(s)):
	if s[i] != t[i]:
		change[s[i]] = set(change.get(s[i], {''}) | {t[i]})
		change[t[i]] = set(change.get(t[i], {''}) | {s[i]})
	else:
		change[s[i]] = set(change.get(s[i], {''}) | {s[i]})
for key in change:
	if len(change[key]) > 2:
		print(-1)
		break
	if change[key] == {'', key}:
		b += 1
else:
	print(int(len(change) / 2 - b / 2))
	for i in change:
		change[i] -= {''}
		for j in change[i]:
			a = j
		if i not in used and i != a:
			print(i, a)
		used += a


s1 = input()
s2 = input()
d = dict()
for i in range(len(s1)):
	if s2[i] != s1[i]:
		res1 = d.get(s1[i], -1)
		res2 = d.get(s2[i], -1)
		if res1 == -1 and res2 == -1 or (res1 == s2[i] and res2 == s1[i]):
			d[s1[i]] = s2[i]
			d[s2[i]] = s1[i]
		else:
			print(-1)
			exit()
	if s2[i] == s1[i]:
		res = d.get(s1[i], -1)
		if res != -1 and res != s1[i]:
			print(-1)
			exit()
		d[s1[i]] = s1[i]
ans = len(d)
for i in d:
	if i == d[i]:
		ans -= 1
print(ans // 2)
used = dict()
for i in d:
	used[i] = 0
for i in d:
	if not used[i] and i != d[i]:
		print(i, d[i])
		used[d[i]] = 1


dict = {}
l = []
o = input()
s = input()
for i in range(len(o)):
	if o[i] == s[i]:
		if o[i] not in l:
			if o[i] not in dict.keys() and o[i] not in dict.values():
				l.append(o[i])
			else:
				print('-1')
				exit()
	elif o[i] in l or s[i] in l:
		print('-1')
		exit()
	elif o[i] in dict.keys():
		if dict[o[i]] != s[i]:
			print('-1')
			exit()
	elif s[i] in dict.keys():
		if dict[s[i]] != o[i]:
			print('-1')
			exit()
	elif s[i] in dict.values() or o[i] in dict.values():
		print('-1')
		exit()
	else:
		dict[o[i]] = s[i]
print(len(dict))
for c in dict.keys():
	print(c, dict[c])