N, M = map(int, input().split())
SC = [list(map(int, input().split())) for _ in range(M)]

A = [-1] * N
ok= True
for s, c in SC:
    i = s-1
    if A[i] != -1 and A[i] != c:
        ok = False
        break
    A[i] = c
if N > 1 and A[0]==0:
    ok = False
if ok:
    for i in range(N):
        if A[i] == -1:
            if i == 0:
                A[i] = 1
            else:
                A[i] = 0
    for s, c in SC:
        i = s-1
        if A[i] != c:
            ok = False
            break    
if ok:
    print(''.join(map(str, A)))
else:    
    print(-1)