n,m = map(int,input().split())
dig = [list(map(int,input().split())) for i in range(m)]

res = -1
for i in range(10**(n-1),1000):
#for i in range(700,705):
    s = str(i)
    ju = True
    for j in dig:
        if j[0] > len(s):
            ju = False
            break
        else:
            if int(s[j[0]-1]) == j[1]:
                continue
            else:
                ju = False
                break
    if ju:
        res = i
        break
print(res)