N,M = list(map(int,input().split()))
CS = [list(map(int,input().split())) for _ in range(M)]
ANS = ['N']*N
for cs in CS:
    if 0 >= cs[0] or cs[0] >= N+1 or (cs[0] == 1 and cs[1] == 0):
        print(-1)
        exit()
    if ANS[cs[0]-1] == 'N' or ANS[cs[0]-1] == str(cs[1]):
        ANS[cs[0]-1] = str(cs[1])
    else:
        print(-1)
        exit()
for i,ans in enumerate(ANS):
    if i == 0 and ans == 'N':
        ANS[i] = '1'
    elif ans == 'N':
        ANS[i] = '0'
print(''.join(ANS))