n,m=map(int,input().split())
max_value=10**n
min_value=10**(n-1)

s,c=[],[]

for _ in range(m):
    a,b=map(int,input().split())
    a-=1
    s.append(a)
    c.append(b)
        
for i in range(min_value,max_value):

    f=True    
    #print(i)
    for j in range(m):
        
        if str(i)[s[j]] == str(c[j]):
            pass
        else:
            f=False

    if f == True:
        print(i)
        exit()
    f=True

print(-1)