function Main(input){
  let data = input.split('\n');
  let arr, row, col;
  for (let i = 0; i < data.length; i++){
    arr = data[i].split(' ');
    row = arr[0];
    col = arr[1];
    if (row === '0' && col === '0'){
      break;
    }
    let s ='';
    let t = '';
    for (let j = 0; j < col; j++){
      s += "#";
      if (j === 0){
      t += "#";
      } else if (j === col -1) {
        t += "#";
        break;
      } else{
        t+='.';
      }
    }
    for (let k = 0; k < row; k++){
      if(k === 0){
        console.log(s);
      } else if (k === row - 1){
        console.log(s);
        break;
      } else {
        console.log(t);
      }      
    }
    console.log('');
    }
  }

Main(require("fs").readFileSync("/dev/stdin", "utf8"));
