n,m = map(int,input().split())
ls = []
if m == 0:
    if n == 1:
        print(0)
    else:
        print("1"+"0"*(n-1))
    exit()
ss = []
cc = []
for i in range(m):
    s,c = map(int,input().split())
    if s in ss:
        if cc[ss.index(s)] != c:
            print(-1)
            exit()
    ss.append(s)
    cc.append(c)
    ls.append([s,c])
    
S = list("0"*n)

for i in ls:
    S[i[0]-1] = str(i[1])

if n != 1:
  for i in ls:
    if i[0] == 1 and i[1] == 0:
      print(-1)  
      exit()
      
for i in S:
  print(i,end="")