while line!="":
line=line.split(" ")
n=int(line[0]);m=int(line[1])
snakemap=[["-" for x in range(n+2)]]
for i inrange(n):
snakemap.append(["|"]+[" " for x in range(n)]+["|"])
snakemap.append(["-" for x in range(n+2)])
line=ipt().split(" ")
x1=int(line[0]);y1=int(line[1])
for i inrange(1,m):
line=ipt().split(" ")
x2=int(line[0]);y2=int(line[1])
pstar(snakemap,x1,y1,x2,y2)
x1,y1=x2,y2
for i inrange(n+2):
print("".join(snakemap[i]))
line=ipt()