import sys
n, m = map(int, input().split())
num = [-1 for i in range(n)]
for i in range(m):
    s, c = map(int, input().split())
    s -= 1
    if num[s] != -1 and c != num[s]:
        print(-1)
        sys.exit()
    num[s] = c
if num[0] == 0 and n == 1:
    print(0)
elif num[0] == 0:
    print(-1)
elif n == 1 and s[0] == -1:
    print(0)
else:
    num[0] = max(num[0], 1)
    for i in range(1, n):
        num[i] = max(num[i], 0)
    print(''.join([str(i) for i in num]))