n,m = map(int,input().split())
sc = [list(map(int,input().split())) for _ in range(m)]
ret = -1
for i in range(10**n+1):
    x = str(i)
    if len(x)!=n:
        continue
    flg = True
    for s,c in sc:
        if x[s-1]!=str(c):
            flg = False
    if flg:
        ret = x
        break
print(ret)