if n == 1:
  for i in range(10):
    i = str(i)
    for s, c in sc:
      if i == str(c):
        flag = True 
      else:
        flag = False
        break 
    if flag:
      print(''.join(i))
      exit()

for i in range(10**(n-1), 1000):
  i = list(str(i))
  flag = False
  for s,c in sc:
    if i[s-1] == str(c):
      flag = True
    else:
      flag = False
      break
  if flag:
    print(''.join(i))
    exit()

print('-1')