N, M = map(int, input().split())

if M == 0:
    if N == 1:
        print(0)
    elif N == 2:
        print(10)
    else:
        print(100)

else:
    a = [0]*N
    b = [0]*N
    for i in range(M):
        s, c = map(int, input().split())
        d = a[s-1]
        if s == 1 and c == 0 and N!=1:
            print("-1")
            break
        if b[s-1] == 0:
            a[s-1] = c
        else:
            a[s-1] = min(a[s-1], c)

    if N ==1:
        print(*a, sep="") 
    else:
        if a[0] == 0:
            a[0] = 1
        print(*a, sep="") 