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:
        # 複数桁の場合に先頭を0で置き換えるのはNG
        ans = '-1'
        break
    elif str(target) + str(num) in replace_history:
        # 同じ置き換えの場合は処理しない
        pass
    elif ans[target - 1] != 'X':
        # 既に置き換え済みの位置を再度別数字に置き換えるのはNG
        ans = '-1'
        break
    else:
        ans = ans[:target - 1] + str(num) + ans[target:]
        replace_history.append(str(target) + str(num))
 
if ans[0] == 'X':
    ans = '1' + ans[1:]

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