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

l = []
for i in range(n):
    l.append(-1)

for i in range(m):
    digit, num = map(int, input().split())
    if digit > n:
        print(-1)
        exit()
    elif l[digit - 1] != -1 and l[digit - 1] != num: 
        print(-1)
        exit()
    else:
        l[digit - 1] = num

if l[0] == 0:
    print(-1)
    exit()
else:
    for i in range(n):
        if i == 0 and l[i] == -1: l[i] == 1
        elif l[i] == -1: l[i] = 0
print(''.join(map(str, l)))

