N,M = map(int,input().split())
guess_list = [0]*N
for i in range(M):
    s,c = map(int,input().split())
    if guess_list[s-1] != 0 and guess_list[s-1] != c:
        print('-1')
        break
    elif s == 1 and c == 0:
        print('-1')
        break
    else:
        guess_list[s-1] = c
else:
    if guess_list[0] == 0:
        guess_list[0] = 1
    guess_list = map(str,guess_list)
    print(''.join(guess_list))

    