n,m=map(int, input().split())
sc = []
if m==0:
    print(10**(n-1))
    exit()
for i in range(m):
    a,b=map(int, input().split())
    sc.append([a, b])
for i in range(1,10**n):
    t = str(i)
    f=True
    for j in sc:
        if len(t)!=n:
            f=False
            break
        if t[j[0]-1]==str(j[1]):
            continue
        else:
            f=False
            break
    if f:
        print(i)
        exit()
print(-1)
