#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <complex>
#include <vector>
#include <cstdio>
using namespace std;
#define ll long long
#define N 100
char mp[N][N];
int l,w,n;
struct line
{
int sx,sy;
int ex,ey;
}lol[N];
int x[N*2],y[N*2],cnt=0;
void clear(){
for(int i=1 ; i<=l ;i++)
for(int j=1 ; j<=w ;j++ )
mp[i][j]='.';
}
void draw_show(){
for(int i=1 ;i<= n ;i++){
int sx=lol[i].sx,sy=lol[i].sy,ex=lol[i].ex,ey=lol[i].ey;
if(sx==ex){
for(int j=min(sy,ey) ; j<=max(sy,ey) ; j++)
mp[sx][j]='#';
}
else{
for(int j=min(sx,ex) ; j<=max(sx,ex) ; j++)
mp[j][sy]='#';
}
}
for(int i=1 ; i<=l ;i++)
for(int j=1 ; j<=w ;j++ )
printf("%c%c",mp[i][j],j==w?'\n':' ');
}
void change(){
int cc=0;
for(int i=1 ;i <=n ;i++){
lol[i].sx=x[++cc],lol[i].sy=y[cc];
lol[i].ex=x[++cc],lol[i].ey=y[cc];
}
}
int compress(int *x,int l){
int tk[N+N],fk=0;
for(int i=1 ; i<=cnt ;i++)
for(int j=-1 ;j<=1 ;j++){
if(x[i]+j>=1 && x[i]+j<= l){
tk[fk++]=x[i]+j;
}
}
sort(tk,tk+fk);
int size=unique(tk,tk+fk)-tk;
for(int i=1 ;i<=cnt ;i++)
x[i] = lower_bound(tk,tk+size,x[i])-tk +1 ;
return size;
}
int main(){
while(~scanf("%d%d",&l,&w) ){
memset(mp,0,sizeof(mp));
cout<<"line's number and their start pots ans ends pots"<<endl;
cin>>n;cnt=0;
for(int i=1 ;i<= n ;i++){
cin>>lol[i].sx>>lol[i].sy>>lol[i].ex>>lol[i].ey;
x[++cnt]=lol[i].sx,y[cnt]=lol[i].sy;
x[++cnt]=lol[i].ex,y[cnt]=lol[i].ey;
}
clear();
draw_show();
puts("________________________________");
l=compress(x,l);
cout<<" l = "<<l<<endl;
w=compress(y,w);
cout<<" w = "<<w<<endl;
change();
clear();
draw_show();
}
return 0;
}