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

kouho = [int(i) for i in range(10**(n-1),10**(n))]
digit = []
for i in range(m):
  s,c = map(int,input().split())
  digit.append([s,c])

for i in kouho:
  tmp_str = str(i)
  Flag = True
  for s,c in digit:
    if tmp_str[s-1] != str(c):
      Flag = False
  if Flag==True:
    print(i)
    exit()
print('-1')
