AtCoder Beginner Contest 062 - Picture Frame

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-----
2 3
abc
arc

-----Sample Output-----
#####
#abc#
#arc#
#####

Difficulty: EASY

Starter code:

Solutions:
(h, w) = list(map(int, input().split()))
top = '#'
top *= w + 2
print(top)
for i in range(h):
	tmp = input()
	print('#' + tmp + '#')
print(top)


(h, w) = map(int, input().split())
print('#' * (w + 2))
for _ in range(h):
	print('#' + str(input()) + '#')
print('#' * (w + 2))


(h, w) = map(int, input().split())
l = '#' * (w + 2)
print(l)
for i in range(h):
	tmp = input()
	print('#' + tmp + '#')
print(l)


(H, W) = map(int, input().split())
print('#' * (W + 2))
for i in range(H):
	str = input()
	print('#' + str + '#')
print('#' * (W + 2))


(h, w) = map(int, input().split())
b = ''.join(['#'] * (w + 2))
print(b)
for i in range(h):
	print('#' + input() + '#')
print(b)


(h, w) = map(int, input().split())
print('#' * (w + 2))
for i in range(h):
	print('#' + input().strip() + '#')
print('#' * (w + 2))


(H, W) = map(int, input().split())
a = ['#' * (W + 2)] + ['#' + input() + '#' for _ in range(H)] + ['#' * (W + 2)]
print('\n'.join(a))


(H, W) = map(int, input().split())
print('#' * (W + 2))
for _ in range(H):
	print('#' + input() + '#')
print('#' * (W + 2))


(h, w) = map(int, input().split())
fl = '#' * (w + 2)
print(fl)
for _ in range(h):
	s = '#' + input() + '#'
	print(s)
print(fl)


(H, W) = (int(T) for T in input().split())
print('#' * (W + 2))
for TH in range(0, H):
	print('#' + input() + '#')
print('#' * (W + 2))


(x, y) = input().split()
x = int(x)
y = int(y)
a = [input() for i in range(x)]
c = ''
for i in range(y + 2):
	c = c + '#'
print(c)
for i in range(x):
	print('#' + a[i] + '#')
print(c)


(h, w) = map(int, input().split())
print('#' * (w + 2))
for i in range(h):
	a = str(input())
	a = '#' + a + '#'
	print(a)
print('#' * (w + 2))


(h, w) = map(int, input().split())
print('#' * (w + 2))
for i in range(h):
	line = input()
	print(f'#{line}#')
print('#' * (w + 2))


(h, w) = map(int, input().split())
print('\n'.join(['#' * (w + 2)] + ['#' + input() + '#' for _ in range(h)] + ['#' * (w + 2)]))


(h, w) = map(int, input().split())
(s, a, x) = ('#' * (w + 1), '#', '#\n#')
for i in range(h):
	a += input() + x
print('#' + s, a + s, sep='\n')


(H, W) = map(int, input().split())
A = [input() for i in range(H)]
print('#' * (W + 2))
for a in A:
	print('#' + a + '#')
print('#' * (W + 2))


(h, w) = [int(x) for x in input().split()]
c = '#'
s = c * (w + 2)
print(s)
for _ in range(h):
	print(c + input() + c)
print(s)


(H, W) = list(map(int, input().split()))
res = []
for i in range(H + 2):
	if i == 0 or i == H + 1:
		l = '#' * (W + 2)
		res.append(l)
	else:
		a = input()
		a = '#' + a + '#'
		res.append(a)
for i in res:
	print(i)


(h, w) = map(int, input().split())
print('#' * -~-~w)
for _ in [0] * h:
	print('#' + input() + '#')
print('#' * -~-~w)


(a, b) = map(int, input().split())
s = '#' * (b + 2)
print(s)
for i in range(a):
	t = input()
	t = '#' + t + '#'
	print(t)
print(s)


(h, w) = map(int, input().split())
a = ['#' * (w + 2)] + ['#' + input() + '#' for i in range(h)] + ['#' * (w + 2)]
print(*a, sep='\n')


(h, w) = [int(v) for v in input().split()]
print('#' * (w + 2))
for i in range(h):
	print('#' + input() + '#')
print('#' * (w + 2))


(H, W) = map(int, input().split())
ls = [['#' for _ in range(W + 2)]]
for _ in range(H):
	A = ['#'] + list(input()) + ['#']
	ls.append(A)
ls.append(['#' for _ in range(W + 2)])
for i in range(H + 2):
	print(''.join(ls[i]))


import sys, math
from itertools import combinations as c, product as p
from collections import deque
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

def si():
	return input()

def ii():
	return int(input())

def fi():
	return float(input())

def lstr():
	return input().split()

def lint():
	return list(map(int, input().split()))

def lintdec():
	return list(map(lambda x: int(x) - 1, input().split()))

def lnstr(n):
	return [input() for _ in range(n)]

def lnint(n):
	return [int(input()) for _ in range(n)]

def lint_list(n):
	return [lint() for _ in range(n)]
(H, W) = lint()
ans = ['#' * (W + 2)]
for _ in range(H):
	ans.append('#' + input() + '#')
ans.append('#' * (W + 2))
print('\n'.join(ans))


(n, m) = map(int, input().split())
print(*['#' * (m + 2)] + ['#' + input() + '#' for _ in range(n)] + ['#' * (m + 2)], sep='\n')


(H, W) = map(int, input().split())
s = '#' * (W + 2)
data = []
data.append(s)
for i in range(H):
	data.append('#' + str(input()) + '#')
data.append(s)
for i in range(H + 2):
	print(data[i])


(x, y) = map(int, input().split())
print('#' * (y + 2))
for i in range(x):
	print('#' + input() + '#')
print('#' * (y + 2))


(h, w) = map(int, input().split())
x = '#' * (w + 2)
print(x)
for i in range(h):
	s = input()
	print('#' + s + '#')
print(x)


(h, w) = list(map(int, input().split()))
a = [input() for _ in range(h)]
ans = ['#' * (w + 2)]
for i in range(h):
	ans.append('#' + a[i] + '#')
ans.append('#' * (w + 2))
for i in range(h + 2):
	print(ans[i])


(H, W) = map(int, input().split())
print('#' * (W + 2))
for _ in [0] * H:
	print(input('#') + '#')
print('#' * (W + 2))


(h, w) = map(int, input().split())
for i in range(h + 1):
	if i == 0 or i == h:
		print('#' * (w + 2))
		if i == h:
			return
	print('#', end='')
	print(input(), end='')
	print('#')


(H, W) = map(int, input().split())
A = ['#' * (W + 2)] + ['#' + input() + '#' for _ in range(H)] + ['#' * (W + 2)]
print(*A, sep='\n')


(h, w) = map(int, input().split())
a = list((list(input().split()) for _ in range(h)))
print('#' * (int(w) + 2))
for i in range(h):
	print('#', *a[i], '#', sep='')
print('#' * (int(w) + 2))


(n, m) = map(int, input().split())
print('#' * (m + 2))
for i in range(n):
	print('#' + input() + '#')
print('#' * (m + 2))


(h, w) = map(int, input().split())
al = ['#' * (w + 2)]
al += ['#' + input() + '#' for _ in range(h)]
al += ['#' * (w + 2)]
for a in al:
	print(a)


(H, W) = [int(x) for x in input().split()]
print('#' * (W + 2))
for h in range(H):
	print('#' + input().strip() + '#')
print('#' * (W + 2))


(h, w) = list(map(int, input().split()))
a = [input() for x in range(h)]
print('#' * (w + 2))
for s in a:
	print('#' + s + '#')
print('#' * (w + 2))


from typing import List

def answer(h: int, w: int, a: List[str]) -> List[str]:
	top_bottom_line = '#' * (w + 2)
	result = [top_bottom_line]
	for line in a:
		result.append(f'#{line}#')
	result.append(top_bottom_line)
	return result

def main():
	(h, w) = list(map(int, input().split()))
	a = [input() for _ in range(h)]
	for i in answer(h, w, a):
		print(i)

def __starting_point():
	main()
__starting_point()


(H, W) = map(int, input().split())
ans = ['#' * (W + 2)] + ['#' + input() + '#' for i in range(H)] + ['#' * (W + 2)]
print(*ans, sep='\n')


(H, W) = list(map(int, input().split()))
ans = []
for _ in range(H):
	a = input()
	ans.append('#' + a + '#')
print('#' * (W + 2))
for i in range(H):
	print(ans[i])
print('#' * (W + 2))


(h, w) = map(int, input().split())
w += 2
print('#' * w)
print('\n'.join(['#' + input().strip() + '#' for _ in [0] * h]))
print('#' * w)


def inpl():
	return list(map(int, input().split()))
(H, W) = inpl()
ans = [['#'] * (W + 2) for _ in range(H + 2)]
for h in range(H):
	A = input()
	for w in range(W):
		ans[h + 1][w + 1] = A[w]
print(*[''.join(a) for a in ans], sep='\n')


(H, W) = map(int, input().split())
a = ['' for i in range(H)]
for i in range(H):
	a[i] = list(str(input()))
for s in range(-1, H + 1):
	for t in range(-1, W + 1):
		if s == -1 or s == H:
			print('#' * (W + 2))
			break
		elif t == -1:
			print('#', end='')
		elif t == W:
			print('#')
		else:
			print(a[s][t], end='')


(h, w) = map(int, input().split())
b = ['#' * (w + 2)]
a = b + ['#' + input() + '#' for i in [0] * h] + b
for x in a:
	print(x)


(H, W) = map(int, input().split())
A = [input() for _ in range(H)]
W += 2
f = '#'
print(f * W)
for a in A:
	print(f'#{a}#')
print(f * W)


(H, W) = map(int, input().split())
a = '#' * (W + 2)
print(a)
for i in range(0, H):
	s = input()
	print('#' + s + '#')
print(a)


(_, w, *s) = open(0).read().split()
t = ['#' * (int(w) + 2)]
a = t + ['#' + t + '#' for t in s] + t
print(*a)


(H, W) = list(map(int, input().split()))
print('#' * (W + 2))
for h in range(H):
	print('#' + input() + '#')
print('#' * (W + 2))


(h, w) = map(int, input().split())
a = [[]]
print('#' * (w + 2))
for _ in range(h):
	print('#', input().strip(), '#', sep='')
print('#' * (w + 2))


(H, W) = map(int, input().split())
anslist = [['#' for i in range(W + 2)] for j in range(H + 2)]
for i in range(H):
	a = input()
	for j in range(W):
		anslist[i + 1][j + 1] = a[j]
for i in range(H + 2):
	for j in range(W + 2):
		print(anslist[i][j], end='')
	print()


(height, width) = map(int, input().split())
for i in range(width + 2):
	print('#', end='')
print('')
for j in range(height):
	print('#', end='')
	str = input()
	print(str, end='')
	print('#')
for l in range(width + 2):
	print('#', end='')


(a, s) = map(int, input().split())
print('#' * (s + 2))
for i in range(a):
	w = input()
	print('#' + w + '#')
print('#' * (s + 2))


(a, b) = map(int, input().split())
s = []
for i in range(a):
	s.append(input())
print('#' * (b + 2))
for i in range(a):
	print('#', end='')
	print(s[i], end='')
	print('#')
print('#' * (b + 2))


(H, W) = list(map(int, input().split()))
A = [list(input()) for _ in range(H)]
print('#' * (W + 2))
for a in A:
	print('#' + ''.join(a) + '#')
print('#' * (W + 2))


(H, W) = map(int, input().split())
frame = [['#' for _ in range(W + 2)] for _ in range(H + 2)]
mat = [['#' for _ in range(W)] for _ in range(H)]
for i in range(H):
	line = input()
	for j in range(W):
		mat[i][j] = line[j]
for (i, row) in enumerate(mat):
	for (j, char) in enumerate(row):
		frame[i + 1][j + 1] = char
for i in frame:
	for j in i:
		print(j, end='')
	print()


(H, W) = list(map(int, input().split()))
a = ''
for i in range(W + 2):
	a += '#'
L = []
L.append(a)
for j in range(H):
	b = str(input())
	c = '#' + b + '#'
	L.append(c)
L.append(a)
for k in range(H + 2):
	print(L[k])


def main():
	(h, w) = list(map(int, input().split()))
	a = []
	for i in range(h):
		a.append(input())
	cnt = len(a[0]) + 2
	print('#' * cnt)
	for _ in a:
		print(f'#{_}#')
	print('#' * cnt)

def __starting_point():
	main()
__starting_point()


with open(0) as f:
	(H, W, *a) = f.read().split()
W = int(W)
a.insert(0, '#' * W)
a.append('#' * W)
for x in a:
	print('#' + x.rstrip('\n') + '#')


(h, w) = map(int, input().split())
print('#' * (w + 2))
for k in [0] * h:
	print('#' + input() + '#')
print('#' * (w + 2))


(h, w) = list(map(int, input().split()))
row = '#' * (w + 2)
print(row)
for _ in range(h):
	print('#' + input() + '#')
print(row)


p = input
q = print
(h, w) = map(int, p().split())
w += 2
o = '#' * w
q(o)
q('\n'.join(['#' + p().strip() + '#' for _ in [0] * h]))
q(o)


(h, w) = map(int, input().split())
a = ['#' + input() + '#' for _ in range(h)]
c = '#' * (w + 2)
for j in [c] + a + [c]:
	print(j)


(h, w) = list(map(int, input().split()))
print('#' * (w + 2))
for i in range(h):
	data = list(map(str, input().split()))
	data2 = ['#'] + data + ['#']
	print(''.join(data2))
print('#' * (w + 2))


(a, b) = map(int, input().split())
print('#' * (b + 2))
for i in range(a):
	c = input()
	print('#' + c + '#')
print('#' * (b + 2))


(N, W) = list(map(int, input().split()))
l = [input() for _ in range(N)]
print('#' * (W + 2))
for i in l:
	print('#' + i + '#')
print('#' * (W + 2))


(H, W) = map(int, input().split())
tmp = '#' * (W + 2)
print(tmp)
for i in range(H):
	grid = '#' + input() + '#'
	print(grid)
print(tmp)


(H, W) = map(int, input().split())
H += 2
W += 2
for i in range(H):
	if i == 0 or i == H - 1:
		out = '#' * W
	else:
		a = input()
		out = '#{}#'.format(a)
	print(out)


(H, W) = map(int, input().split())
f = ''.join(['#'] * (W + 2))
print(f)
for i in range(H):
	print('#' + input() + '#')
print(f)


(N, W) = map(int, input().split())
print('#' * (W + 2))
for i in range(N):
	print('#' + input() + '#')
print('#' * (W + 2))


(h, w) = map(int, input().split())
s = [input() for _ in range(h)]
t = ['#' * (int(w) + 2)]
a = t + ['#' + t + '#' for t in s] + t
print(*a)


import sys
input = sys.stdin.readline

def main():
	strings = []
	(h, w) = map(int, input().split())
	strings = [input().rstrip() for _ in range(h)]
	output = ''
	for i in range(h + 2):
		if i == 0 or i == h + 1:
			igeta = '#' * (w + 2)
			print('{}'.format(igeta))
		else:
			output = '#' + strings[i - 1] + '#'
			print(output)

def __starting_point():
	main()
__starting_point()


(H, W) = [int(x) for x in input().split()]
pic = [list(input()) for _ in range(H)]
ans = [['#' for i in range(W + 2)] for j in range(H + 2)]
for i in range(H):
	for j in range(W):
		ans[i + 1][j + 1] = pic[i][j]
low = ''
for i in range(H + 2):
	for j in range(W + 2):
		low += ans[i][j]
	print(low)
	low = ''


(h, w) = map(int, input().split())
huta = ['#' for _ in range(w + 2)]
huta = ''.join(huta)
print(huta)
for _ in range(h):
	a = input()
	print('#{}#'.format(a))
print(huta)


(H, W) = map(int, input().split())
pic = []
for _ in range(H):
	a = input()
	pic.append(a)
print('#' * (W + 2))
for i in range(H):
	print('#' + pic[i] + '#')
print('#' * (W + 2))


(h, w) = map(int, input().split())
l = []
[l.append(input()) for _ in range(h)]
print('#' * (w + 2))
for s in l:
	print('#', s, '#', sep='')
print('#' * (w + 2))


import sys
import copy
import math
import itertools
import numpy as np
l = [int(c) for c in input().split()]
H = l[0]
W = l[1]
a = [input() for c in range(H)]
print('#' * (W + 2))
for i in range(H):
	print('#' + a[i] + '#')
print('#' * (W + 2))


(h, w) = map(int, input().split())
li = [list(input().split()) for i in range(h)]
for i in range(len(li)):
	st = li[i][0]
	li[i] = '#' + st + '#'
lis = '#' * (w + 2)
li.append(lis)
li.insert(0, lis)
for i in li:
	print(i)


(h, w) = map(int, input().split())
f = lambda x: print('#' * x)
f(w + 2)
for _ in range(h):
	print('#' + input() + '#')
f(w + 2)


import sys
(H, W) = map(int, sys.stdin.readline().split())
print('#' * (W + 2))
for _ in range(H):
	s = sys.stdin.readline().strip()
	print('#' + s + '#')
print('#' * (W + 2))


(h, w) = map(int, input().split())
words = [0] * (h + 2)
for i in range(1, h + 1, 1):
	s = input()
	words[i] = s
for j in range(len(words)):
	if words[j] == 0:
		words[j] = '#' * (w + 2)
	else:
		words[j] = '#' + words[j] + '#'
for ans in words:
	print(ans)


(h, w) = map(int, input().split())
pic = [input() for _ in range(h)]
print('#' * (w + 2))
for i in pic:
	print('#' + i + '#')
print('#' * (w + 2))


(x, y) = map(int, input().split())
L = [list(input()) for _ in range(x)]
F = [['#'] * (y + 2) for _ in range(x + 2)]
for i in range(x):
	for j in range(y):
		F[i + 1][j + 1] = L[i][j]
for f in F:
	print(''.join(f))


(h, w) = map(int, input().split())
a = [list(input()) for i in range(h)]
d = [['#'] * (w + 2) for i in range(h + 2)]
for i in range(h):
	for j in range(w):
		d[i + 1][j + 1] = a[i][j]
for i in range(h + 2):
	print(*d[i], sep='')


(_, w, *s) = open(0).read().split()
(t, k) = ('#' * -~int(w), '#\n#')
print(t, *s, sep=k, end=k + t)


HW = input().split()
H = int(HW[0])
W = int(HW[1])
lst = []
for i in range(H):
	lst.append('#' + input() + '#')
print('#' * (W + 2))
for s in lst:
	print(s)
print('#' * (W + 2))


(h, w) = map(int, input().split())
a_l = [['#'] + list(map(str, input().split())) + ['#'] for i in range(h)]
print(''.join(['#'] * (w + 2)))
for a in a_l:
	print(''.join(a))
print(''.join(['#'] * (w + 2)))


(h, w) = map(int, input().split())
[print('#', end='') for j in range(w + 2)]
print()
for i in range(h):
	print('#' + input() + '#')
[print('#', end='') for j in range(w + 2)]


(h, w) = map(int, input().split())
s = ['#' + input() + '#' for _ in range(h)]
s = ['#' * (w + 2)] + s + ['#' * (w + 2)]
print(*s, sep='\n')


(h, w) = list(map(int, input().split()))
pixel = [[] for i in range(h + 2)]
for i in range(h + 2):
	if i == 0:
		pixel[i].append('#' * (w + 2))
	elif i == h + 1:
		pixel[i].append('#' * (w + 2))
	else:
		pixel[i].append('#')
		s = input()
		pixel[i].append(s)
		pixel[i].append('#')
for i in range(h + 2):
	print(''.join(pixel[i]))


(h, w) = map(int, input().split())
l = [input() for _ in [0] * h]
print('#' * (w + 2))
for s in l:
	print('#' + s + '#')
print('#' * (w + 2))


(H, W) = [int(x) for x in input().split()]
print('#' * (W + 2))
for i in range(H):
	print('#' + input() + '#')
print('#' * (W + 2))


(h, w) = map(int, input().split())
s = []
s.append('#' * (w + 2))
for i in range(h):
	t = input()
	t = '#' + t + '#'
	s.append(t)
s.append('#' * (w + 2))
for ss in s:
	print(''.join(ss))


(h, w) = map(int, input().split())
l = ['#' + input() + '#' for _ in range(h)]
ans = ['#' * (w + 2)] + l + ['#' * (w + 2)]
for i in ans:
	print(i)


(A, B) = list(map(int, input().split()))
print('#' * (B + 2))
for i in range(A):
	print('#' + input() + '#')
print('#' * (B + 2))


(H, W) = [int(x) for x in input().split()]
for i in range(H):
	if i == 0:
		print(''.join(['#'] * (W + 2)))
	print('#' + input() + '#')
print(''.join(['#'] * (W + 2)))


(i, j) = map(int, input().split())
a = '#' * (j + 2)
print(a)
for y in range(i):
	print('#' + input() + '#')
print(a)


(N, M) = map(int, input().split())
print('#' * (M + 2))
for i in range(N):
	print('#' + str(input()) + '#')
print('#' * (M + 2))


(h, w) = map(int, input().split())
x = '#' * (w + 2)
print(x)
for i in range(h):
	z = input()
	y = '#' + z + '#'
	print(y)
print(x)


(c, r) = tuple(map(int, input().split()))
print('#' * (r + 2))
for _ in range(c):
	print('#{}#'.format(input()))
print('#' * (r + 2))


(h, w) = map(int, input().split())
a = [input() for _ in range(h)]
for i in range(h + 2):
	if i == 0 or i == h + 1:
		print('#' * (w + 2))
	else:
		print('#' + a[i - 1] + '#')


(h, w) = map(int, input().split())
s = '#' * (w + 2)
print(s)
for i in range(h):
	t = input()
	print('#', end='')
	print(t, end='#\n')
print(s)


(h, w) = map(int, input().split())
a = []
for _ in range(h):
	a.append(input())
for _ in range(w + 2):
	print('#', end='')
print()
for i in range(h):
	print('#', end='')
	print(a[i], end='')
	print('#')
for _ in range(w + 2):
	print('#', end='')


def resolve():
	(H, W) = [int(item) for item in input().split()]
	grid = [input() for _ in range(H)]
	print('#' * (W + 2))
	for line in grid:
		print('#' + line + '#')
	print('#' * (W + 2))

def __starting_point():
	resolve()
__starting_point()


(h, w) = map(int, input().split())
grid = [['#'] * (w + 2) for _ in range(h + 2)]
for i in range(h):
	grid[i + 1] = ['#'] + list(map(str, input().rstrip())) + ['#']
for i in range(h + 2):
	print(''.join(grid[i]))


(h, w) = map(int, input().split())
print('#' * (w + 2))
for q in range(h):
	print('#' + input() + '#')
print('#' * (w + 2))


(h, w) = map(int, input().split())
l = [str(input()) for i in range(h)]
p = '#'
print(p * (w + 2))
for j in l:
	print(p + j + p)
print(p * (w + 2))


(h, w) = map(int, input().split())
al = []
for _ in range(h):
	row = input()
	row = '#' + row + '#'
	al.append(row)
top = '#' * (w + 2)
print(top)
for a in al:
	print(a)
print(top)


def main():
	(H, W) = list(map(int, input().split()))
	print('#' * (W + 2))
	for _ in range(H):
		print('#{}#'.format(input()))
	print('#' * (W + 2))

def test():
	import doctest
	doctest.testmod()

def __starting_point():
	main()
__starting_point()


(H, W) = map(int, input().split())
print('#' * (W + 2))
for s in range(H):
	print('#' + input() + '#')
print('#' * (W + 2))


(h, w) = map(int, input().split())
a = [input() for _ in range(h)]
s = ''
for i in range(w + 2):
	s += '#'
print(s)
for i in a:
	t = list(i)
	t.insert(0, '#')
	t.append('#')
	print(''.join(t))
print(s)


(N, M) = map(int, input().split())
print('#' * (M + 2))
for _ in range(N):
	print('#' + input() + '#')
print('#' * (M + 2))


from collections import Counter, defaultdict, deque
from heapq import heappop, heappush
from bisect import bisect_left, bisect_right
import sys, math, itertools, fractions
sys.setrecursionlimit(10 ** 8)
mod = 10 ** 9 + 7
INF = float('inf')

def inp():
	return int(sys.stdin.readline())

def inpl():
	return list(map(int, sys.stdin.readline().split()))
(h, w) = inpl()
s = [input() for _ in range(h)]
res = []
for i in range(h + 2):
	if i == 0 or i == h + 1:
		res.append('#' * (w + 2))
	else:
		res.append('#' + s[i - 1] + '#')
for x in res:
	print(x)


(h, w) = map(int, input().split())
a = []
for _ in range(h):
	a.append('#' + input() + '#')
sharp = '#' * (w + 2)
print(sharp)
for j in range(0, h):
	print(a[j])
print(sharp)


(h, w) = map(int, input().split())
for i in range(w + 1):
	print('#', end='')
print('#')
for i in range(h):
	print('#' + input() + '#')
for i in range(w + 1):
	print('#', end='')
print('#')


(H, W) = list(map(int, input().split()))
a = [input() for _ in range(H)]
for i in range(0, H):
	a[i] = '#' + a[i] + '#'
print('#' * (W + 2))
for i in range(H):
	print(a[i])
print('#' * (W + 2))


(a, b) = map(int, input().split())
pic = [input() for _ in range(a)]
print('#' * (b + 2))
for i in pic:
	print('#' + i + '#')
print('#' * (b + 2))