N, M = [int(i) for i in input().split()]

V = 10**N
Q = {}

for _ in range(M):
    i, v = [int(i) for i in input().split()]
    i -= 1
    try:
        Q[i]==10
    except:
        Q[i] = v
    else:
        if Q[i]!=v:
            print(-1)
            quit()

for d in range(1, V):
    flag=True
    ds = str(d).zfill(N)
    if ds[0]=='0':
        continue
    for i, v in enumerate(ds):
        try:
            Q[i]==10
        except:
            pass
        else:
            if Q[i]!=int(ds[i]):
                flag=False
    if flag:
        print(ds)
        quit()
print(-1)