digits_num, count = map(int, input().split())
ans = 'X' * digits_num
replace_history = []

for i in range(count):
    target, num = map(int, input().split())

    if target == 1 and num == 0 and digits_num != 1:
        ans = '-1'
        break
    elif str(target) + str(num) in replace_history:
        pass
    elif ans[target - 1] != 'X':
        ans = '-1'
        break
    else:
        ans = ans[:target - 1] + str(num) + ans[target:]
        replace_history.append(str(target) + str(num))

if 'X' in ans:
    if ans[0] == 'X':
        ans[0] == '1'
    
    ans = ans.replace('X', '0')

print(ans)