#include <bits/stdc++.h>
int main(void) {
  int H, W, a, b, k = 0;
  while (k != -1) {
    scanf("%d %d", &H, &W);
    if (H == 0 && W == 0) {
      break;
    }
    for (a = 1; a <= H; a++) {
      for (b = 1; b <= W; b++) {
        if (b == 1 || b == W || a == 1 || a == H) {
          printf("#");
        } else {
          printf(".");
        }
      }
      printf("\n");
    }
    printf("\n");
  }
  return 0;
}
