n,m = map(int,input().split())
ls =[]

for _ in range(m):
  s,c = input().split()
  s = int(s)-1
  ls.append([s,c])

ans = -1
for i in range(pow(10,n-1),pow(10,n)):
  s = str(i).zfill(n)
  p = True
  for a in ls:
    if not (s[a[0]] == a[1]):
      p = False
  if p:
    ans = i
    break
print(ans)


