List=[]
while True:
    try:
        List.append(list(map(int,input().split())))

    except:
        break;

keta1 = 2
keta1num = 0
keta = 0

for l in List:
  if l[0] == 1:
    keta1 = 1
    if keta1num < l[1]:
      keta1num = l[1]
  if keta < l[0]:
    keta = l[0]

if keta1 != 1 or keta1num == 0:
  print('-1')
ans = []
for i in range(keta):
  ans.append(10)
  
for l in List:
  if ans[l[0] - 1] > l[1]:
    ans[l[0] - 1] = l[1]
for i in range(keta):
  if ans[i - 1] == 10:
  	ans[i - 1] = 0
N = ''
for x in ans:
  N = N + str(x)
print(int(N))