n, m = map(int, input().split())
d = {}
for i in range(m):
    s, c = map(int, input().split())
    if s == 1 and c == 0 and n > 1:
        print(-1)
        exit(0)
    if s in d:
        if d[s] != c:
            print(-1)
            exit(0)
    else:
        d[s] = c
ans = ''
for i in range(1, n + 1):
    if i in d:
        ans += chr(ord('0') + d[i])
    elif i == 1:
        ans += '1'
    else:
        ans += '0'
print(ans)
