N, M = list(map(int, input().split(' ')))

num_list = [-1 for i in range(N)]

false_flag = False

sc = []
for i in range(M):
    sc.append(list(map(int, input().split(' '))))

for i in range(M):
    s, c = sc[i][0], sc[i][1]

    if num_list[s-1] == -1:
        num_list[s-1] = c
    else:
        if num_list[s-1] == c:
            continue
        else:
            false_flag = True
            break
if num_list[0] == 0:
    false_flag = True

if false_flag == False:
    for i in range(N):
        if num_list[i] == -1:
            if i == 0:
                num_list[0] = 1
            else:
                num_list[i] = 0
    print(*num_list, sep='')
else:
    print(-1)