import sys

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N, M = lr()
num = [None] * (N+1)
for _ in range(M):
    s, c = lr()
    if s == 1 and c == 0:
        print(-1); exit()
    if num[s] and num[s] != c:
        print(-1); exit()
    num[s] = c

for i in range(1, N+1):
    if num[i] is None:
        if i == 0:
            num[0] = 1
        else:
            num[i] = 0

num_string = ''.join(map(str, num[1:]))
answer = int(num_string)
print(answer)
