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

for i in range(n):
    ans += "x"

pf = True
for i in range(m):
    s,c = map(int,input().split())
    if (not ans[s] == "x") and (not ans[s] == str(c)):
        print(-1)
        pf = False
        break
    else:
        ans[s] = str(c)

if pf:
    if ans[0] == "x":
        ans[0] = "1"
    for i in range(n):
        if ans[i] == "x":
            ans[i] = "0"
print(ans)
