n,m = map(int,input().split())
L = []
for i in range(m):
    a,b = map(int,input().split())
    L.append((a,b))
#print(L)
for i in range(1000):
    s = str(i)
    flag = False
    if len(s) == n:
        for j in range(m):
            
            if s[L[j][0]-1] == str(L[j][1]):
                flag = True
            else:
                flag = False
                break
        if flag:
            print(s)
            exit()
print(-1)