Announcement
************Second Round will be ONLINE instead of ONSITE*************
Problem Statement

Schimdt is teaching Jenko a new technique to excel at bases. He writes n numbers in base k on a piece of paper and also their decimal sum. He doesn’t mention k on the paper. Jenko has to find out the value of k using those numbers and their sum. As Jenko is weak in maths, he needs your help to find the value of k.

Input

First line contains n, the count of numbers written on the paper. Next n lines contains the numbers in base k. Next line contains their decimal sum.

Output

Output the desired value of k. If multiple solutions are possible, print the minimum possible value.

Constraints

1 ≤ n ≤ 100000

2 ≤ k ≤ 16

Note: The decimal sum of all the numbers will never exceeds 10^18.

SAMPLE INPUT
2
10 21
10

SAMPLE OUTPUT
3

Explanation

10 in base 3=3 in base 10.
21 in base 3=7 in base 10.
Their sum is 3+7=10 which is given. So, 3 is the required answer
import sys
n = int(sys.stdin.readline())
s = ["" for _ in xrange(n)]
#for i in xrange(n):
#	s[i] = sys.stdin.readline()
s = sys.stdin.readline().split()
m = int(sys.stdin.readline())
#print int('21',3)
d = 0
book = ['A','B','C','D','E','F']
book2 = ['a','b','c','d','e','f']
for ss in s:
	
	for sss in ss:
		#print sss
		if sss in book:
			sss = book.index(sss)+10
		elif sss in book2:
			sss = book2.index(sss)+10
		if int(sss)>d:
			d = int(sss)
dd = max(2,int(d) +1)
if dd>16:
	dd = 16
#print dd
for k in xrange(dd,17):
	su = 0
	for i in xrange(n):
		#print s[i]
		su += int(s[i],k)
	if su==m:
		print k
		break