digits_num, count = map(int, input().split())
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 ans[0] == 'X':
    ans = '1' + ans[1:]

if 'X' in ans:
    ans = ans.replace('X', '0')
 
print(ans)