#graph implementation
import math
n,m=map(int,input().split())
ans=[0]*n
for i in range(m):
    s,c=map(int,input().split())
    if ans[s-1]>=c:
        ans[s-1]=c
if ans[0]==0:
    print(-1)
else:
    for i in ans:
        print(i,end="")
print()
