n, m = map(int,input().split())
li = []
for _ in range(m):
    li.append(list(map(int,input().split())))
li = list(map(list, set(map(tuple, li))))
li = sorted(li)
number = 0
for i in range(len(li)-1):
    if li[i][0] == li[i+1][0]:
        print(-1)
        exit()
    else:
        number += li[i][1] * (10 ** (n-li[i][0])    )
number += li[len(li)-1][1] * (10 ** (n-li[len(li)-1][0])    )
if li[0][0] == 1 and li[0][1] == 0 and n >= 2:
    print(-1)
    exit()
print(number)