import itertools
import functools
import math
from collections import Counter
from itertools import combinations
import re

N,M=map(int,input().split())

ans = ["."] * N

for i in range(M):
    S,C=map(int,input().split())

    if ans[S-1] not in (-1,C):
        print(-1)
        exit()
    ans[S-1] = C

if N != 1 and ans[3-N] == "0":
    print(-1)
    exit()
cmp = re.compile("".join(ans))

for i in range(10**N):
    res = cmp.match(str(i))
    if res == True:
        print(i)

print(-1)
