
#include <stdio.h>
#include <string.h>
#include <limits.h>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <queue>

#ifndef U_L_LONG
typedef unsigned long long ULLONG;
#endif
#ifndef L_LONG
typedef long long LLONG;
#endif
template <class _T> static _T tp_abs(const _T& a) {
	//	usage:  tp_abs<type name>(a);
	return ((a < 0) ? (a * -1) : a);
}
template <class _T> static _T tp_min(_T a, _T b) {
	return a < b ? a : b;
}
template <class _T> static _T tp_max(_T a, _T b) {
	return a > b ? a : b;
}
template<class _T> static void get1int(_T& a) {
	const char* fmt = " %d";
	if (sizeof(_T) == sizeof(long long)) {
		fmt = " %lld";
	}

	if (scanf(fmt, &a) < 0) {
		printf("g1int Error\n");
	}
}
template<class _T> static void get2int(_T& a, _T& b) {
	const char* fmt = " %d %d";
	if (sizeof(_T) == sizeof(long long)) {
		fmt = " %lld %lld";
	}

	if (scanf(fmt, &a, &b) < 0) {
		printf("g2int Error\n");
	}
}
template<class _T> static void get3int(_T& a, _T& b, _T& c) {
	const char* fmt = " %d %d %d";
	if (sizeof(_T) == sizeof(long long)) {
		fmt = " %lld %lld %lld";
	}

	if (scanf(fmt, &a, &b, &c) < 0) {
		printf("g3int Error\n");
	}
}
static void getstring(char* buff) {
	if (scanf(" %s", buff) < 0) {
		printf("getstr error!\n");
	}
}

static void ABC096C_GridReplacing();

#if 1
int main()
{
	ABC096C_GridReplacing();
	fflush(stdout);
	return 0;
}
#endif

static bool ABC096C_bfs(char grid[51][51], int nowH, int nowW, int H, int W)
{
	if (grid[nowH][nowW] != '#') return true;

	bool enable = false;
	int dh[] = { 1, 0, -1, 0 };
	int dw[] = { 0, 1, 0, -1 };

	std::queue<std::pair<int, int>> bp;
	bp.push(std::pair<int, int>(nowH, nowW));
		
	while (!bp.empty()) {
		std::pair<int, int> pt = bp.front(); bp.pop();

		for (int i = 0; i < 4; i++) {
			int nh = pt.first + dh[i];
			int nw = pt.second + dw[i];
			if ((nh < H) && (nh >= 0) && (nw < W) && (nw >= 0) && (grid[nh][nw] == '#')) {
				enable = true;
				grid[nh][nw] = '.';
				bp.push(std::pair<int, int>(nh, nw));
			}
		}
	}
	if (enable) grid[nowH][nowW] = '.';
	
	return enable;
}
