n, *D  = [list(map(int, s.split())) for s in open(0)]
imp = 0
dic = dict()
D = sorted(D)
cond = []
for d in D:
    if n[0] != 1 and d[0] == 1 and d[1] == 0:
        imp += 1
    if d not in cond:
        cond.append(d)
        if d[0] in dic:
            imp += 1
        else:
            dic[d[0]] = d[1]

s = ""
if imp:
    print(-1)
else:
    for i in range(n[0]):
        if i + 1 in dic:
            s += str(dic[i+1])
        else:
            if i == 0:
                s += str(1)
            else:
                s += str(0)
    print(s)