N, M = map(int, raw_input().split())

ans = ""
for i in range(N):
     ans = ans + "a"

ans = list(ans)
flag = True

for i in range(M):
     s, c = map(int, raw_input().split())
     if ans[s-1] == "a":
          ans[s-1] = c
     elif ans[s-1] != c:
          flag = False

if N == 1:
     if ans[0] == "a" or ans[0] == 0:
          print "0"
          exit()


new = ""
if ans[0] == "a":
     ans[0] = 1
for i in range(N):
     if ans[i] == "a":
          new = new+"0"
     else:
          new = new + str(ans[i])

if new[0] == "0":
     flag = False

if N == 1:
     if new[0] == 0:
          flag = True

if flag == True:
     print new
else:
     print "-1"
