def inputs(): return [int(x) for x in input().split()]
n,m = inputs()
sc = [inputs() for _ in range(m)]
a = 10**n
flag = 0
for i in range(a):
  b = str(i)
  flag = 0
  for j in range(m):
    s1,c1 = sc[j]
    if len(b)!=n or b[s1-1]!=str(c1):
      break
    flag+=1
  if flag==m:
    print(b)
    exit()
print(-1)