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 ANS[cs[0]-1] == 'N':
        ANS[cs[0]-1] = str(cs[1])
        continue
    if ANS[cs[0]-1] != str(cs[1]):
        print(-1)
        exit()
for i in range(N):
    if i == 0 and ANS[i] == 'N':
        ANS[0] = '1'
        continue
    if ANS[i] == 'N':
        ANS[i] = '0'
if ANS[0] == '0':
    print(-1)
    exit()  
print(''.join(ANS))