N, M = map(int, input().split())
a = [0]*N
for i in range(M):
    s, c = map(int, input().split())
    a[s-1] = c
if N == 1:
    print(*a, sep="") 
elif a[0] == 0:
    print("-1")
else:
    print(*a, sep="")  