n,m= map(int,input().split())
num = [0] * n
num[0] = 1
qu = set()
ne=False
for i in range(m):
    s,c= map(int,input().split())
    if s in qu:
        if num[s-1]!=c:ne=True
    else:qu.add(s)
    if s==1 and c==0:ne=True
    num[s-1]=c
if ne:print(-1)
else:print(''.join([str(t) for t in num]))
