import java.util.Scanner;
public class Test {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int h = scanner.nextInt();
int w = scanner.nextInt();
System.out.print("*");
for (int i = 0; i < w - 2; i++) {
System.out.print("-");
}
System.out.println("*");
for (int i = 0; i < h - 2; i++) {
System.out.print("|");
for (int j = 0; j < w - 2; j++) {
System.out.print(" ");
}
System.out.println("|");
}
System.out.print("*");
for (int i = 0; i < w - 2; i++) {
System.out.print("-");
}
System.out.println("*");
}
}