import numpy as np

n, m = np.asarray(input().split(), dtype=np.int32)

if n == 1:
    ans = "0"
    check = "0"
elif n == 2:
    ans = "10"
    check = "00"
else:
    ans = "100"
    check = "000"
ans = list(ans)
check = list(check)
for i in range(m):
    s, c = np.asarray(input().split(), dtype=np.int32)
    s -= 1
    if check[s] == "0":
        ans[s] = str(c)
        check[s] = "1"
    else:
        if ans[s] != str(c):
            print(-1)
            break

    if i+1 == m:
        if n > 1 and ans[0] == "0":
            print(-1)
            break
        print("".join(ans))
