n,m = map(int, input().split())

judge = True

a = [-1]*n

for i in range(m):
    s,c = map(int, input().split())
    if (a[s-1]==-1) or (a[s-1]==c):
        a[s-1] = c
        if (s==1) and (c==0):
            judge = False
    else:
        judge = False

if judge:
    if a[0] == -1:
        a[0] = 1
    
    for i in range(1,n):
        if a[i] == -1:
            a[i] = 0
    
    print(''.join(map(str, a)))

else:
    print(-1)