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

    