N,M = input().split()
N = int(N)
M = int(M)
ans = ["-" for _ in range(N)]
ss = []
for _ in range(M):
    s,c = input().split()
    s = int(s)
    if ans[s-1] == c or ans[s-1] == '-':
        ans[s-1] = c
    else:
        ans[s-1] = "="
ans = "".join(ans)
ans = ans.replace("-","0")
if ans[0] == "0" and N >= 2:
    print(-1)
elif ans.find("=") != -1:
    print(-1)
else:
    print(ans)     