n, m = [int(i) for i in input().split()]
s = []
c = []
for i in range(m):
    tmp = [int(j) for j in input().split()]
    s.append(tmp[0])
    c.append(tmp[1])

for i in range(10 ** (n - 1) ,10 ** n - 1):
    status = True
    for j in range(m):
        if(str(i)[s[j] - 1] != str(c[j])):
            status = False
    if(status):
        print(i)
        exit()
print(-1)
