Valya and Tolya are an ideal pair, but they quarrel sometimes. Recently, Valya took offense at her boyfriend because he came to her in t-shirt with lettering that differs from lettering on her pullover. Now she doesn't want to see him and Tolya is seating at his room and crying at her photos all day long.

This story could be very sad but fairy godmother (Tolya's grandmother) decided to help them and restore their relationship. She secretly took Tolya's t-shirt and Valya's pullover and wants to make the letterings on them same. In order to do this, for one unit of mana she can buy a spell that can change some letters on the clothes. Your task is calculate the minimum amount of mana that Tolya's grandmother should spend to rescue love of Tolya and Valya.

More formally, letterings on Tolya's t-shirt and Valya's pullover are two strings with same length n consisting only of lowercase English letters. Using one unit of mana, grandmother can buy a spell of form (c_1, c_2) (where c_1 and c_2 are some lowercase English letters), which can arbitrary number of times transform a single letter c_1 to c_2 and vise-versa on both Tolya's t-shirt and Valya's pullover. You should find the minimum amount of mana that grandmother should spend to buy a set of spells that can make the letterings equal. In addition you should output the required set of spells. 


-----Input-----

The first line contains a single integer n (1 ≤ n ≤ 10^5) — the length of the letterings.

The second line contains a string with length n, consisting of lowercase English letters — the lettering on Valya's pullover.

The third line contains the lettering on Tolya's t-shirt in the same format.


-----Output-----

In the first line output a single integer — the minimum amount of mana t required for rescuing love of Valya and Tolya.

In the next t lines output pairs of space-separated lowercase English letters — spells that Tolya's grandmother should buy. Spells and letters in spells can be printed in any order.

If there are many optimal answers, output any.


-----Examples-----
Input
3
abb
dad

Output
2
a d
b a
Input
8
drpepper
cocacola

Output
7
l e
e d
d c
c p
p o
o r
r a



-----Note-----

In first example it's enough to buy two spells: ('a','d') and ('b','a'). Then first letters will coincide when we will replace letter 'a' with 'd'. Second letters will coincide when we will replace 'b' with 'a'. Third letters will coincide when we will at first replace 'b' with 'a' and then 'a' with 'd'.

Difficulty: interview

Starter code:

Solutions:
# import sys
# sys.stdin = open('in.txt', 'r')

_ = input()
s = input()
t = input()

par = [i for i in range(26)]
def find(x):
    if par[x] != x:
        par[x] = find(par[x])
        return par[x]
    else:
        return x

for i in range(len(s)):
    a, b = find(ord(s[i])-97), find(ord(t[i])-97)
    if a != b:
        par[a] = b

res = 0
for i in range(26):
    find(i)

for i in range(26):
    res += max(0, par.count(i) - 1)
print(res)

for i in range(26):
    d = []
    for j in range(26):
        if par[j] == i:
            d.append(chr(j+97))

    for j in range(len(d)-1):
        print(d[j], d[j+1])


n = int(input())
v = input()
t = input()
rank = [0] * 26
par = [i for i in range(26)]


def find(x):
    if par[x] == x:
        return x
    else:
        par[x] = find(par[x])
        return par[x]


def unite(x, y):
    x = find(x)
    y = find(y)
    if x == y:
        return
    if rank[x] > rank[y]:
        par[y] = x
    else:
        par[x] = y
        if rank[x] == rank[y]:
            rank[y] += 1


def same(x, y):
    return find(x) == find(y)


rec = []
num = 0
for i in range(n):
    a, b = ord(v[i]) - ord("a"), ord(t[i]) - ord("a")

    if not same(a-1, b-1):
        unite(a - 1, b - 1)
        rec.append((v[i], t[i]))
        num += 1

print(num)
for p, q in rec:
    print(p, q)

n = int(input())
S = set()
Slovar = []
sviter = input()
futbol = input()
res = 0
Ans = []
for i in range(n):
    if sviter[i] != futbol[i]:
        if sviter[i] not in S and futbol[i] not in S:
            Slovar.append(sviter[i] + futbol[i])
            S.add(sviter[i])
            S.add(futbol[i])
            res += 1
            Ans.append([sviter[i], futbol[i]])
        elif sviter[i] in S and futbol[i] not in S:
            S.add(futbol[i])
            for j in range(len(Slovar)):
                if sviter[i] in Slovar[j]:
                    Slovar[j] += futbol[i]
                    res += 1
                    Ans.append([sviter[i], futbol[i]])                    
                    break
        elif sviter[i] not in S and futbol[i] in S:
            S.add(sviter[i])
            for j in range(len(Slovar)):
                if futbol[i] in Slovar[j]:
                    Slovar[j] += sviter[i]
                    res += 1
                    Ans.append([sviter[i], futbol[i]])                     
                    break
        elif sviter[i] in S and futbol[i] in S:
            for j in range(len(Slovar)):
                if futbol[i] in Slovar[j]:
                    a = j
                if sviter[i] in Slovar[j]:
                    b = j                
            if a != b:
                Slovar[a] = Slovar[a] + Slovar[b]
                Slovar[b] = ''
                res += 1
                Ans.append([sviter[i], futbol[i]])
        #print(i, res, Slovar, S)
print(res)
for i in range(res):
    print(*Ans[i])

n = int(input())

t = input()
v = input()

s = list(set(list(t)).union(set(list(v))))
uf = [i for i in range(len(s))]

def find(uf,i):
    p = uf[i]
    return p if i==p else find(uf,p)

def union(uf,i,j):
    uf[find(uf,i)] = find(uf,j)

res = []    
for i in range(n):
    ti = s.index(t[i])
    vi = s.index(v[i])
    if (find(uf,ti) != find(uf,vi)):
        union(uf,ti,vi)
        res.append((t[i],v[i]))

print(len(res))
for i in range(len(res)):
    print(res[i][0],res[i][1])

#!/usr/bin/env python3
#! -*- coding: utf-8 -*-
from random import getrandbits

p = []

def get(v):
	nonlocal p
	if p[v] == v:
		return v
	p[v] = get(p[v])
	return p[v]

def unite(u, v):
	nonlocal p
	u, v = get(u), get(v)
	if u == v:
		return False
	if getrandbits(1):
		u, v = v, u
	p[u] = v
	return True

def main():
	n = int(input())
	nonlocal p
	p = list(range(26))
	s = input()
	t = input()
	ans = []
	for i, x in enumerate(zip(s, t)):
		a, b = x
		if unite(ord(a) - ord('a'), ord(b) - ord('a')):
			ans.append((a, b))
	print(len(ans))
	for x in ans:
		print(*x)

def __starting_point():
	main()
__starting_point()

def f(x):
    if data[x] != x:
        data[x] = f(data[x])
        return data[x]
    else:
        return x

n = int(input())
s = input()
t = input()
data = [i for i in range(26)]
for i in range(n):
    a, b = f(ord(s[i]) - ord("a")), f(ord(t[i]) - ord("a"))
    if a != b:
        data[a] = b
ans = 0
for i in range(26):
    f(i)
for i in range(26):
    ans += max(0, data.count(i) - 1)
print(ans)
for i in range(26):
    ans = []
    for j in range(26):
        if data[j] == i:
            ans.append(chr(j + ord("a")))
    for j in range(len(ans) - 1):
        print(ans[j], ans[j + 1])

def f(x):
    if data[x] != x:
        data[x] = f(data[x])
        return data[x]
    return x

n = int(input())
s = input()
t = input()
data = [i for i in range(26)]
for i in range(n):
    a, b = f(ord(s[i]) - ord("a")), f(ord(t[i]) - ord("a"))
    if a != b:
        data[a] = b
ans = 0
for i in range(26):
    f(i)
for i in range(26):
    ans += max(0, data.count(i) - 1)
print(ans)
for i in range(26):
    ans = []
    for j in range(26):
        if data[j] == i:
            ans.append(chr(j + ord("a")))
    for j in range(len(ans) - 1):
        print(ans[j], ans[j + 1])

parent = [i for i in range(200)]

def fin (x):
    if parent[x] == x:
        return x
    x = parent[x]
    parent[x] = fin(x)
    return parent[x]


#import sys
#sys.stdin = open ('464-D.in', 'r')

n = int(input())
a = input()
b = input()
lst = []
for i in range(0,n):
    x = ord(a[i])-48
    y = ord(b[i])-48
    u = fin(x)
    v = fin(y)
    if u!=v:
        lst.append((ord(a[i])-48,ord(b[i])-48))
        parent[u] = v

print(len(lst))
for i, j in lst:
    print (chr(i+48), chr(j+48))

n = int(input())
first, second = input(), input()
letters = {i:i for i in [chr(i) for i in range(ord('a'), ord('z')+1)]}
# print(letters)
# res = []

for i in range(n):
    s1, s2 = first[i], second[i]
    if letters[s1] == letters[s2]:
        continue
    if s1 > s2:
        s1, s2 = s2, s1
    frm, to = letters[s2], letters[s1]
    for key in letters:
        if letters[key] == frm:
            letters[key] = to
result = []
for k, v in list(letters.items()):
    if k != v:
        result.append((k, v))
print(len(result))
for r in result:
    print(f'{r[0]} {r[1]}')


from collections import defaultdict


length = int(input().strip())
s1 = input().strip()
s2 = input().strip()

adj = defaultdict(list)
nodes = set()

for c1, c2 in zip(s1, s2):
    if c1 != c2:  # add to undirected graph
        adj[c1].append(c2)
        adj[c2].append(c1)
        nodes.add(c1)
        nodes.add(c2)

v = set()
st = []


def dfs(n):
    v.add(n)
    for neighbor in adj[n]:
        if neighbor not in v:
            st.append((n, neighbor))
            dfs(neighbor)


for n in nodes:
    if n not in v:
        dfs(n)

print(len(st))
for pair in st:
    print(*pair)


class DSet:
    def __init__(self, n):
        self.parents = [-1 for i in range(n)]
        self.rank = [0 for i in range(n)]

    def find(self, n):
        if self.parents[n] is -1:
            return n
        ret = self.find(self.parents[n])
        self.parents[n] = ret
        return ret

    def union(self, a, b):
        if a is -1 or b is -1:
            return False
        x, y = self.find(a), self.find(b)
        if self.find(a) == self.find(b) and x is not -1:
            return False
        if self.rank[x] == self.rank[y]:
            self.parents[x] = y
            self.rank[x] = self.rank[y] = self.rank[x] + 1
        elif self.rank[x] > self.rank[y]:
            self.parents[y] = x
            self.rank[y] = self.rank[x]
        else:
            self.parents[x] = y
            self.rank[x] = self.rank[y]
        return True


ds = DSet(2 * int(input()))
str1, str2 = input(), input()

alphaHash = [-1 for i in range(26)]
for i in range(len(str1)):
    ds.union(i, alphaHash[ord(str1[i]) - ord('a')])
    alphaHash[ord(str1[i]) - ord('a')] = i
    ds.union(len(str1) + i, alphaHash[ord(str2[i]) - ord('a')])
    alphaHash[ord(str2[i]) - ord('a')] = len(str1) + i

ans = []
for i in range(len(str1)):
    if ds.union(i, len(str1) + i):
        ans.append((str1[i], str2[i]))

print(len(ans))
for x in ans:
    print(x[0] + " " + x[1])


def main():
    p = [i for i in range(26)]

    def find(v):
        if p[v] != v:
            p[v] = find(p[v])
        return p[v]

    n = int(input())
    s1 = input()
    s2 = input()

    ans = []

    for i in range(n):
        a = find(ord(s1[i]) - ord('a'))
        b = find(ord(s2[i]) - ord('a'))

        if a != b:
            p[a] = b
            ans.append((chr(ord('a') + a), chr(ord('a') + b)))

    print(len(ans))

    for a, b in ans:
        print(a, b)
        

def __starting_point():
    main()

__starting_point()

from collections import defaultdict
from queue import Queue

IS_WAY_CACHE = set()


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


def is_way(char_map, ch1, ch2):
    nonlocal IS_WAY_CACHE
    q = Queue()
    q.put(ch1)
    visited = {ch1}
    while not q.empty():
        cur_node = q.get()
        if cur_node == ch2:
            return True
        visited.add(cur_node)
        neighbours = char_map[cur_node]
        for n in neighbours:
            IS_WAY_CACHE.add((ch1, n))
            if n not in visited:
                q.put(n)
    return False


def is_way_cache(ch1, ch2):
    return (ch1, ch2) in IS_WAY_CACHE


def main():
    input()
    one, two = input(), input()
    char_map = defaultdict(set)
    res = []
    for ch1, ch2 in zip(one, two):
        if ch1 == ch2:
            continue
        if is_way_cache(ch1, ch2):
            continue
        if is_way_cache(ch2, ch1):
            continue
        if is_way(char_map, ch1, ch2):
            continue
        if is_way(char_map, ch2, ch1):
            continue
        res.append((ch1, ch2))
        char_map[ch1].add(ch2)
        char_map[ch2].add(ch1)

    print(len(res))
    for ch1, ch2 in res:
        print(ch1, ch2)


def __starting_point():
    main()
__starting_point()

from collections import defaultdict
from queue import Queue

IS_WAY_CACHE = set()


def is_way(char_map, ch1, ch2):
    nonlocal IS_WAY_CACHE
    q = Queue()
    q.put(ch1)
    visited = {ch1}
    while not q.empty():
        cur_node = q.get()
        if cur_node == ch2:
            return True
        visited.add(cur_node)
        neighbours = char_map[cur_node]
        for n in neighbours:
            IS_WAY_CACHE.add((ch1, n))
            if n not in visited:
                q.put(n)
    return False


def is_way_cache(ch1, ch2):
    return (ch1, ch2) in IS_WAY_CACHE


def main():
    input()
    one, two = input(), input()
    char_map = defaultdict(set)
    res = []
    for ch1, ch2 in zip(one, two):
        if ch1 == ch2:
            continue
        if is_way_cache(ch1, ch2):
            continue
        if is_way(char_map, ch1, ch2):
            continue
        res.append((ch1, ch2))
        char_map[ch1].add(ch2)
        char_map[ch2].add(ch1)

    print(len(res))
    for ch1, ch2 in res:
        print(ch1, ch2)


def __starting_point():
    main()
__starting_point()

def initialize(arr,n):
    for i in range(n):
        arr.append(i)
    return arr

def root(arr,n):
    while(arr[n]!=n):
        n=arr[n]
    return n

def union(arr,a,b):
    arr[a]=arr[b]

n=int(input())
a=input()
b=input()
arr=initialize([],26)
cnt=0
ans=[]
for i in range(n):
    a1=ord(a[i])-97
    b1=ord(b[i])-97
    x=root(arr,a1)
    y=root(arr,b1)
    if(x!=y):
        cnt+=1
        union(arr,x,y)
        ans.append([a[i],b[i]])
print(cnt)
for i in ans:
    print(i[0],i[1])



#k=int(input())
#n,m=map(int,input().split())

#a=list(map(int,input().split()))

#b=list(map(int,input().split()))


def dfs(x):
    for s in range(1,cnt[x]+1):
        if label[alp2[x][s]]==0:
           label[alp2[x][s]]=label[x]
           dfs(alp2[x][s])

n=int(input())
a=input()
b=input()

l=n

alp=[0]*27
alp2=[0]*27
cnt=[0]*27
label=[-1]*27

for i in range(27):
    alp[i]=[0]*27
    alp2[i]=[0]*27

for i in range(l):
    label[ord(a[i])-ord('a')+1]=0
    label[ord(b[i])-ord('a')+1]=0

cntlet=0
for i in range(27):
    if label[i]==0:
        cntlet+=1

for i in range(l):
    alp[ord(a[i])-ord('a')+1][ord(b[i])-ord('a')+1]=1
    alp[ord(b[i])-ord('a')+1][ord(a[i])-ord('a')+1]=1

for i in range(27):
    for j in range(i+1,27):
        if alp[i][j]==1:
            cnt[i]+=1
            cnt[j]+=1
            alp2[i][cnt[i]]=j
            alp2[j][cnt[j]]=i

con=0


for i in range(1,27):
    if(label[i]==0):
        con+=1
        label[i]=con
        dfs(i)

print(cntlet-con)

for i in range(1,con+1):
    for j in range(1,27):
        if label[j]==i:
            break

    for k in range(j+1,27):
        if label[k]==i:
            print(chr(j-1+ord('a')), chr(k-1+ord('a')))

def find(x,parent,rank):
    if(parent[x]!=x):
        parent[x]=find(parent[x],parent,rank)
    return parent[x]

def union(x,y,parent,rank):
    
    xroot=parent[x]
    yroot=parent[y]
    
    if(rank[xroot]<rank[yroot]):
        parent[xroot]=yroot
    elif(rank[xroot]>rank[yroot]):
        parent[yroot]=xroot
    else:
        parent[yroot]=xroot
        rank[xroot]+=1
    
    
    
n=int(input())
str1=input()
str2=input()

hashd=dict()
rev=dict()
i=0
k=0
while(i<len(str1)):
    if(str1[i] not in hashd):
        hashd[str1[i]]=k
        rev[k]=str1[i]
        k+=1
    i+=1
i=0
while(i<len(str2)):
    if(str2[i] not in hashd):
        hashd[str2[i]]=k
        rev[k]=str2[i]
        k+=1
    i+=1

rank=[0 for x in range(k)]
parent=[x for x in range(k)]
sums=0
i=0
arr1=[]
arr2=[]
while(i<n):
    if(find(hashd[str1[i]],parent,rank)!=find(hashd[str2[i]],parent,rank)):
        sums+=1
        union(hashd[str1[i]],hashd[str2[i]],parent,rank)
        arr1.append(str1[i])
        arr2.append(str2[i])
    i+=1
print(sums)
i=0
while(i<len(arr1)):
    print(arr1[i]+' '+arr2[i])
    i+=1


n=int(input())
a=input()

b=input()
diff=[]
for i in range(n):
    if(a[i]!=b[i]):
        posai=-1
        posbi=-1
        
        for j in range(len(diff)):
            if(a[i] in diff[j]):
                posai=j
            if(b[i] in diff[j]):
                posbi=j
        if(posbi!=-1 and posai!=-1):
            if(posbi==posai):
                pass
            else:
                diff[posai]=diff[posai].union(diff[posbi])
                del diff[posbi]
        elif(posbi!=-1):
            diff[posbi].add(a[i])
        elif(posai!=-1):
            diff[posai].add(b[i])
        else:
            diff.append({a[i],b[i]})
#print(diff)
diff2=[]
for i in diff:
    diff2.append([])
    for j in i:
        diff2[-1].append(j)
ans=0
for i in diff2:
    ans+=len(i)-1
print(ans)
for i in diff2:
    for j in range(1,len(i)):
        print(i[j-1],i[j])
    
    


n = int(input())
a = input()
b = input()
f = lambda c: ord(c) - 97
g = lambda x: chr(97 + x)
fa = [i for i in range(26)]
get_fa = lambda x: x if fa[x] == x else get_fa(fa[x])
for i in range(n):
    child = f(b[i])
    father = get_fa(child)
    while (child != father):
        child = fa[child]
    fa[child] = get_fa(f(a[i]))
print(sum(i != get_fa(i) for i in range(26)))
for i in range(26):
    l = i
    r = fa[i]
    if l != r:
        print(g(l), g(r))


def getfather(x):
    if (x == fa[x]): return x
    fa[x] = getfather(fa[x])
    return fa[x]

n = int(input())
s = list(input())
t = list(input())
fa = [_ for _ in range(26)]

ans = []
tot = 0
for i in range(n):
    x = ord(s[i]) - 97
    y = ord(t[i]) - 97
    fx = getfather(x)
    fy = getfather(y)
    if fx != fy:
        fa[fx] = fy
        tot += 1
        ans.append((chr(x + 97),chr(y + 97)))

print(tot)
for i in ans:
    print(i[0] + " " + i[1])
    




def find(list, v):
  if list[v] != v:
    list[v] = find(list, list[v])
  return list[v]

def union(list, a, b):
  list[a] = b

d = [i for i in range(26)]
ans = []

n = int(input())
s1 = input()
s2 = input()

for i in range(n):
  a = find(d, ord(s1[i]) - ord('a'))
  b = find(d, ord(s2[i]) - ord('a'))
  if a == b:
    continue

  union(d, a, b)
  ans.append((chr(ord('a') + a), chr(ord('a') + b)))

print(len(ans))
for a, b in ans:
  print(a, b)


class Union_Find():
    def __init__(self, value):
        self.parents = None
        self.value = None

    def find_parents(self):
        if (self.parents == None):
            return self
        else:
            self.parents = self.parents.find_parents()
            return self.parents


n = int(input().strip())
s1 = input().strip()
s2 = input().strip()

dp = dict()
for i in s1:
    if i not in dp:
        dp[i] = Union_Find(i)
for i, v in enumerate(s2):
    if v not in dp:
        dp[v] = Union_Find(v)
    fr = dp[v].find_parents()
    to = dp[s1[i]].find_parents()
    if (fr != to):
        fr.parents = to

ans = dict()
cnt = 0
for i in dp:
    now = dp[i].find_parents()
    if now in ans:
        ans[now].append(i)
        cnt += 1
    else:
        ans[now] = [i]
print(cnt)
for i in ans:
    for j in range(1, len(ans[i])):
        print(ans[i][j - 1], ans[i][j])

n = int(input())
a = input()
b = input()

pr = {}
ans = []

for i in range(0, 26):
    pr[i] = i

def find_set(v):
    if pr[v] == v:
        return v
    pr[v] = find_set(pr[v])
    return pr[v]

def union_set(x, y):
    pr[x] = y
    ans.append((x, y))

for i in range(len(a)):
    pa = find_set(ord(a[i]) - 97)
    pb = find_set(ord(b[i]) - 97)
    if pa == pb:
        continue
    union_set(pa, pb)

print(len(ans))
for i in ans:
    print(chr(97 + i[0]), chr(97 + i[1]))

from collections import defaultdict

adj_matrix = defaultdict(list)

n = int(input())
s1 = input()
s2 = input()

#Create Graph
for i in range(n):
    if(s1[i] != s2[i]):
        adj_matrix[s1[i]].append(s2[i])
        adj_matrix[s2[i]].append(s1[i])

visited = set()
mst = []
count = 0
def dfs_util(vertices):
    nonlocal  count
    for vertex in adj_matrix[vertices]:
        if vertex not in visited:
            count += 1
            mst.append((vertices, vertex))
            visited.add(vertex)
            dfs_util(vertex)

for vertices in adj_matrix:
    if vertices not in visited:
        visited.add(vertices)
        dfs_util(vertices)
print(count)
for finds in mst:
    print(finds[0], finds[1])

links = [{i} for i in range(26)]
spells = []

count = 0
n = int(input())
s1 = input()
s2 = input()

for i in range(0,n):
  n1 = ord(s1[i]) - 97
  n2 = ord(s2[i]) - 97
  if n1 != n2 and not (n2 in links[n1]):
    links[n1] = links[n1].union(links[n2])
    links[n2] = links[n2].union(links[n1])
    for j in links[n1]:
      if j != n1:
        links[j] = links[n1].union(links[j])

    count = count + 1
    spells.append(chr(97+n1) + " " + chr(97+n2))

print(count)

for i in spells:
  print(i)