n,m=map(int,input().split())
# a,b,c=map(int,input().split())
# s=input()
# s,t=map(str,input().split())
ans=[0]*n
anss=""
l=[]
L=[]
for i in range(m):
  s,c=map(int,input().split())
  l.append(str(s)+str(c))

l=list(set(l))
for x in l:
  L.append([x[0],x[1]])
X=[]

for i in range(len(L)):

  ans[int(L[i][0])-1] = int(L[i][1])
  if L[i][0] in X:
    print(-1)
    exit()
  else:
      X.append(L[i][0])
print(ans)
if ans[0]==0:
  if n!=1:
    ans[0]="1"
    for x in ans:
      anss+=str(x)
      print(anss)
  else:
    print(0)
else:
  for x in ans:
    anss+=str(x)
  print(anss)