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