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

tb = {}
for i in range(m):
    if s[i] in tb:
        if tb[s[i]] != c[i]:
            print("-1")
            exit(0)
    tb[s[i]] = c[i]

ans = ''
for i in range(1, n + 1):
    if i in tb:
        ans += str(tb[i])
    else:
        if i == 1:
            ans += '1'
        else:
            ans += '0'
print(ans)
