S=[];C=[]
N,M=map(int,input().split())
for i in range(M):
  s,c=map(int,input().split())
  S.append(s)
  C.append(c)
#print(S)
#print(C)
A=[0]*N
for i in range(M):
  A[S[i]-1]=C[i]
B=A[0]*100+A[1]*10+A[2]
if len(str(B))!=N:
  print(-1)
else:
  print(B)