N,M=map(int,input().split())
n=['0']*N
for i in range(M):
    s,c=map(str,input().split())
    S.append(s)
    if n[int(s)-1]!='0' and n[int(s)-1]!=c:
        print(-1)
        exit()
    if s=='1' and c=='0':
        print(-1)
        exit()
    n[int(s)-1]=c
if n[0]=='0':
    n[0]='1'
print(''.join(n))