# -*- coding: utf-8 -*-
import sys


N,M=[int(i) for i in input().rstrip().split()]
sc_list=[[int(j) for j in input().split()] for i in range(M)]
#-----

ans=["x"]*N

Flag=True
for s,c in sc_list:
    if s == 1 and c == 0 and N != 1:
        print("-1")
        sys.exit()
    elif ans[s-1] != "x" and ans[s-1] != c:
        print("-1")
        sys.exit()
    else:
        ans[s-1] = c


if ans[0] == "x":
    ans[0] = 1

for i in range(1,len(ans)):
    if ans[i] == "x":
        ans[i] = 0

print(*ans,sep="")
