N,M = map(int,input().split())
s,c=[],[]
for _ in range(M):
    s_,c_ = map(int,input().split())
    s.append(s_)
    c.append(c_)

a,b=10**(N-1),10**N

for i in range(a,b):
    ok = True
    num = str(i)
    for k in range(M):
        if num[s[k]-1] != str(c[k]):
            ok = False
    if ok:
        print(i)
        exit()
print(-1)