#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;

int main () {
  int S;
  cin >> S;
  for( int s=1; s<=S; s++ ){
    cout << "Scenario #" << s << ":" << endl;
    
    //--- Listen.
    int n, m;
    cin >> n >> m;
    vector<string> v( n, string( n, '?' ));
    while( m-- ){
      int i, j;
      cin >> i >> j;
      v[i-1][j-1] = '*';
    }
    
    //--- Dress.
    int qb=0, qe=1, iq[99999], jq[99999];
    iq[0] = jq[0] = n/2;
    
    //--- Dance...
    while( qe > qb ){
      int I = iq[qb], J = jq[qb++];
      v[I][J] = '.';
      for( int k=0; k<2; k++ )
	for( int i=max(I-1,0); i<min(I+2,n); i++ )
	  for( int j=max(J-1,0); j<min(J+2,n); j++ )
	    if( k  &&  v[i][j] == '?' )
	      v[i][j] = ' ', iq[qe] = i, jq[qe++] = j;
	    else if( v[i][j] == '*' )
	      v[I][J] = '#', k=i=j=n;
    }
    
    //--- Answer.
    for( int i=0; i<n; i++ )
      cout << v[i] << endl;
    cout << endl;
  }
}
