#graph implementation
import math
n,m=map(int,input().split())
ans=[0]*n
flag=False
for i in range(m):
    s,c=map(int,input().split())
    ans[s-1]=c
    if s-1==0:
        flag=True
#print(ans)
if not flag:
    ans[0]=1
if ans[0]==0 and n>1:
    print(-1)
else:
    for i in ans:
        print(i,end="")
print()
