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

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

if num[0] != '0':
    ans = num
elif num[0] == '0' and N == 1:
    ans = '0'
    
for rule in rules:
    if rule[1] not in values:
        values.append(rule[1])
        idxes.append(rule[0])

idxes_set = set(idxes)
if len(idxes) != len(idxes_set):
    ans = '-1'

print(ans)