n, m = map(int, input().split(' '))
sayi = []
for i in range(n):
    sayi.append('*')

for i in range(m):
    s, t = map(int, input().split(' '))
    if n >= 2 and s == 1 and t == 0:
        print(-1)
        exit()
    if sayi[s-1] == "*" or sayi[s-1] == str(t):
        sayi[s-1] = str(t)
    else:
        print(-1)
        exit()
for i in range(len(sayi)):
    if sayi[i] == '*':
        if i == 0:
            sayi[i] = '1'
        else:
            sayi[i] = '0'
print(''.join(sayi))