import sys

N, M = [int(_) for _ in input().split()]
a = [-1 for i in range(N+1)]
for i in range(M):
    s, c = [int(_) for _ in input().split()]
    if s == 1 and c == 0:
        print(-1)
        sys.exit(0)
    if a[s] != -1:
        if c != a[s]:
            print(-1)
            sys.exit(0)
    else:
        a[s] = c

for i in range(1, N+1):
    if a[i] == -1:
        if i == 1:
            a[i] = 1
        else:
            a[i] = 0

print(*a[1:], sep='')
