N,M = map(int,input().split())

flag = False

number = [-1 for i in range(N)]

for i in range(M):
    s,c = map(int,input().split())
    if number[s-1] == c or number[s-1] == -1:
        number[s-1] = c
    else:
        flag = True

if flag or number[0] == 0:
    print(-1)
else:
    # -1が入っている場合、最上位は1で計算
    for i in range(N):
        if number[i] == -1:
            if i == 0:
                number[i] = 1
            else:
                number[i] = 0
    print(''.join(map(str,number)))