N,M=map(int,input().split())
x=[False]*N
flag=0


for _ in range(M):
  a,b=map(str,input().split())
  if a=="1" and b=="0":
    flag=1
    if N==1:
      flag=None
      print("0")
  if x[int(a)-1]==False:
    x[int(a)-1]=b
  else:
    if x[int(a)-1]!=b:
      flag=1

if flag==1:
  print("-1")
elif flag==0:
  if x[0]==False:
    if M==0:
      x[0]=="0"
    else:
      x[0]="1"
  for i in range(N):
    if x[i]==False:
      x[i]="0"
  else:
    if x.count("0")==N and M!=0:
      print("0")
    print("".join(x))