line = input().split()
N = int(line[0])
M = int(line[1])

hm = {}

for i in range(M):
    line = input().split()
    hm[int(line[0])] = int(line[1])

s = sorted(hm.items(), key=lambda item: item[0], reverse=True)
num = 0
place = 1
for i in reversed(range(N)): 
    dig = hm.get(i+1, 0)
    num += dig * place
    place *= 10

if num > place / 10:
    print(num)
else:
    print(-1)