Coming up with a new problem isn't as easy as many people think. Sometimes it is hard enough to name it. We'll consider a title original if it doesn't occur as a substring in any titles of recent Codeforces problems. 

You've got the titles of n last problems — the strings, consisting of lowercase English letters. Your task is to find the shortest original title for the new problem. If there are multiple such titles, choose the lexicographically minimum one. Note, that title of the problem can't be an empty string.

A substring s[l... r] (1 ≤ l ≤ r ≤ |s|) of string s = s_1s_2... s_{|}s| (where |s| is the length of string s) is string s_{l}s_{l} + 1... s_{r}.

String x = x_1x_2... x_{p} is lexicographically smaller than string y = y_1y_2... y_{q}, if either p < q and x_1 = y_1, x_2 = y_2, ... , x_{p} = y_{p}, or there exists such number r (r < p, r < q), that x_1 = y_1, x_2 = y_2, ... , x_{r} = y_{r} and x_{r} + 1 < y_{r} + 1. The string characters are compared by their ASCII codes.


-----Input-----

The first line contains integer n (1 ≤ n ≤ 30) — the number of titles you've got to consider. Then follow n problem titles, one per line. Each title only consists of lowercase English letters (specifically, it doesn't contain any spaces) and has the length from 1 to 20, inclusive.


-----Output-----

Print a string, consisting of lowercase English letters — the lexicographically minimum shortest original title.


-----Examples-----
Input
5
threehorses
goodsubstrings
secret
primematrix
beautifulyear

Output
j

Input
4
aa
bdefghijklmn
opqrstuvwxyz
c

Output
ab



-----Note-----

In the first sample the first 9 letters of the English alphabet (a, b, c, d, e, f, g, h, i) occur in the problem titles, so the answer is letter j.

In the second sample the titles contain 26 English letters, so the shortest original title cannot have length 1. Title aa occurs as a substring in the first title.

Difficulty: MEDIUM
Tags: String algorithms

Complete search
Skill types: Complete search

Starter code:

Solutions:
import string
titles = ''
letters = [i for i in string.ascii_lowercase]
num_inputs = int(input())
for i in range(num_inputs):
	word = input()
	titles += word + ' '
solved = False
for i in letters:
	if i not in titles:
		print(i)
		solved = True
		break
if not solved:
	for j in letters:
		if solved:
			break
		for i in letters:
			s = j + i
			if s not in titles:
				print(s)
				solved = True
				break


from string import ascii_lowercase
dict = {}
f = 0
n = int(input())
k = 0
s = ''
l = []
l1 = []
m = 0
for i in range(0, n):
	s = input()
	l1.append(s)
l1 = [i.strip() for i in l1]
str = 'a'
while f == 0:
	m = 0
	for i in range(0, n):
		s = ''.join(l1[i])
		if str in s:
			m = m + 1
	if m != 0:
		if str[k] == 'z':
			j = k
			while str[j] == 'z' and j >= 0:
				str = str.replace(str[k], 'a')
				j = j - 1
			if j == -1:
				str = str + 'a'
				k = k + 1
			else:
				str = str[:j] + chr(ord(str[j]) + 1) + str[j + 1:]
		else:
			str = str[:k] + chr(ord(str[k]) + 1)
	else:
		f = 1
		break
print(str)


from itertools import product

def generate_name(S):
	for i in range(1, 9):
		for letters in product('abcdefghijklmnopqrstuvwxyz', repeat=i):
			name = ''.join(letters)
			if all((name not in s for s in S)):
				return name
print(generate_name([input() for _ in range(int(input()))]))


I = input
s = ' '.join((I() for _ in '0' * int(I())))
R = list(map(chr, range(122, 96, -1)))
for i in R:
	for j in R:
		if s.count(i + j) == 0:
			r = i + j
for i in R:
	if s.count(i) == 0:
		r = i
print(r)


n = int(input())
s = ''
for i in range(n):
	s += ' ' + input()
se = set(s)
if len(se) <= 26:
	for i in range(97, 123):
		if chr(i) not in se:
			print(chr(i))
			exit()
else:
	for i in range(97, 123):
		for j in range(97, 123):
			if chr(i) + chr(j) not in s:
				print(chr(i) + chr(j))
				exit()


class CodeforcesTask278BSolution:

	def __init__(self):
		self.result = ''
		self.n = 0
		self.names = []

	def read_input(self):
		self.n = int(input())
		for x in range(self.n):
			self.names.append(input())

	def process_task(self):
		used = {}
		for name in self.names:
			for x in range(len(name)):
				for y in range(x, len(name)):
					sub = name[x:y + 1]
					used[sub] = True
		cd = False
		for a in ' abcdefghijklmnopqrstuvwxyz':
			for b in ' abcdefghijklmnopqrstuvwxyz':
				for c in 'abcdefghijklmnopqrstuvwxyz':
					l1 = '' if a == ' ' else a
					l2 = '' if b == ' ' else b
					l3 = c
					nn = l1 + l2 + l3
					if nn not in used:
						cd = True
						break
				if cd:
					break
			if cd:
				break
		self.result = nn

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


n = int(input())
a = []
m = 0
for i in range(n):
	a.append(input())
	m = max(m, len(a[i]))
for i in range(26):
	t = chr(97 + i)
	possible = True
	for k in range(n):
		if not possible:
			break
		for l in range(len(a[k])):
			if a[k][l] == t:
				possible = False
				break
	if possible:
		print(t)
		exit()
for i in range(26):
	for j in range(26):
		t = chr(97 + i) + chr(97 + j)
		possible = True
		for k in range(n):
			if not possible:
				break
			for l in range(len(a[k]) - 1):
				if a[k][l:l + 2] == t:
					possible = False
					break
		if possible:
			print(t)
			exit()


n = int(input())
arr = []
for i in range(n):
	arr += [input()]
s = '+'.join(arr)
q = 'abcdefghijklmnopqrstuvwxyz'
for i in q:
	if i not in s:
		print(i)
		break
else:
	for i in q:
		for j in q:
			if i + j not in s:
				print(i + j)
				exit()


3
n = int(input())
lst = [input() for _ in range(n)]
alf = [chr(ord('a') + _) for _ in range(26)]
ans = None
for a in alf:
	if not [1 for w in lst if w.find(a) != -1]:
		ans = a
		break
if ans is not None:
	print(ans)
else:
	for a in alf:
		for b in alf:
			t = a + b
			if not [1 for w in lst if w.find(t) != -1]:
				ans = t
				break
		if ans is not None:
			print(ans)
			break


n = int(input())
l = []
for i in range(n):
	l += [input()]
s = '+'.join(l)
q = 'abcdefghijklmnopqrstuvwxyz'
for i in q:
	if i not in s:
		print(i)
		break
else:
	for i in q:
		for j in q:
			if i + j not in s:
				print(i + j)
				return


import re
import itertools
from collections import Counter

class Task:
	strings = []
	answer = ''

	def getData(self):
		numberOfStrings = int(input())
		for i in range(0, numberOfStrings):
			self.strings += [input()]

	def solve(self):
		badStrings = set()
		for current in self.strings:
			for left in range(0, len(current)):
				for right in range(left + 1, len(current) + 1):
					badStrings.add(current[left:right])
		alphabet = []
		for character in range(ord('a'), ord('z') + 1):
			alphabet += [chr(character)]
		for answerLength in range(1, 21 + 1):
			for p in itertools.product(alphabet, repeat=answerLength):
				string = re.sub('[^\\w]', '', str(p))
				if string not in badStrings:
					self.answer = string
					return

	def printAnswer(self):
		print(self.answer)
task = Task()
task.getData()
task.solve()
task.printAnswer()


n = int(input())
strings = []
all = []
alps = []
for i in range(26):
	alps.append(chr(ord('a') + i))
	all.append(alps[i])
for i in range(26):
	for j in range(i, 26):
		all.append(alps[i] + alps[j])
for i in range(n):
	s = input()
	for j in range(len(s)):
		for k in range(j, len(s)):
			strings.append(s[j:k + 1])
ans = ''
for i in all:
	f = 1
	for j in strings:
		if i == j:
			f = 0
			break
	if f == 1:
		print(i)
		break


n = int(input())
lis = []
ss = 'abcdefghijklmnopqrstuvwxyz'
for i in range(n):
	s = input()
	lis.append(s)
k = 1
for i in range(26):
	ser = ss[i]
	k = 0
	for j in lis:
		if ser not in j:
			k += 1
	if k == n:
		print(ser)
		exit()
for i in range(26):
	for j in range(26):
		ser = ss[i] + ss[j]
		k = 0
		for t in lis:
			if ser not in t:
				k += 1
		if k == n:
			print(ser)
			exit()


n = int(input())
a = []
for i in range(n):
	x = input()
	a.append(x)
arr = []
for i in range(26):
	arr.append(chr(i + ord('a')))
for i in range(26):
	for j in range(26):
		arr.append(arr[i] + chr(j + ord('a')))
for i in range(len(arr)):
	cnt = 0
	for j in range(n):
		if arr[i] not in a[j]:
			cnt += 1
	if cnt == n:
		print(arr[i])
		exit(0)


n = int(input())
alph = 'abcdefghijklmnopqrstuvwxyz'
L = []
for x in range(n):
	L.append(input())
i = 0
j = 0
k = -1
ch = alph[0]
while 1:
	if ch not in L[i]:
		i = i + 1
	else:
		j = j + 1
		if j >= 26:
			if j > 0 and j % 26 == 0:
				k = k + 1
			ch = alph[k] + alph[j % 26]
		else:
			ch = alph[j]
		i = 0
	if i == n:
		break
print(ch)


cs1 = {chr(x) for x in range(ord('a'), ord('z') + 1)}
cs2 = {x + y for x in cs1 for y in cs1}
for i in range(int(input())):
	s = input()
	for i in range(len(s) - 1):
		cs1.discard(s[i:i + 1])
		cs2.discard(s[i:i + 2])
	cs1.discard(s[len(s) - 1:len(s)])
print(min(cs1) if cs1 else min(cs2))


from itertools import *
alphabet = 'abcdefghijklmnopqrstuvwxyz'

def newProblem(names):
	for i in range(1, 3):
		for s in product(alphabet, repeat=i):
			st = ''.join(s)
			if names.find(st) == -1:
				return st
n = int(input())
names = []
for i in range(0, n):
	name = input()
	names.append(name)
namesstr = ' '.join(names)
print(newProblem(namesstr))


import string
s = ' '.join((input() for i in range(int(input()))))
alph = string.ascii_lowercase
for i in alph:
	if i not in s:
		print(i)
		exit()
for i in alph:
	for j in alph:
		if i + j not in s:
			print(i + j)
			exit()


n = int(input())
all = set()
for w in range(n):
	s = input()
	for i in range(len(s) + 1):
		for j in range(i):
			all.add(s[j:i])
cnt = 0
limit = 26
l = 1
while True:
	s = ''
	tmp = cnt
	for i in range(l):
		s = chr(ord('a') + tmp % 26) + s
		tmp //= 26
	if s not in all:
		print(s)
		break
	cnt += 1
	if cnt == limit:
		cnt = 0
		limit *= 26
		l += 1


import itertools
n = int(input())
d = set()
for i in range(n):
	s = input()
	for j in s:
		d.add(j)
	for j in range(len(s) - 1):
		d.add(s[j:j + 2])
	for j in range(len(s) - 2):
		d.add(s[j:j + 3])
R = [i for i in range(26)]
D = [[] for i in range(3)]
a = ord('a')
for i in range(26):
	D[0].append(chr(i + a))
for (i, j) in itertools.product(R, R):
	D[1].append(chr(i + a) + chr(j + a))
for (i, j, k) in itertools.product(R, R, R):
	D[2].append(chr(i + a) + chr(j + a) + chr(k + a))
for i in range(3):
	D[i] = sorted(D[i])
	for k in D[i]:
		if k not in d:
			print(k)
			exit()


n = int(input())
single = []
double = []
titlesingle = []
titledouble = []
for i in range(n):
	x = input()
	l = list(x)
	titlesingle.extend(l)
	if len(x) > 1:
		for j in range(1, len(x)):
			s = x[j - 1] + x[j]
			titledouble.append(s)
sets = set(titlesingle)
setd = set(titledouble)
for i in range(26):
	s = chr(ord('a') + i)
	single.append(s)
for i in range(26):
	for j in range(26):
		s = chr(ord('a') + i) + chr(ord('a') + j)
		double.append(s)
if len(sets) < 26:
	ls = list(set(single) - sets)
	ls.sort()
	print(ls[0])
else:
	ls = list(set(double) - setd)
	ls.sort()
	print(ls[0])


a = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']

def fed(n):
	for j in a:
		for k in a:
			x = True
			for i in range(n):
				if (j + k in l[i]) == False:
					x = True
				else:
					x = False
					break
			if x == True:
				return j + k
n = int(input())
l = [0] * n
for i in range(n):
	l[i] = input()
s = set([])
for i in range(n):
	s = s | set(l[i])
if s != set(a):
	for j in range(len(a)):
		if (a[j] in s) == False:
			print(a[j])
			break
else:
	print(fed(n))


n = int(input())
ch = ''
while n:
	sh = input()
	ch += ' ' + sh
	n -= 1
l = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']
t = False
for x in l:
	if x not in ch:
		t = True
		print(x)
		break
if not t:
	for i in range(len(l)):
		if not t:
			for j in range(len(l)):
				s = l[i] + l[j]
				if s not in ch:
					print(s)
					t = True
					break


from itertools import *
alphabet = 'abcdefghijklmnopqrstuvwxyz'

def isValid(s, names):
	for name in names:
		if name.find(s) != -1:
			return False
	return True

def newProblem(names):
	for i in range(1, 3):
		for s in product(alphabet, repeat=i):
			st = ''
			for c in s:
				st += c
			if isValid(st, names):
				return st
n = int(input())
names = []
for i in range(0, n):
	name = input()
	names.append(name)
print(newProblem(names))


def ts(d, l):
	for i in range(len(l)):
		if d in l[i]:
			return True
	return False

def main():
	n = int(input())
	l = []
	d = ''
	f = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']
	for i in range(n):
		l.append(input())
	for j in range(20):
		for k in range(len(f)):
			for i in range(len(f)):
				d += f[i]
				if ts(d, l):
					d = d[:-1]
				else:
					return d
			d = d[:-1]
			d += f[k]
print(main())


import sys

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

def mint():
	return int(minp())

def mints():
	return map(int, minp().split())
all = set()

def subs(s):
	for i in range(len(s)):
		for j in range(i + 1, len(s) + 1):
			all.add(s[i:j])
n = mint()
for i in range(n):
	subs(minp())

def rec(s, n):
	if n == 0:
		if s not in all:
			print(s)
			exit(0)
		return
	for i in range(ord('a'), ord('z') + 1):
		rec(s + chr(i), n - 1)
for i in range(1, 100):
	rec('', i)


alpha = 'abcdefghijklmnopqrstuvwxyz'
n = int(input())
s = ''
for _ in range(n):
	s += input() + ' '
for x in alpha:
	if x not in s:
		print(x)
		break
else:
	for i in alpha:
		for j in alpha:
			if i + j not in s:
				print(i + j)
				quit()


import string
n = int(input())
s = '.'.join((input() for _ in range(n)))
a = string.ascii_lowercase
for i in a:
	if i not in s:
		print(i)
		exit()
for i in a:
	for j in a:
		if i + j not in s:
			print(i + j)
			exit()


ans = []
for i in range(27):
	for j in range(27):
		for t in range(27):
			tempa = [i, j, t]
			s = ''
			for q in range(len(tempa)):
				if tempa[q] == 26:
					continue
				else:
					s += chr(tempa[q] + 97)
					ans.append([len(s), s])
ans.sort()
pg = []
x = int(input())
for i in range(x):
	s = input()
	pg.append(s)
for i in range(len(ans)):
	flag = 0
	for j in range(len(pg)):
		if ans[i][1] in pg[j]:
			flag += 1
	if flag == 0:
		print(ans[i][1])
		exit()


import string
n = int(input())
d = {}
s = ''
for _ in range(n):
	s += input() + ' '
a = string.ascii_lowercase
for x in a:
	if x not in s:
		print(x)
		exit()
for x in a:
	for y in a:
		if x + y not in s:
			print(x + y)
			exit()


n = int(input())
t = ' '.join((input() for i in range(n)))
ans = 0
for i in 'abcdefghijklmnopqrstuvwxyz':
	if not i in t:
		ans = i
		break
if not ans:
	for i in 'abcdefghijklmnopqrstuvwxyz':
		for j in 'abcdefghijklmnopqrstuvwxyz':
			if not i + j in t:
				ans = i + j
				break
		if ans:
			break
print(ans)


n = int(input())
alph = 'abcdefghijklmnopqrstuvwxyz'
ch = ''
for x in range(n):
	ch += ' ' + input()

def f():
	ch1 = ''
	j = 0
	for k in range(26):
		for i in range(26):
			if ch1 + alph[i] not in ch:
				print(ch1 + alph[i])
				return
		ch1 = alph[j]
		j += 1
f()