digits_num, count = map(int, input().split())

if count == 0:
    ans = '-1'
else:
    ans = 'X' * digits_num

    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 ans[target - 1] == 'X':
            ans = ans[:target - 1] + str(num) + ans[target:]
        elif ans[target - 1] == str(num):
            pass
        else:
            ans = '-1'
            break

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