n, m = map(int, input().split())
d = dict()
for i in range(m):
    s, c = map(int, input().split())
    if s==1 and c==0:
        print("-1")
        exit()
    if s in d.keys():
        print("-1")
        exit()
    d[s] = c
target = 0
all = set(range(1,n+1))
kouho = set(d.keys())
dif = all - kouho
for s, c in d.items():
    target += 10**(n-s)*c
if n in dif:
    print(100+target)
else:
    print(target)