n, m = map(int, input().split())
ans = [-1] * n

headdef = cant = 0
for i in range(m):
        s, c = map(int, input().split())
        if ans[s-1]<0: ans[s-1] = c
        elif ans[s-1]!=c: cant = 1
        if s==1: headdef = 1
for i in range(n):
        if ans[i]==-1: ans[i]=0

if ans[0]==0:
        if headdef: cant = 1
        else: ans[0] = 1

if cant: print(-1)
else: print("".join(map(str, ans)))