n, m = list(map(int, input().split(' ')))
pairs = []

for i in range(m):
    pairs.append(list(map(int, input().split(' '))))

num = [-1 for i in range(n)]

for pair in pairs:
    s, c = pair

    if (num[s-1] != -1 and num[s-1] != c) or (s == 1 and c == 0):
        print(-1)
        exit(0)
    else:
        num[s-1] = c

for i in range(n):
    if num[i] == -1:
        num[i] = 0 if i != 0 else 1

print(''.join([str(i) for i in num]))
