def get_unique_list(seq):
    seen = []
    return [x for x in seq if x not in seen and not seen.append(x)]
            
a,o=map(int,input().split())
l=[list(map(int,input().split())) for i in range(o)]
g = get_unique_list(l)
c = sorted(g)
d = 0
b = len(c)
if not a==1 and c[0] == [1,0]:
 print(-1)
else:
  if not b==1:
   for k in range(b-1):
    if l[k][0] == l[k+1][0]:
     print(-1)
     break
   else:
    for j in range(b):
     if a < c[j][0]:
      print(-1)
      break
     d=d+(10**(a-c[j][0]))*c[j][1]
    else:
     print(d)
  else:
    print((10**(a-c[0][0]))*c[0][1])