n,m = map(int,input().split())

s_li=[0]*m
l_li=[0]*m
for i in range(m):
    s_li[i],l_li[i] = map(int,input().split())

for i in range(1,1000):
    string = str(i)
    if len(string)!=n:
        continue
    flag=True
    for j in range(m):
        if int(string[s_li[j]-1])==l_li[j]:
            continue
        flag=False
        break
    if flag:
        print(string);exit()
print(-1)
    


