N,M=map(int,input().split())
sc=[[int(i) for i in input().split()] for j in range(M)]
res=["x"]*N
flag=True
for s,c in sc:
    if N<s or res[s-1] not in ['x', str(c)]:
        flag=False
        break
    res[s-1]=str(c)
if len(res)>1 and res[0]=='0':flag=False
if not flag:
    print(-1)
else:
    if res[0]=='x':
        res[0] = '0' if len(res)==1 else '1'
    for i in range(1,N):
        if(res[i]=='x'):
            res[i]='0'
    print(''.join(res))
