N, M = map(int,input().split())
num = [0,1,2,3,4,5,6,7,8,9]
ans = [str(i) for i in range(10**(N-1), 10**N)]
check = [1 for i in range(10**(N-1), 10**N)]
if N == 1:
    ans.insert(0,0)
    check.insert(0,1)

for i in range(M):
    s, c = map(int,input().split())
    s -= 1
    for idx, j in enumerate(ans):
        if j[s] != str(c):
            check[idx] = 0
for idx, i in enumerate(check):
    if i == 1:
        print(ans[idx])
        quit()
print(-1)