n, m = map(int, input().split())

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

if ans[0] == 0:
    print(-1)
    exit()

if ans[0] == -1:
    ans[0] = 1
for i in range(1, n):
    if ans[i] == -1:
        ans[i] = 0

print(*ans, sep='')