import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String args[]) throws IOException{
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		StringBuilder builder = new StringBuilder();
		while(true){
			String data[] = reader.readLine().split(" ");
			int a= Integer.parseInt(data[0]);
			int b= Integer.parseInt(data[1]);
			
			if(a==0 && b==0)
				break;
			
			for(int y=0; y<a; y++){
				for(int x=0; x<b; x++){
					builder.append(y==0||y==a-1||x==0||x==b-1? "#" : ".");
				}
				builder.append("\n");
			}
			builder.append("\n");
		
		}
		System.out.print(builder);
	}
} import java.io.BufferedReader; BufferedReader java.io import java.io.IOException; IOException java.io import java.io.InputStreamReader; InputStreamReader java.io public class Main {
	public static void main(String args[]) throws IOException{
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		StringBuilder builder = new StringBuilder();
		while(true){
			String data[] = reader.readLine().split(" ");
			int a= Integer.parseInt(data[0]);
			int b= Integer.parseInt(data[1]);
			
			if(a==0 && b==0)
				break;
			
			for(int y=0; y<a; y++){
				for(int x=0; x<b; x++){
					builder.append(y==0||y==a-1||x==0||x==b-1? "#" : ".");
				}
				builder.append("\n");
			}
			builder.append("\n");
		
		}
		System.out.print(builder);
	}
} Main public static void main(String args[]) throws IOException{
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		StringBuilder builder = new StringBuilder();
		while(true){
			String data[] = reader.readLine().split(" ");
			int a= Integer.parseInt(data[0]);
			int b= Integer.parseInt(data[1]);
			
			if(a==0 && b==0)
				break;
			
			for(int y=0; y<a; y++){
				for(int x=0; x<b; x++){
					builder.append(y==0||y==a-1||x==0||x==b-1? "#" : ".");
				}
				builder.append("\n");
			}
			builder.append("\n");
		
		}
		System.out.print(builder);
	} main {
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		StringBuilder builder = new StringBuilder();
		while(true){
			String data[] = reader.readLine().split(" ");
			int a= Integer.parseInt(data[0]);
			int b= Integer.parseInt(data[1]);
			
			if(a==0 && b==0)
				break;
			
			for(int y=0; y<a; y++){
				for(int x=0; x<b; x++){
					builder.append(y==0||y==a-1||x==0||x==b-1? "#" : ".");
				}
				builder.append("\n");
			}
			builder.append("\n");
		
		}
		System.out.print(builder);
	} BufferedReader reader = new BufferedReader(new InputStreamReader(System.in)); reader new BufferedReader(new InputStreamReader(System.in)) StringBuilder builder = new StringBuilder(); builder new StringBuilder() while(true){
			String data[] = reader.readLine().split(" ");
			int a= Integer.parseInt(data[0]);
			int b= Integer.parseInt(data[1]);
			
			if(a==0 && b==0)
				break;
			
			for(int y=0; y<a; y++){
				for(int x=0; x<b; x++){
					builder.append(y==0||y==a-1||x==0||x==b-1? "#" : ".");
				}
				builder.append("\n");
			}
			builder.append("\n");
		
		} true {
			String data[] = reader.readLine().split(" ");
			int a= Integer.parseInt(data[0]);
			int b= Integer.parseInt(data[1]);
			
			if(a==0 && b==0)
				break;
			
			for(int y=0; y<a; y++){
				for(int x=0; x<b; x++){
					builder.append(y==0||y==a-1||x==0||x==b-1? "#" : ".");
				}
				builder.append("\n");
			}
			builder.append("\n");
		
		} String data[] = reader.readLine().split(" "); data reader.readLine().split(" ") reader.readLine().split reader.readLine() reader.readLine reader " " int a= Integer.parseInt(data[0]); a Integer.parseInt(data[0]) Integer.parseInt Integer data[0] data 0 int b= Integer.parseInt(data[1]); b Integer.parseInt(data[1]) Integer.parseInt Integer data[1] data 1 if(a==0 && b==0)
				break; a==0 && b==0 a==0 a 0 b==0 b 0 break; for(int y=0; y<a; y++){
				for(int x=0; x<b; x++){
					builder.append(y==0||y==a-1||x==0||x==b-1? "#" : ".");
				}
				builder.append("\n");
			} int y=0; int y=0; y 0 y<a y a y++ y++ y {
				for(int x=0; x<b; x++){
					builder.append(y==0||y==a-1||x==0||x==b-1? "#" : ".");
				}
				builder.append("\n");
			} {
				for(int x=0; x<b; x++){
					builder.append(y==0||y==a-1||x==0||x==b-1? "#" : ".");
				}
				builder.append("\n");
			} for(int x=0; x<b; x++){
					builder.append(y==0||y==a-1||x==0||x==b-1? "#" : ".");
				} int x=0; int x=0; x 0 x<b x b x++ x++ x {
					builder.append(y==0||y==a-1||x==0||x==b-1? "#" : ".");
				} {
					builder.append(y==0||y==a-1||x==0||x==b-1? "#" : ".");
				} builder.append(y==0||y==a-1||x==0||x==b-1? "#" : ".") builder.append builder y==0||y==a-1||x==0||x==b-1? "#" : "." y==0||y==a-1||x==0||x==b-1 x==0 y==0||y==a-1||x==0||x==b-1 y==0 y 0 y==a-1 y a-1 a 1 x==0 x 0 x==b-1 x b-1 b 1 "#" "." builder.append("\n") builder.append builder "\n" builder.append("\n") builder.append builder "\n" System.out.print(builder) System.out.print System.out System System.out builder String args[] args public class Main {
	public static void main(String args[]) throws IOException{
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		StringBuilder builder = new StringBuilder();
		while(true){
			String data[] = reader.readLine().split(" ");
			int a= Integer.parseInt(data[0]);
			int b= Integer.parseInt(data[1]);
			
			if(a==0 && b==0)
				break;
			
			for(int y=0; y<a; y++){
				for(int x=0; x<b; x++){
					builder.append(y==0||y==a-1||x==0||x==b-1? "#" : ".");
				}
				builder.append("\n");
			}
			builder.append("\n");
		
		}
		System.out.print(builder);
	}
} public class Main {
	public static void main(String args[]) throws IOException{
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		StringBuilder builder = new StringBuilder();
		while(true){
			String data[] = reader.readLine().split(" ");
			int a= Integer.parseInt(data[0]);
			int b= Integer.parseInt(data[1]);
			
			if(a==0 && b==0)
				break;
			
			for(int y=0; y<a; y++){
				for(int x=0; x<b; x++){
					builder.append(y==0||y==a-1||x==0||x==b-1? "#" : ".");
				}
				builder.append("\n");
			}
			builder.append("\n");
		
		}
		System.out.print(builder);
	}
} Main
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String args[]) throws IOException{
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		StringBuilder builder = new StringBuilder();
		while(true){
			String data[] = reader.readLine().split(" ");
			int a= Integer.parseInt(data[0]);
			int b= Integer.parseInt(data[1]);
			
			if(a==0 && b==0)
				break;
			
			for(int y=0; y<a; y++){
				for(int x=0; x<b; x++){
					builder.append(y==0||y==a-1||x==0||x==b-1? "#" : ".");
				}
				builder.append("\n");
			}
			builder.append("\n");
		
		}
		System.out.print(builder);
	}
}