import sys
input = sys.stdin.readline

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

score=[-1]*N

for i in range(M):
    s,c=map(int,input().split())
    s-=1

    if score[s]==-1 or score[s]==c:
        score[s]=c
    else:
        print(-1)
        sys.exit()
    
if N>1 and score[0]==0:
    print(-1)
    sys.exit()

for i in range(N):
    if score[i]==-1:
        score[i]=0

if max(score)==0 and N>1:
    score[0]=1

print("".join(map(str,score)))
