N,M  = (int(x) for x in input().split())
Num  = list('?'*N)
Flag = 1

for T in range(0,int(M)):
    s,c = input().split()
    if (Num[int(s)-1]!='?' and Num[int(s)-1]!=c) or (s=='1' and c=='0'):
        Flag = 0
        break
    else:
        Num[int(s)-1] = c
        
if Flag:
    if Num[0]=='?':
        Num[0] = '1'
        Num = ['0' if x=='?' else x for x in Num]
    else:
        Num = ['0' if x=='?' else x for x in Num]
    print(''.join(Num))
else:
    print('-1')