N, M = map(int, input().split())
cond = [list(map(int, input().split())) for _ in range(M)]
flag = True
ans = [-1]*N

if M == 0:
    if N == 1:
        print(0)
    else:
        print('1'+'0'*(N-1))
else:
    for i in cond:
    digit = i[0]-1
    if digit > N-1:
        flag = False
        break
    elif ans[digit] != -1 and ans[digit] != i[1]:
        flag = False
        break
    elif i == [1, 0] and N > 1:
        flag = False
        break
    else:
        ans[digit] = i[1]

    if flag:
        if ans[0] == -1:
            ans[0] = 1
        
        for i in range(1, N):
            if ans[i] == -1:
                ans[i] = 0
        
        print(''.join(map(str, ans)))
    else:
        print(-1)