Problem:
Score : 200 points

Problem Statement

You are given a image with a height of H pixels and a width of W pixels.
Each pixel is represented by a lowercase English letter.
The pixel at the i-th row from the top and j-th column from the left is a_{ij}.

Put a box around this image and output the result. The box should consist of # and have a thickness of 1.

Constraints

1 ≤ H, W ≤ 100

a_{ij} is a lowercase English letter.

Input

Input is given from Standard Input in the following format:

H W
a_{11} ... a_{1W}
:
a_{H1} ... a_{HW}

Output

Print the image surrounded by a box that consists of # and has a thickness of 1.

Sample Input 1

2 3
abc
arc

Sample Output 1

#####
#abc#
#arc#
#####

Sample Input 2

1 1
z

Sample Output 2

###
#z#
###

Solution in C (GCC 5.4.1) (judge verdict: Accepted)

#define _GLIBCXX_DEBUG

#include <unistd.h>
#include <stdlib.h>

void get_nums(int *array, char *s, int count)
{
    int num;
    int i;
    int j;
    
    i = -1;
    while (s[++i] != 10)
    {
        if (s[i] != 32)
        {
            num = 0;
            while ('0' <= s[i] && s[i] <= '9')
            {
                num = num * 10 + s[i++] - '0';
                if (!s[i])
                {
                    array[count++] = num;
                    return ;                    
                }
            }
            array[count++] = num;
            i--;
        }
    }  
}

void get_stirngs(char *s, char *tmp, int pass_flag, int count)
{
    int i;
    int j;
    
    i = -1;
    while (count < pass_flag)
    {
        while (tmp[++i] != 10)
            ;
        count++;
    }
    j = 0;
    while (tmp[++i] != 10)
    {
        while (31 < tmp[i] && tmp[i] < 127)
        {
            s[j++] = tmp[i++];
            if (!tmp[i])
            {
                s[j] = 0;
                return ;                    
            }
        }
        s[j] = 0;
        i--;
    }  
}

void get_ans(int x, int y, char *tmp)
{
    int i;
    int j;
    char s[x + 1];
    
    j = -1;
    while (++j < y + 2)
    {
        if (0 < j  && j <= y)
            get_stirngs(s, tmp, j, 0);
        i = -1;
        while (++i < x + 2)
        {
            if (0 < j  && j <= y && 0 < i && i <= x)
                write(1, &s[i - 1], 1);
            else
                write(1, "#", 1);
        }
        write(1, "\n", 1);
    }
}

char *create_array(char *s, char *new_arr, char *t, int size)
{
    int i;
    int j;
    
    i = -1;
    while (s[++i])
        new_arr[i] = s[i];
    free(s);
    j = -1;
    while (++j < size)
        new_arr[i++] = t[j];   
    new_arr[i] = 0;
    return (new_arr);
}

char *get_data(char *s)
{
    int size;
    int sum_size;
    char t[5];
    char *new_arr;
    
    sum_size = 0;
    while ((size = read(0, t, 5)))
    {
        if (size == -1)
            return (NULL);
        sum_size += size;
        if (!(new_arr = (char*)malloc(sum_size + 1)))
            return (NULL);
        s = create_array(s, new_arr, t, size);
    }
    return (s);
}

int main(void){
    int num[2];
    char *s;
    
    s = malloc(1);
    s = get_data(s);
    
    //printf("%s\n\n",s);
    //write(1,s,6);
    get_nums(num, s, 0);
    //printf("num[0]=%d,num[1]=%d\n",num[0],num[1]);
    get_ans(num[1],num[0], s);
    return (0);
}