n, m = [int(i) for i in input().split()]
a = [-1] * n
for i in range(m):
    s, c = [int(i) for i in input().split()]
    s -= 1
    if a[s] != -1 and a[s] != c:
        print(-1)
        exit()
    a[s] = c

if n == 1:
    if a[0] == -1:
        print(-1)
        exit()
else:
    if a[0] == 0:
        print(-1)
        exit()
    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)))
