n,m = [int(i) for i in input().split()]
sc  = [i.split() for i in list(set([input() for i in range(m)]))]
a = [-1]*n

for k,v in sc:
  k = int(k)-1
  if k==0 and v==0:
    print(-1)
    exit()
  if a[k]!=-1:
    print(-1)
    exit()
  a[k] = v

for i in range(n):
  if a[i]==-1:
    if i==0:
      a[i]="1"
    else:
      a[i]="0"

print(int(''.join(a)))