N,M=map(int,input().split())
A=[-1]*N
Q=True
L=list(list(map(int,input().split())) for j in range(M))
for i in range(M):
  if A[L[i][0]-1]==-1 or A[L[i][0]-1]==L[i][1]:
    A[L[i][0]-1]==L[i][1]
  else:
    Q=False
for k in range(N):
  if A[k]==-1:
    if N!=1 and k==0:
      A[k]=1
    else:
      A[k]=0
if N!=1 and A[0]==0:
  Q=False
if Q:
  S=""
  for i in range(N):
    S+=str(A[i])
  print(int(S))
else:
  print(-1)
