n,m=map(int,input().split())
l=[list(map(int,input().split())) for _ in range(m)]

arr=[str(i) for i in range(700,10**n)]

for x in arr:
  flag=[False]*n
  for i,tmp in enumerate(l):
    s,c=tmp
    if x[s-1]==str(c):
      flag[i]=True
  if all(flag):
    print(x)
    exit()
print(-1)