N,M = map(int, input().split())
rules = [list(map(int, input().split())) for i in range(M)]
ans = '-1'
num = '0'*N

for rule in rules:
    num = num[:rule[0]-1] + str(rule[1]) + num[rule[0]:]

if num[0] != '0':
    ans = num

print(ans)