n,m=[int(i) for i in input().split()]
result=[0]*m
for i in range(m):
    re = input().split()
    result[int(re[0])-1] = int(re[1])

ans = ''
for i in result: ans+=str(i)

if ans[0] == '0': print(-1)
else: print(ans)

