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

d=["0"]*N

for i in range(M):
    d[int(s[i])-1]=c[i]
if N>=2 and int(d[0])==0:
    print(-1)
else:print("".join(d))