N, M = map(int, input().split())
a = [0]*N
for i in range(M):
    s, c = map(int, input().split())
    d = a[s-1]
    if s == 1 and c == 0:
        print("-1")
        break
    if d != 0:
        a[s-1] = min(c, d)
    else:
        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:
        a[0] = 1
    print(*a, sep="") 