N,M = map(int,input().split())
s = [0]*M
c = [0]*M
ans = ["0"]*N
for i in range(M):
    s[i],c[i] = map(int,input().split())

for i in range(M):
    ans[s[i]-1] = str(c[i])

if (ans[0] == "0"):
    if (N == 1):
        print(0)
    else:
        print(-1)
else:
    print("".join(ans))