N, M = map(int, input().split())
if M == 0:
    if N == 1:
        print(0)
    elif N == 2:
        print(10)
    else:
        print(100)
    exit()

rule = dict()
for _ in range(M):
    s, c = map(int, input().split())
    if rule.get(s, None) is not None:
        if rule.get(s) == c:
            continue
        else:
            print(-1)
            exit()
    else:
        rule[s] = c
# print(rule)

if rule.get(1) == 0:
    print(-1)
    exit()

v = []
for i in range(1, N + 1):
    if rule.get(i) is not None:
        v.append(str(rule.get(i)))
    else:
        if i == 1:
            v.append('1')
        else:
            v.append('0')
print(''.join(v))
