N, M = map(int, input().split())
num = [x for x in str(10**(N - 1))]
confirmed_or_not = [False] * N

for _ in range(M):
    s, c = map(int, input().split())
    if s > N:
        num = ['-1']
        break
    
    if s == 1 and c == 0:
        if N > 1:
            num = ['-1']
            break
        
    if confirmed_or_not[s-1] and num[s-1] != str(c):
        num = ['-1']
        break
        
    num[s - 1] = str(c)
    confirmed_or_not[s-1] = True


if N == 1 and not confirmed_or_not[0]:
    num = ['0']

print(*num)