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

NN = ['A']*N
mujun = 0

for m in range(M):
    si,ci = map(int,input().split())
    if NN[si-1] == 'A':
        NN[si-1] = ci
    else:
        if NN[si-1] == ci:
            pass
        else:
            mujun = 1
            break
            
if mujun == 0:
    AA = []
    for n in range(N):
        if n == 0:
            if NN[n] == 'A':
                AA.append('1')
            else:
                AA.append(str(NN[n]))
        else:
            if NN[n] == 'A':
                AA.append('0')
            else:
                AA.append(str(NN[n]))

    if AA[0] == '0' and len(AA) > 1:
        mujun = 1
    
if mujun == 1:
    print('-1')
else:
    print(''.join(AA))