#include <bits/stdc++.h>

#define x first
#define y second

using namespace std;

pair <int, int> all[3600];
char c[60][60];
pair <int, int> p[3600];
pair <int, int> t[3600];
int n;
char last[110][110];
int tc[110][110];

inline bool e(int x, int y)
{
	if(x > -1 && x < n && y > -1 && y < n)
		return 1;
	return 0;
}

int main() {
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin >> n;
	int ps = 0;
	int ts = 0;
	for(int i = 0; i < n; i ++)
	{
		for(int j = 0; j < n; j++)
		{
			cin >> c[i][j];
			if(c[i][j] == 'x')
			{
				tc[i][j] = 1;
			}
		}
	}
	for(int i = 0; i < n; i ++)
	{
		for(int j = 0; j < n; j++)
		{
			if(c[i][j] == 'o')
			{
				p[ps].x = i;
				p[ps].y = j;
				ps++;
			}
			if(c[i][j] == 'x')
			{
				t[ts].x = i;
				t[ts].y = j;
				ts++;
			}
		}
	}
	int xall = 0;
	for(int g = 0; g < ps; g++)
	{
		for(int i = 0; i < ts; i ++)
		{
			bool ok = 1;
			int dx = t[i].x - p[g].x;
			int dy = t[i].y - p[g].y;
			for(int j = 0; j < ps; j++)
			{
				if(!(c[p[j].x + dx][p[j].y + dy] == 'o' || c[p[j].x + dx][p[j].y + dy] == 'x' || e(p[j].x + dx, p[j].y + dy) == 0))
					break;
				if(j == ps - 1)
				{
					last[n - 1 + dx][n - 1 + dy] = 'x';
					for(int h = 0; h < ps; h++)
					{
						if(e(p[h].x + dx,p[h].y + dy))
						{
							tc[p[h].x + dx][p[h].y + dy] = 2;
						}
					}
				}
			}
		}
	}
	for(int i = 0; i < n; i++)
	{
		for(int j = 0; j < n; j ++)
		{
			if(tc[i][j] == 1)
			{
				cout << "NO";
				return 0;
			}
		}
	}
	cout << "YES" << endl;
	last[n-1][n-1] = 'o';
	for(int i = 0; i < 2*n -1; i++)
	{
		for(int j = 0; j < n * 2 - 1; j++)
		{
			if(last[i][j] == 'o')
				cout <<'o';
			else
			if(last[i][j] == 'x')
				cout << 'x';
			else
			cout << '.';
		}
		cout << endl;
	}

	return 0;
}


#include <bits/stdc++.h>

#define x first
#define y second

using namespace std;

pair <int, int> all[3600];
int c[60][60];
bool tf[60][60];
pair <int, int> p[3600];
pair <int, int> t[3600];
int n;
char last[110][110];

bool e(int x, int y)
{
	if(x > -1 && x < n && y > -1 && y < n)
		return 1;
	return 0;
}
int tc[110][110];

int main() {
	for(int i = 0; i < 110; i++)
	{
		for(int j = 0; j < 110; j ++)
		{
			last[i][j] = '.';
		}
	}
	cin >> n;
	int ps = 0;
	int ts = 0;
	for(int i = 0; i < n; i ++)
	{
		for(int j = 0; j < n; j++)
		{
			char x;
			cin >> x;
			if(x == '.')
				c[i][j] = 0;
			else
			if(x == 'o')
				c[i][j] = 1;
			else
				c[i][j] = 2;
			if(c[i][j] == 2)
			{
				tc[i][j] = 1;
			}
		}
	}
	for(int i = 0; i < n; i ++)
	{
		for(int j = 0; j < n; j++)
		{
			if(c[i][j] == 1)
			{
				p[ps].x = i;
				p[ps].y = j;
				ps++;
			}
			if(c[i][j] == 2)
			{
				t[ts].x = i;
				t[ts].y = j;
				ts++;
			}
		}
	}
	int xall = 0;
	for(int g = 0; g < ps; g++)
	{
		for(int i = 0; i < ts; i ++)
		{
			bool ok = 1;
			int dx = t[i].x - p[g].x;
			int dy = t[i].y - p[g].y;
			for(int j = 0; j < ps; j++)
			{
				if(c[p[j].x + dx][p[j].y + dy] == 1 || c[p[j].x + dx][p[j].y + dy] == 2 || e(p[j].x + dx, p[j].y + dy) == 0)
				{
				}
				else
					break;
				if(j == ps - 1)
				{
					last[n - 1 + dx][n - 1 + dy] = 'x';
					for(int h = 0; h < ps; h++)
					{
						if(e(p[h].x + dx,p[h].y + dy))
						{
							tc[p[h].x + dx][p[h].y + dy] = 2;
						}
					}
				}
			}
		}
	}
	for(int i = 0; i < n; i++)
	{
		for(int j = 0; j < n; j ++)
		{
			if(tc[i][j] == 1)
			{
				cout << "NO";
				return 0;
			}
		}
	}
	cout << "YES" << endl;
	last[n-1][n-1] = 'o';
	for(int i = 0; i < 2*n -1; i++)
	{
		for(int j = 0; j < n * 2 - 1; j++)
			cout << last[i][j];
		cout << endl;
	}

	return 0;
}


#include <bits/stdc++.h>

#define x first
#define y second

using namespace std;

pair <int, int> all[3600];
char c[60][60];
pair <int, int> p[3600];
pair <int, int> t[3600];
int n;
char last[110][110];

inline bool e(int x, int y)
{
	if(x > -1 && x < n && y > -1 && y < n)
		return 1;
	return 0;
}
int tc[110][110];

int main() {
	cin >> n;
	int ps = 0;
	int ts = 0;
	for(int i = 0; i < n; i ++)
	{
		for(int j = 0; j < n; j++)
		{
			cin >> c[i][j];
			if(c[i][j] == 'x')
			{
				tc[i][j] = 1;
			}
		}
	}
	for(int i = 0; i < n; i ++)
	{
		for(int j = 0; j < n; j++)
		{
			if(c[i][j] == 'o')
			{
				p[ps].x = i;
				p[ps].y = j;
				ps++;
			}
			if(c[i][j] == 'x')
			{
				t[ts].x = i;
				t[ts].y = j;
				ts++;
			}
		}
	}
	int xall = 0;
	for(int g = 0; g < ps; g++)
	{
		for(int i = 0; i < ts; i ++)
		{
			bool ok = 1;
			int dx = t[i].x - p[g].x;
			int dy = t[i].y - p[g].y;
			for(int j = 0; j < ps; j++)
			{
				if(c[p[j].x + dx][p[j].y + dy] == 'o' || c[p[j].x + dx][p[j].y + dy] == 'x' || e(p[j].x + dx, p[j].y + dy) == 0)
				{
				}
				else
					break;
				if(j == ps - 1)
				{
					last[n - 1 + dx][n - 1 + dy] = 'x';
					for(int h = 0; h < ps; h++)
					{
						if(e(p[h].x + dx,p[h].y + dy))
						{
							tc[p[h].x + dx][p[h].y + dy] = 2;
						}
					}
				}
			}
		}
	}
	for(int i = 0; i < n; i++)
	{
		for(int j = 0; j < n; j ++)
		{
			if(tc[i][j] == 1)
			{
				cout << "NO";
				return 0;
			}
		}
	}
	cout << "YES" << endl;
	last[n-1][n-1] = 'o';
	for(int i = 0; i < 2*n -1; i++)
	{
		for(int j = 0; j < n * 2 - 1; j++)
		{
			if(last[i][j] == 'o')
				cout <<'o';
			else
			if(last[i][j] == 'x')
				cout << 'x';
			else
			cout << '.';
		}
		cout << endl;
	}

	return 0;
}


#include <bits/stdc++.h>

#define x first
#define y second

using namespace std;

int n;
vector<pair<int,int> > pi;
int c[60][60];
char ll[110][110];

bool e(int x, int y)
{
	if(x > -1 && x < n && y > -1 && y < n)
		return 1;
	else
		return 0;
}

int main() {
	cin >> n;
	for(int i = 0; i < 2 * n -1; i ++)
	{
		for(int j = 0; j < 2 * n - 1; j ++)
			ll[i][j] = '.';
	}
	for(int i = 0; i < n; i ++)
	{
		for(int j = 0; j < n; j ++)
		{
			char x;
			cin >> x;
			if(x == 'o')
			{
				pi.push_back(pair<int, int> (i, j));
				c[i][j] = 1;
			}
			else
			if(x == 'x')
				c[i][j] = 2;
		}
	}
	for(int i = 1 - n; i < n; i++)
	{
		for(int j = 1 - n; j < n; j ++)
		{
			bool v = 1;
			for(int p = 0; p < pi.size(); p++)
			{
				int dx = pi[p].first + i;
				int dy = pi[p].second + j;
				if(e(dx, dy) && c[dx][dy] == 0)
				{
					v = 0;
					break;
				}
			}
			if(v == 1)
			{
				ll[i + n - 1][j + n - 1] = 'x';
				for(int p = 0; p < pi.size(); p++)
				{
					if(e(pi[p].x + i, pi[p].y + j))
						c[pi[p].x + i][pi[p].y + j] = 10;
				}
			}
		}
	}

	ll[n -1][n-1] = 'o';
	for(int i = 0; i < n; i ++)
	{
		for(int j = 0; j < n; j ++)
		{
			if(c[i][j] == 2)
			{
				cout << "NO";
				return 0;
			}
		}
	}
	cout << "YES" << endl;
	for(int i = 0; i < 2 * n - 1; i ++)
	{
		for(int j = 0; j < 2 * n - 1; j ++)
			cout << ll[i][j];
		cout << endl;
	}
	return 0;
}


#include <bits/stdc++.h>

#define x first
#define y second

using namespace std;

pair <int, int> all[3600];
char c[60][60];
pair <int, int> p[3600];
pair <int, int> t[3600];
int n;
char last[110][110];
int tc[110][110];

inline bool e(int x, int y)
{
	if(x > -1 && x < n && y > -1 && y < n)
		return 1;
	return 0;
}

int main() {
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin >> n;
	int ps = 0;
	int ts = 0;
	for(int i = 0; i < n; i ++)
	{
		for(int j = 0; j < n; j++)
		{
			cin >> c[i][j];
			if(c[i][j] == 'x')
			{
				tc[i][j] = 1;
			}
		}
	}
	for(int i = 0; i < n; i ++)
	{
		for(int j = 0; j < n; j++)
		{
			if(c[i][j] == 'o')
			{
				p[ps].x = i;
				p[ps].y = j;
				ps++;
			}
			if(c[i][j] == 'x')
			{
				t[ts].x = i;
				t[ts].y = j;
				ts++;
			}
		}
	}
	int xall = 0;
	for(int g = 0; g < ps; g++)
	{
		for(int i = 0; i < ts; i ++)
		{
			bool ok = 0;
			int dx = t[i].x - p[g].x;
			int dy = t[i].y - p[g].y;
			for(int j = 0; j < ps; j++)
			{
				if(!(c[p[j].x + dx][p[j].y + dy] == 'o' || c[p[j].x + dx][p[j].y + dy] == 'x' || e(p[j].x + dx, p[j].y + dy) == 0))
					break;
				if(j == ps - 1)
				{
					ok = 1;
				}
			}
			if(ok == 1)
			{
				last[n - 1 + dx][n - 1 + dy] = 'x';
				for(int h = 0; h < ps; h++)
				{
					if(e(p[h].x + dx,p[h].y + dy))
					{
						tc[p[h].x + dx][p[h].y + dy] = 2;
					}
				}
			}
		}
	}
	for(int i = 0; i < n; i++)
	{
		for(int j = 0; j < n; j ++)
		{
			if(tc[i][j] == 1)
			{
				cout << "NO";
				return 0;
			}
		}
	}
	cout << "YES" << endl;
	last[n-1][n-1] = 'o';
	for(int i = 0; i < 2*n -1; i++)
	{
		for(int j = 0; j < n * 2 - 1; j++)
		{
			if(last[i][j] == 'o')
				cout <<'o';
			else
			if(last[i][j] == 'x')
				cout << 'x';
			else
			cout << '.';
		}
		cout << endl;
	}

	return 0;
}


#include <bits/stdc++.h>

#define x first
#define y second

using namespace std;

pair <int, int> all[3600];
int c[60][60];
pair <int, int> p[3600];
pair <int, int> t[3600];
int n;
char last[110][110];

inline bool e(int x, int y)
{
	if(x > -1 && x < n && y > -1 && y < n)
		return 1;
	return 0;
}
int tc[110][110];

int main() {
	cin >> n;
	int ps = 0;
	int ts = 0;
	for(int i = 0; i < n; i ++)
	{
		for(int j = 0; j < n; j++)
		{
			char x;
			cin >> x;
			if(x == '.')
				c[i][j] = 0;
			else
			if(x == 'o')
				c[i][j] = 1;
			else
				c[i][j] = 2;
			if(c[i][j] == 2)
			{
				tc[i][j] = 1;
			}
		}
	}
	for(int i = 0; i < n; i ++)
	{
		for(int j = 0; j < n; j++)
		{
			if(c[i][j] == 1)
			{
				p[ps].x = i;
				p[ps].y = j;
				ps++;
			}
			if(c[i][j] == 2)
			{
				t[ts].x = i;
				t[ts].y = j;
				ts++;
			}
		}
	}
	int xall = 0;
	for(int g = 0; g < ps; g++)
	{
		for(int i = 0; i < ts; i ++)
		{
			bool ok = 1;
			int dx = t[i].x - p[g].x;
			int dy = t[i].y - p[g].y;
			for(int j = 0; j < ps; j++)
			{
				if(c[p[j].x + dx][p[j].y + dy] == 1 || c[p[j].x + dx][p[j].y + dy] == 2 || e(p[j].x + dx, p[j].y + dy) == 0)
				{
				}
				else
					break;
				if(j == ps - 1)
				{
					last[n - 1 + dx][n - 1 + dy] = 'x';
					for(int h = 0; h < ps; h++)
					{
						if(e(p[h].x + dx,p[h].y + dy))
						{
							tc[p[h].x + dx][p[h].y + dy] = 2;
						}
					}
				}
			}
		}
	}
	for(int i = 0; i < n; i++)
	{
		for(int j = 0; j < n; j ++)
		{
			if(tc[i][j] == 1)
			{
				cout << "NO";
				return 0;
			}
		}
	}
	cout << "YES" << endl;
	last[n-1][n-1] = 'o';
	for(int i = 0; i < 2*n -1; i++)
	{
		for(int j = 0; j < n * 2 - 1; j++)
		{
			if(last[i][j] == 'o')
				cout <<'o';
			else
			if(last[i][j] == 'x')
				cout << 'x';
			else
			cout << '.';
		}
		cout << endl;
	}

	return 0;
}


#include <bits/stdc++.h>

#define x first
#define y second

using namespace std;

pair <int, int> all[3600];
int c[60][60];
bool tf[60][60];
pair <int, int> p[3600];
pair <int, int> t[3600];
int n;
char last[110][110];

bool e(int x, int y)
{
	if(x > -1 && x < n && y > -1 && y < n)
		return 1;
	return 0;
}
int tc[110][110];

int main() {
	for(int i = 0; i < 110; i++)
	{
		for(int j = 0; j < 110; j ++)
		{
			last[i][j] = '.';
		}
	}
	cin >> n;
	int ps = 0;
	int ts = 0;
	for(int i = 0; i < n; i ++)
	{
		for(int j = 0; j < n; j++)
		{
			char x;
			cin >> x;
			if(x == '.')
				c[i][j] = 0;
			else
			if(x == 'o')
				c[i][j] = 1;
			else
				c[i][j] = 2;
			if(c[i][j] == 2)
			{
				tc[i][j] = 1;
			}
		}
	}
	for(int i = 0; i < n; i ++)
	{
		for(int j = 0; j < n; j++)
		{
			if(c[i][j] == 1)
			{
				p[ps].x = i;
				p[ps].y = j;
				ps++;
			}
			if(c[i][j] == 2)
			{
				t[ts].x = i;
				t[ts].y = j;
				ts++;
			}
		}
	}
	int xall = 0;
	for(int g = 0; g < ps; g++)
	{
		for(int i = 0; i < ts; i ++)
		{
			bool ok = 1;
			int dx = t[i].x - p[g].x;
			int dy = t[i].y - p[g].y;
			for(int j = 1; j < ps; j++)
			{
				if(c[p[j].x + dx][p[j].y + dy] == 1 || c[p[j].x + dx][p[j].y + dy] == 2 || e(p[j].x + dx, p[j].y + dy) == 0)
				{
				}
				else
					break;
				if(j == ps - 1)
				{
					last[n - 1 + dx][n - 1 + dy] = 'x';
					for(int h = 0; h < ps; h++)
					{
						if(e(p[h].x + dx,p[h].y + dy))
						{
							tc[p[h].x + dx][p[h].y + dy] = 2;
						}
					}
				}
			}
		}
	}
	for(int i = 0; i < n; i++)
	{
		for(int j = 0; j < n; j ++)
		{
			if(tc[i][j] == 1)
			{
				cout << "NO";
				return 0;
			}
		}
	}
	cout << "YES" << endl;
	last[n-1][n-1] = 'o';
	for(int i = 0; i < 2*n -1; i++)
	{
		for(int j = 0; j < n * 2 - 1; j++)
			cout << last[i][j];
		cout << endl;
	}

	return 0;
}


#include <bits/stdc++.h>

#define x first
#define y second

using namespace std;

pair <int, int> all[3600];
char c[60][60];
pair <int, int> p[3600];
pair <int, int> t[3600];
int n;
char last[110][110];
int tc[110][110];

inline bool e(int x, int y)
{
	if(x > -1 && x < n && y > -1 && y < n)
		return 1;
	return 0;
}

int main() {
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin >> n;
	int ps = 0;
	int ts = 0;
	for(int i = 0; i < n; i ++)
	{
		for(int j = 0; j < n; j++)
		{
			cin >> c[i][j];
			if(c[i][j] == 'x')
			{
				tc[i][j] = 1;
				t[ts].x = i;
				t[ts].y = j;
				ts++;
			}
			else
			if(c[i][j] == 'o')
			{
				p[ps].x = i;
				p[ps].y = j;
				ps++;
			}
		}
	}
	int xall = 0;
	for(int g = 0; g < ps; g++)
	{
		for(int i = 0; i < ts; i ++)
		{
			bool ok = 0;
			int dx = t[i].x - p[g].x;
			int dy = t[i].y - p[g].y;
			for(int j = 0; j < ps; j++)
			{
				if(!(c[p[j].x + dx][p[j].y + dy] == 'o' || c[p[j].x + dx][p[j].y + dy] == 'x' || e(p[j].x + dx, p[j].y + dy) == 0))
					break;
				if(j == ps - 1)
				{
					ok = 1;
				}
			}
			if(ok == 1)
			{
				last[n - 1 + dx][n - 1 + dy] = 'x';
				for(int h = 0; h < ps; h++)
				{
					if(e(p[h].x + dx,p[h].y + dy))
					{
						tc[p[h].x + dx][p[h].y + dy] = 2;
					}
				}
			}
		}
	}
	for(int i = 0; i < n; i++)
	{
		for(int j = 0; j < n; j ++)
		{
			if(tc[i][j] == 1)
			{
				cout << "NO";
				return 0;
			}
		}
	}
	cout << "YES" << endl;
	last[n-1][n-1] = 'o';
	for(int i = 0; i < 2*n -1; i++)
	{
		for(int j = 0; j < n * 2 - 1; j++)
		{
			if(last[i][j] == 'o')
				cout <<'o';
			else
			if(last[i][j] == 'x')
				cout << "x";
			else
			cout << '.';
		}
		cout << endl;
	}

	return 0;
}


#include <bits/stdc++.h>

#define x first
#define y second

using namespace std;

pair <int, int> all[3600];
char c[60][60];
pair <int, int> p[3600];
pair <int, int> t[3600];
int n;
char last[110][110];
int tc[110][110];

inline bool e(int x, int y)
{
	if(x > -1 && x < n && y > -1 && y < n)
		return 1;
	return 0;
}

int main() {
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin >> n;
	int ps = 0;
	int ts = 0;
	for(int i = 0; i < n; i ++)
	{
		for(int j = 0; j < n; j++)
		{
			cin >> c[i][j];
			if(c[i][j] == 'x')
			{
				tc[i][j] = 1;
			}
		}
	}
	for(int i = 0; i < n; i ++)
	{
		for(int j = 0; j < n; j++)
		{
			if(c[i][j] == 'o')
			{
				p[ps].x = i;
				p[ps].y = j;
				ps++;
			}
			if(c[i][j] == 'x')
			{
				t[ts].x = i;
				t[ts].y = j;
				ts++;
			}
		}
	}
	int xall = 0;
	for(int g = 0; g < ps; g++)
	{
		for(int i = 0; i < ts; i ++)
		{
			bool ok = 1;
			int dx = t[i].x - p[g].x;
			int dy = t[i].y - p[g].y;
			for(int j = 0; j < ps; j++)
			{
				if(c[p[j].x + dx][p[j].y + dy] == 'o' || c[p[j].x + dx][p[j].y + dy] == 'x' || e(p[j].x + dx, p[j].y + dy) == 0)
				{
				}
				else
					break;
				if(j == ps - 1)
				{
					last[n - 1 + dx][n - 1 + dy] = 'x';
					for(int h = 0; h < ps; h++)
					{
						if(e(p[h].x + dx,p[h].y + dy))
						{
							tc[p[h].x + dx][p[h].y + dy] = 2;
						}
					}
				}
			}
		}
	}
	for(int i = 0; i < n; i++)
	{
		for(int j = 0; j < n; j ++)
		{
			if(tc[i][j] == 1)
			{
				cout << "NO";
				return 0;
			}
		}
	}
	cout << "YES" << endl;
	last[n-1][n-1] = 'o';
	for(int i = 0; i < 2*n -1; i++)
	{
		for(int j = 0; j < n * 2 - 1; j++)
		{
			if(last[i][j] == 'o')
				cout <<'o';
			else
			if(last[i][j] == 'x')
				cout << 'x';
			else
			cout << '.';
		}
		cout << endl;
	}

	return 0;
}


#include <iostream>

using namespace std ;

int n ;
const int N = 50 + 10 ;
bool Booly[2 * N - 1][2 * N - 1] ;
string S[N] ;
// main memory

void Barresy (int x , int y)
{
    for(int i = 0 ; i < n ; i++)
        for(int j = 0 ; j < n ; j++)
            if(S[i][j] == '.')
                Booly[n - 1 + (i - x)][n - 1 + (j - y)] = false ;

    return ;
}

void Sadegar (int x , int y)
{
    for(int i = 0 ; i < n ; i++)
        for(int j = 0 ; j < n ; j++)
            if(S[i][j] == 'x' and Booly[n - 1 + (i - x)][n - 1 + (j - y)] == true)
                S[i][j] = '.' ;

    return ;
}

int main()
{
    cin >> n ;

    for(int i = 0 ; i < n ; i++)
        cin >> S[i] ;

    for(int i = 0 ; i < 2 * n ; i++)
        for(int j = 0 ; j < 2 * n ; j++)
            Booly[i][j] = true ;

    // vorodi

    for(int i = 0 ; i < n ; i++)
        for(int j = 0 ; j < n ; j++)
            if(S[i][j] == 'o')
                Barresy(i , j) ;

    for(int i = 0 ; i < n ; i++)
        for(int j = 0 ; j < n ; j++)
            if(S[i][j] == 'o')
                Sadegar(i , j) ;

    for(int i = 0 ; i < n ; i++)
        for(int j = 0 ; j < n ; j++)
            if(S[i][j] == 'x'){
                cout << "NO" << endl ;
                return 0 ;
            }

    for(int i = 0 ; i < n ; i++)
        cout << S[i] << endl ;

    cout << "YES" << endl ;

    for(int i = 0 ; i < 2 * n - 1 ; i++){
        for(int j = 0 ; j < 2 * n - 1 ; j++)
            if(i == n - 1 and j == n - 1)
                cout << "o" ;
            else if(Booly[i][j])
                cout << "x" ;
            else
                cout << "." ;
        cout << "\n" ;
    }

    cout << endl ;
	return 0 ;
}


#include <iostream>

using namespace std ;

int n ;
const int N = 50 + 10 ;
bool Booly[2 * N - 1][2 * N - 1] ;
string S[N] ;
// main memory

void Barresy (int x , int y)
{
    for(int i = 0 ; i < n ; i++)
        for(int j = 0 ; j < n ; j++)
            if(S[i][j] == '.')
                Booly[n - 1 + (i - x)][n - 1 + (j - y)] = false ;

    return ;
}

void Sadegar (int x , int y)
{
    for(int i = 0 ; i < n ; i++)
        for(int j = 0 ; j < n ; j++)
            if(S[i][j] == 'x' and Booly[n - 1 + (i - x)][n - 1 + (j - y)] == true)
                S[i][j] = '.' ;

    return ;
}

int main()
{
    cin >> n ;

    for(int i = 0 ; i < n ; i++)
        cin >> S[i] ;

    for(int i = 0 ; i < 2 * n ; i++)
        for(int j = 0 ; j < 2 * n ; j++)
            Booly[i][j] = true ;

    // vorodi

    for(int i = 0 ; i < n ; i++)
        for(int j = 0 ; j < n ; j++)
            if(S[i][j] == 'o')
                Barresy(i , j) ;

    for(int i = 0 ; i < n ; i++)
        for(int j = 0 ; j < n ; j++)
            if(S[i][j] == 'o')
                Sadegar(i , j) ;

    for(int i = 0 ; i < n ; i++)
        for(int j = 0 ; j < n ; j++)
            if(S[i][j] == 'x'){
                cout << "No" << endl ;
                return 0 ;
            }

    for(int i = 0 ; i < n ; i++)
        cout << S[i] << endl ;

    cout << "Yes" << endl ;

    for(int i = 0 ; i < 2 * n - 1 ; i++){
        for(int j = 0 ; j < 2 * n - 1 ; j++)
            if(i == n - 1 and j == n - 1)
                cout << "o" ;
            else if(Booly[i][j])
                cout << "x" ;
            else
                cout << "." ;
        cout << "\n" ;
    }

    cout << endl ;
	return 0 ;
}


#include <iostream>

using namespace std ;

int n ;
const int N = 50 + 10 ;
bool Booly[2 * N - 1][2 * N - 1] ;
string S[N] ;
// main memory

void Barresy (int x , int y)
{
    for(int i = 0 ; i < n ; i++)
        for(int j = 0 ; j < n ; j++)
            if(S[i][j] == '.')
                Booly[n - 1 + (i - x)][n - 1 + (j - y)] = false ;

    return ;
}

void Sadegar (int x , int y)
{
    for(int i = 0 ; i < n ; i++)
        for(int j = 0 ; j < n ; j++)
            if(S[i][j] == 'x' and Booly[n - 1 + (i - x)][n - 1 + (j - y)] == true)
                S[i][j] = '.' ;

    return ;
}

int main()
{
    cin >> n ;

    for(int i = 0 ; i < n ; i++)
        cin >> S[i] ;

    for(int i = 0 ; i < 2 * n ; i++)
        for(int j = 0 ; j < 2 * n ; j++)
            Booly[i][j] = true ;

    // vorodi

    for(int i = 0 ; i < n ; i++)
        for(int j = 0 ; j < n ; j++)
            if(S[i][j] == 'o')
                Barresy(i , j) ;

    for(int i = 0 ; i < n ; i++)
        for(int j = 0 ; j < n ; j++)
            if(S[i][j] == 'o')
                Sadegar(i , j) ;

    for(int i = 0 ; i < n ; i++)
        for(int j = 0 ; j < n ; j++)
            if(S[i][j] == 'x'){
                cout << "NO" << endl ;
                return 0 ;
            }

    cout << "YES" << endl ;

    for(int i = 0 ; i < 2 * n - 1 ; i++){
        for(int j = 0 ; j < 2 * n - 1 ; j++)
            if(i == n - 1 and j == n - 1)
                cout << "o" ;
            else if(Booly[i][j])
                cout << "x" ;
            else
                cout << "." ;
        cout << "\n" ;
    }

    cout << endl ;
	return 0 ;
}


#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <vector>
const int MaxN = 100;
using namespace std;

char s[MaxN + 5][MaxN + 5];
int n;
vector < pair <int, int> > V;
bool vis[MaxN + 5][MaxN + 5];
char res[MaxN + 5][MaxN + 5];
bool check(int x, int y)
{
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= n; j++) {
			if(s[i][j] == 'o') {
				int tx = x + i, ty = y + j;
				if(tx >= 1 && tx <= n && ty <= n && ty >= 1) {
					if(s[tx][ty] == '.') return false;
				}
			}
		}
	}
	return true;
}

void New_flag(int x, int y)
{
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= n; j++) {
			if(s[i][j] == 'o') {
				int tx = x + i, ty = y + j;
				if(tx >= 1 && tx <= n && ty <= n && ty >= 1) {
					vis[tx][ty] = true;
				}
			}
		}
	}
}

void Init()
{
	V.clear(); memset(vis, 0, sizeof(vis));
	for (int i = 1; i <= n; i++) scanf("%s", s[i] + 1);
	for (int i = -n; i <= n; i++) {
		for (int j = -n; j <= n; j++) {
			if(check(i, j)) {
				New_flag(i, j);
				V.push_back(make_pair(i, j));
			}
		}
	}
}

void Solve()
{
	for (int i = 1; i <= n; i++) for (int j = 1; j <= n; j++) if(s[i][j] == 'x' && vis[i][j] == false) {
		printf("NO\n"); return ;
	}
	memset(res, 0, sizeof(res));
	for (int i = 1; i <= 2 * n; i++) for (int j = 1; j <= 2 * n; j++) res[i][j] = '.';
	for (auto now : V) {
		res[now.first + n][now.second + n] = 'x';
	}
	res[n][n] = 'o';
	printf("YES\n");
	for (int i = 1; i <= 2 * n - 1; i++) printf("%s\n", res[i] + 1);
}

int main()
{
	while(~scanf("%d", &n)) {
		Init(); Solve();
	}
	return 0;
}


#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <vector>
const int MaxN = 100;
using namespace std;

char s[MaxN + 5][MaxN + 5];
int n;
vector < pair <int, int> > V;
bool vis[MaxN + 5][MaxN + 5];
char res[MaxN + 5][MaxN + 5];
bool check(int x, int y)
{
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= n; j++) {
			if(s[i][j] == 'o') {
				int tx = x + i, ty = y + j;
				if(tx >= 1 && tx <= n && ty <= n && ty >= 1) {
					if(s[tx][ty] == '.') return false;
				}
			}
		}
	}
	return true;
}

void New_flag(int x, int y)
{
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= n; j++) {
			if(s[i][j] == 'o') {
				int tx = x + i, ty = y + j;
				if(tx >= 1 && tx <= n && ty <= n && ty >= 1) {
					vis[tx][ty] = true;
				}
			}
		}
	}
}

void Init()
{
	V.clear();
	for (int i = 1; i <= n; i++) scanf("%s", s[i] + 1);
	for (int i = -n; i <= n; i++) {
		for (int j = -n; j <= n; j++) {
			if(check(i, j)) {
				New_flag(i, j);
				V.push_back(make_pair(i, j));
			}
		}
	}
}

void Solve()
{
	for (int i = 1; i <= n; i++) for (int j = 1; j <= n; j++) if(s[i][j] == 'x' && vis[i][j] == false) {
		printf("NO\n"); return ;
	}
	memset(res, 0, sizeof(res));
	for (int i = 1; i <= 2 * n; i++) for (int j = 1; j <= 2 * n; j++) res[i][j] = '.';
	for (auto now : V) {
		res[now.first + n][now.second + n] = 'x';
	}
	res[n][n] = 'o';
	printf("YES\n");
	for (int i = 1; i <= 2 * n; i++) printf("%s\n", res[i] + 1);
}

int main()
{
	while(~scanf("%d", &n)) {
		Init(); Solve();
	}
	return 0;
}


#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <vector>
const int MaxN = 100;
using namespace std;

char s[MaxN + 5][MaxN + 5];
int n;
vector < pair <int, int> > V;
bool vis[MaxN + 5][MaxN + 5];
char res[MaxN + 5][MaxN + 5];
bool check(int x, int y)
{
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= n; j++) {
			if(s[i][j] == 'o') {
				int tx = x + i, ty = y + j;
				if(tx >= 1 && tx <= n && ty <= n && ty >= 1) {
					if(s[tx][ty] == '.') return false;
				}
			}
		}
	}
	return true;
}

void New_flag(int x, int y)
{
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= n; j++) {
			if(s[i][j] == 'o') {
				int tx = x + i, ty = y + j;
				if(tx >= 1 && tx <= n && ty <= n && ty >= 1) {
					vis[tx][ty] = true;
				}
			}
		}
	}
}

void Init()
{
	V.clear(); memset(vis, 0, sizeof(vis));
	for (int i = 1; i <= n; i++) scanf("%s", s[i] + 1);
	for (int i = -n; i <= n; i++) {
		for (int j = -n; j <= n; j++) {
			if(check(i, j)) {
				New_flag(i, j);
				V.push_back(make_pair(i, j));
			}
		}
	}
}

void Solve()
{
	for (int i = 1; i <= n; i++) for (int j = 1; j <= n; j++) if(s[i][j] == 'x' && vis[i][j] == false) {
		printf("NO\n"); return ;
	}
	memset(res, 0, sizeof(res));
	for (int i = 1; i <= 2 * n - 1; i++) for (int j = 1; j <= 2 * n - 1; j++) res[i][j] = '.';
	for (auto now : V) {
		res[now.first + n][now.second + n] = 'x';
	}
	res[n][n] = 'o';
	for (int i = 1; i <= 2 * n - 1; i++) res[i][2 * n] = 0;
	printf("YES\n");
	for (int i = 1; i <= 2 * n - 1; i++) printf("%s\n", res[i] + 1);
}

int main()
{
	while(~scanf("%d", &n)) {
		Init(); Solve();
	}
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

const int maxn = 55;

char s[maxn][maxn];
bool fix[maxn * 2][maxn * 2],cov[maxn][maxn];
int n;

int main()
{
	scanf("%d", &n);
	for(int i = 0;i < n;i ++)
		scanf("%s", s[i]);
	for(int i = 0;i < n;i ++)
		for(int j = 0;j < n;j ++)
			if (s[i][j] == 'o')
				for(int k = 0;k < n;k ++)
					for(int p = 0;p < n;p ++)
						if (s[k][p] == '.')
							fix[k - i + n][p - j + n] = 1;
	for(int i = 0;i < n;i ++)
		for(int j = 0;j < n;j ++)
			if (s[i][j] == 'o')
				for(int k = 0;k < 2 * n;k ++)
					for(int p = 0;p < 2 * n;p ++)
						if (!fix[k][p])
						{
							int rx = i + k - n,ry = j + p - n;
							if (rx >= 0 && ry >= 0 && rx < n && ry < n)
								cov[rx][ry] = 1;
						}
	for(int i = 0;i < n;i ++)
		for(int j = 0;j < n;j ++)
			if (s[i][j] == 'x' && !cov[i][j]) {printf("NO\n");return 0;}
	printf("YES\n");
	for(int i = 0;i < 2 * n;i ++)
	{
		for(int j = 0;j < 2 * n;j ++)
			if (i == n && j == n) printf("o"); else
				printf("%c", fix[i][j] ? '.' : 'x');
		printf("\n");
	}
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

const int maxn = 55;

char s[maxn][maxn];
bool fix[maxn * 2][maxn * 2],cov[maxn][maxn];
int n;

int main()
{
	scanf("%d", &n);
	for(int i = 0;i < n;i ++)
		scanf("%s", s[i]);
	for(int i = 0;i < n;i ++)
		for(int j = 0;j < n;j ++)
			if (s[i][j] == 'o')
				for(int k = 0;k < n;k ++)
					for(int p = 0;p < n;p ++)
						if (s[k][p] == '.')
							fix[k - i + n][p - j + n] = 1;
	for(int i = 0;i < n;i ++)
		for(int j = 0;j < n;j ++)
			if (s[i][j] == 'o')
				for(int k = 0;k < 2 * n;k ++)
					for(int p = 0;p < 2 * n;p ++)
						if (!fix[k][p])
						{
							int rx = i + k - n,ry = j + p - n;
							if (rx >= 0 && ry >= 0 && rx < n && ry < n)
								cov[rx][ry] = 1;
						}
	for(int i = 0;i < n;i ++)
		for(int j = 0;j < n;j ++)
			if (s[i][j] == 'x' && !cov[i][j]) {printf("NO\n");return 0;}
	printf("YES\n");
	for(int i = 1;i < 2 * n;i ++)
	{
		for(int j = 1;j < 2 * n;j ++)
			if (i == n && j == n) printf("o"); else
				printf("%c", fix[i][j] ? '.' : 'x');
		printf("\n");
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> pi;
vector<pi> pos;
vector<pi> ans;
vector<pi> tmp;
string m[100];
char in[100][100];
int n;
int main()
{
    cin>>n;
    for(int i=0;i<n;i++)
    {
        cin>>m[i];
    }
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<n;j++)
        {
            if(m[i][j]!='o')
                continue;
            pos.push_back(pi(i,j));
        }
    }
    for(int i=-n;i<n;i++)
    {
        for(int j=-n;j<n;j++)
        {

            if(i==0&&j==0)
                continue;
            tmp.clear();
            int cnt=0;
            int o=0,x=0;
            int out=0,cham=0;
            for(int ij=0;ij<pos.size();ij++)
            {
                tmp.push_back(pi(pos[ij].first+i,pos[ij].second+j));
            }
            for(int ij=0;ij<tmp.size();ij++)
            {
                int xx,yy;
                xx=tmp[ij].first;
                yy=tmp[ij].second;
                if(xx<0||yy<0||xx>=n||yy>=n)
                    {
                        out++;
                        continue;
                    }
                if(m[xx][yy]=='o')
                    o++;
                if(m[xx][yy]=='x')
                    x++;
                if(m[xx][yy]=='.')
                    cham++;
            }
            if(x+o+out+cham==0||out==tmp.size()||cham==tmp.size())
                continue;
            if(cham)
            {
                if(x)
                {
                    cout<<"NO";
                    return 0;
                }
                else
                {
                    continue;
                }
            }
            if(x+o+out==tmp.size())
            {
                if(x==0)
                    continue;
                ans.push_back(pi(i,j));
                continue;
            }
            else
            {
               cout<<"NO";
                return 0;
            }
        }
    }
    for(int i=0;i<2*n-1;i++)
    {
        for(int j=0;j<2*n-1;j++)
        {
            in[i][j]='.';
        }
    }
    in[n-1][n-1]='o';
    for(int i=0;i<ans.size();i++)
    {
        in[n-1+ans[i].first][n-1+ans[i].second]='x';
    }

    cout<<"YES\n";
    for(int i=0;i<2*n-1;i++)
        {for(int j=0;j<2*n-1;j++)
        {
            cout<<in[i][j];
        }
        cout<<"\n";}
}


#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> pi;
vector<pi> pos;
vector<pi> ans;
vector<pi> tmp;
string m[100];
char in[100][100];
int check[100][100];
int n;
int main()
{
    cin>>n;
    for(int i=0;i<n;i++)
    {
        cin>>m[i];
    }
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<n;j++)
        {
            if(m[i][j]!='o')
                continue;
            pos.push_back(pi(i,j));
        }
    }
    for(int i=-n;i<n;i++)
    {
        for(int j=-n;j<n;j++)
        {

            if(i==0&&j==0)
                continue;
            tmp.clear();
            int cnt=0;
            int o=0,x=0;
            int out=0,cham=0;
            for(int ij=0;ij<pos.size();ij++)
            {
                tmp.push_back(pi(pos[ij].first+i,pos[ij].second+j));
            }
            for(int ij=0;ij<tmp.size();ij++)
            {
                int xx,yy;
                xx=tmp[ij].first;
                yy=tmp[ij].second;
                if(xx<0||yy<0||xx>=n||yy>=n)
                    {
                        out++;
                        continue;
                    }
                if(m[xx][yy]=='o')
                    o++;
                if(m[xx][yy]=='x')
                    x++;
                if(m[xx][yy]=='.')
                    cham++;
            }
            if(x+o+out+cham==0||out==tmp.size()||cham==tmp.size())
                continue;
            if(cham)
            {
                continue;
            }
            if(x+o+out==tmp.size())
            {
                if(x==0)
                    continue;
                for(int ij=0;ij<tmp.size();ij++)
                {
                    int xx,yy;
                    xx=tmp[ij].first;
                    yy=tmp[ij].second;
                    if(xx>=0&&yy>=0&&xx<n&&yy<n&&m[xx][yy]=='x')
                    {
                        check[xx][yy]=1;
                    }
                }
                ans.push_back(pi(i,j));
                continue;
            }
        }
    }
    for(int i=0;i<2*n-1;i++)
    {
        for(int j=0;j<2*n-1;j++)
        {
            in[i][j]='.';
        }
    }
    int cntx=0,cnt1=0;
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<n;j++)
        {
            if(m[i][j]=='x')
                cntx++;
            if(check[i][j]==1)
                cnt1++;
        }
    }
    if(cntx!=cnt1)
    {
        cout<<"NO";
        return 0;
    }
    in[n-1][n-1]='o';

    for(int i=0;i<ans.size();i++)
    {
        in[n-1+ans[i].first][n-1+ans[i].second]='x';
    }

    cout<<"YES\n";
    for(int i=0;i<2*n-1;i++)
        {for(int j=0;j<2*n-1;j++)
        {
            cout<<in[i][j];
        }
        cout<<"\n";}
}


#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> pi;
vector<pi> pos;
vector<pi> ans;
vector<pi> tmp;
string m[100];
char in[100][100];
int n;
int main()
{
    cin>>n;
    for(int i=0;i<n;i++)
    {
        cin>>m[i];
    }
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<n;j++)
        {
            if(m[i][j]!='o')
                continue;
            pos.push_back(pi(i,j));
        }
    }
    for(int i=-n;i<n;i++)
    {
        for(int j=-n;j<n;j++)
        {

            if(i==0&&j==0)
                continue;
            tmp.clear();
            int cnt=0;
            int o=0,x=0;
            int out=0,cham=0;
            for(int ij=0;ij<pos.size();ij++)
            {
                tmp.push_back(pi(pos[ij].first+i,pos[ij].second+j));
            }
            for(int ij=0;ij<tmp.size();ij++)
            {
                int xx,yy;
                xx=tmp[ij].first;
                yy=tmp[ij].second;
                if(xx<0||yy<0||xx>=n||yy>=n)
                    {
                        out++;
                        continue;
                    }
                if(m[xx][yy]=='o')
                    o++;
                if(m[xx][yy]=='x')
                    x++;
                if(m[xx][yy]=='.')
                    cham++;
            }
            if(x+o+out+cham==0||out==tmp.size()||cham==tmp.size())
                continue;
            if(cham)
            {
                if(x)
                {
                    cout<<"NO";
                    return 0;
                }
                else
                {
                    continue;
                }
            }
            if(x+o+out==tmp.size())
            {
                if(x==0)
                    continue;
                ans.push_back(pi(i,j));
                continue;
            }
            else
            {
               cout<<"NO";
                return 0;
            }
        }
    }
    for(int i=0;i<2*n-1;i++)
    {
        for(int j=0;j<2*n-1;j++)
        {
            in[i][j]='.';
        }
    }
    in[n-1][n-1]='o';
    for(int i=0;i<ans.size();i++)
    {
        in[n-1+ans[i].first][n-1+ans[i].second]='x';
    }

    cout<<"YES\n";
    for(int i=0;i<2*n+1;i++)
        {for(int j=0;j<2*n+1;j++)
        {
            cout<<in[i][j];
        }
        cout<<"\n";}
}


#include<iostream>
#include<cstdio>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<cassert>
#define PB push_back
#define MP make_pair
#define sz(v) (int((v).size()))
#define forn(i,n) for(int i=0;i<(n);++i)
#define forv(i,v) forn(i,sz(v))
#define fors(i,s) for(auto i=(s).begin();i!=(s).end();++i)
#define all(v) (v).begin(),(v).end()
using namespace std;
char res[200][200],mbd[200][200],sbd[200][200];
int n;
int main(){
  cin>>n;

  for(int i=0;i<n;i++) for(int j=0;j<n;j++) sbd[i][j]='.';
  for(int i=0;i<2*n-1;i++) for(int j=0;j<2*n-1;j++) res[i][j]='x';
  res[n-1][n-1]='o';
	for(int i=0;i<n;i++)
	{
		scanf("%s",mbd[i]);
    	for(int j=0;j<n;j++)if(mbd[i][j]=='o') sbd[i][j]='o';
  	}

  forn(i,n){
    forn(j,n){
      if(mbd[i][j]=='o'){
	forn(a,n){
	  forn(b,n){
	    if(mbd[a][b]=='.')
	      res[n-1+a-i][n-1+b-j]='.';
	  }
	}
      }
    }
  }
  forn(i,n){
    forn(j,n){
      if(sbd[i][j]=='o'){
	forn(a,n){
	  forn(b,n){
	    if(sbd[a][b]=='.' && res[n-1+a-i][n-1+b-j]=='x')
	      sbd[a][b]='x';
	  }
	}
      }
    }
  }
  forn(i,n){
  	forn(j,n){
  		if(sbd[i][j]!=mbd[i][j])
  		{
  			cout<<"NO"<<endl;
  	return 0;
		  }
	  }
  }
 // if(sbd==mbd){
    cout<<"YES"<<endl;
    forn(i,2*n-1)
      cout<<res[i]<<endl;
//  }
 // else
 //   cout<<"NO"<<endl;
  return 0;
}


#include <bits/stdc++.h>
#define ll long long
#define _n 2020
#define C continue
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define gc getchar
#define pc putchar
#define mem(a,b) memset(a,b,sizeof(a))
#define _for(i,a,b) for( int i=(a); i<=(b); i++)
#define _rep(i,a,b) for( int i=(a); i>=(b); i--)
using namespace std;
inline int rd()
{
    int x=0,f=1;char ch=gc();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=gc();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=gc();}
    return x*f;
}
char ch[200];
inline void rt(int x )
{
    int cnt=0,tmp=x>0?x:-x;
    if (!x) {pc('0');return;}
    if(x<0) pc('-');
    while(tmp>0) {ch[cnt++]=tmp%10+'0';tmp/=10;}
    while(cnt>0) pc(ch[--cnt]);
}
char s[60][60],c[150][150],d[60][60];
int a[1000][2];
int main()
{
	int n=rd();
	_for(i,1,n) _for(j,1,n) d[i][j]='.';
	_for(i,1,2*n-1) _for(j,1,2*n-1) c[i][j]='x';
	c[n][n]='o';

	int cnt=0;

	_for(i,1,n)
	{
		scanf("%s",s[i]+1);
		_for(j,1,n)
		{
			if (s[i][j]=='o')
			{
				cnt++;
				a[cnt][0]=i;
				a[cnt][1]=j;
				d[i][j]='o';
			}
		}
	}
	_for(i,1,n) _for(j,1,n) if (s[i][j]=='.') _for(k,1,cnt) c[n+i-a[k][0]][n+j-a[k][1]]='.';
	_for(i,1,cnt)
	{
		_for(j,1,n)
		{
			_for(k,1,n)
			{
				//��ǰj,k ԭ�� a[i][0,1]
				if (d[j][k]=='.' && c[n+j-a[i][0]][n+k-a[i][1]]=='x') d[j][k]='x';
			}
		}
	}

	_for(i,1,n)
	{
		_for(j,1,n)
		{
		//	printf("%c",d[i][j]);
			if (s[i][j]!=d[i][j])
			{
				printf("NO");
				return 0;
			}
		}
	//	printf("\n");
	}
	printf("YES\n");
	_for(i,1,2*n-1)
	{
		_for(j,1,2*n-1)
		printf("%c",c[i][j]);
		printf("\n");
	}

    return 0;
}


#include<iostream>
#include<cstdio>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<cassert>
#define PB push_back
#define MP make_pair
#define sz(v) (int((v).size()))
#define forn(i,n) for(int i=0;i<(n);++i)
#define forv(i,v) forn(i,sz(v))
#define fors(i,s) for(auto i=(s).begin();i!=(s).end();++i)
#define all(v) (v).begin(),(v).end()
using namespace std;
char res[200][200],mbd[200][200],sbd[200][200];
int n;
int main(){
  cin>>n;

  for(int i=0;i<n;i++) for(int j=0;j<n;j++) sbd[i][j]='.';
  for(int i=0;i<2*n-1;i++) for(int j=0;j<2*n-1;j++) res[i][j]='x';
  res[n-1][n-1]='o';
	for(int i=0;i<n;i++)
	{
		scanf("%s",mbd[i]);
    	for(int j=0;j<n;j++)if(mbd[i][j]=='o') sbd[i][j]='o';
  	}

  forn(i,n){
    forn(j,n){
      if(mbd[i][j]=='o'){
	forn(a,n){
	  forn(b,n){
	    if(mbd[a][b]=='.')
	      res[n-1+a-i][n-1+b-j]='.';
	  }
	}
      }
    }
  }
  forn(i,n){
    forn(j,n){
      if(sbd[i][j]=='o'){
	forn(a,n){
	  forn(b,n){
	    if(sbd[a][b]=='.' && res[n-1+a-i][n-1+b-j]=='x')
	      sbd[a][b]='x';
	  }
	}
      }
    }
  }
  if(sbd==mbd){
    cout<<"YES"<<endl;
    forn(i,2*n-1)
      cout<<res[i]<<endl;
  }
  else
    cout<<"NO"<<endl;
  return 0;
}


#include <bits/stdc++.h>
#define ll long long
#define _n 2020
#define C continue
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define gc getchar
#define pc putchar
#define mem(a,b) memset(a,b,sizeof(a))
#define _for(i,a,b) for( int i=(a); i<=(b); i++)
#define _rep(i,a,b) for( int i=(a); i>=(b); i--)
using namespace std;
inline int rd()
{
    int x=0,f=1;char ch=gc();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=gc();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=gc();}
    return x*f;
}
char ch[200];
inline void rt(int x )
{
    int cnt=0,tmp=x>0?x:-x;
    if (!x) {pc('0');return;}
    if(x<0) pc('-');
    while(tmp>0) {ch[cnt++]=tmp%10+'0';tmp/=10;}
    while(cnt>0) pc(ch[--cnt]);
}
char s[60][60],c[150][150],d[60][60];
int a[1000][2];
int main()
{
	int n=rd();
	_for(i,1,n) _for(j,1,n) d[i][j]='.';
	_for(i,1,2*n-1) _for(j,1,2*n-1) c[i][j]='x';
	c[n][n]='o';

	int cnt=0;

	_for(i,1,n)
	{
		scanf("%s",s[i]+1);
		_for(j,1,n)
		{
			if (s[i][j]=='o')
			{
				cnt++;
				a[cnt][0]=i;
				a[cnt][1]=j;
				d[i][j]='o';
			}
		}
	}
	_for(i,1,n) _for(j,1,n) if (s[i][j]=='.') _for(k,1,cnt) c[n+i-a[k][0]][n+j-a[k][1]]='.';

	_for(i,1,n)
	{
		_for(j,1,n)
		{
			if (d[i][j]=='o')
			{
				_for(k,1,n)
				{
					_for(l,1,n)
					{
						if (d[k][l]=='.' && c[n+k-i][n+l-j]=='x')
						{
							d[k][l]='x';
						}
					 }
				}
			}
		}
	}
	/*
	_for(i,1,cnt)
	{
		_for(j,1,n)
		{
			_for(k,1,n)
			{
				//��ǰj,k ԭ�� a[i][0,1]
				if (d[j][k]=='.' && c[n+j-a[i][0]][n+k-a[i][1]]=='x') d[j][k]='x';
			}
		}
	}
	*/
	_for(i,1,n)
	{
		_for(j,1,n)
		{
		//	printf("%c",d[i][j]);
			if (s[i][j]!=d[i][j])
			{
				printf("NO");
				return 0;
			}
		}
	//	printf("\n");
	}
	printf("YES\n");
	_for(i,1,2*n-1)
	{
		_for(j,1,2*n-1)
		printf("%c",c[i][j]);
		printf("\n");
	}

    return 0;
}


#include<iostream>
#include<cstdio>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<cassert>
#define PB push_back
#define MP make_pair
#define sz(v) (in((v).size()))
#define forn(i,n) for(in i=0;i<(n);++i)
#define forv(i,v) forn(i,sz(v))
#define fors(i,s) for(auto i=(s).begin();i!=(s).end();++i)
#define all(v) (v).begin(),(v).end()
using namespace std;
typedef long long in;
typedef vector<in> VI;
typedef vector<VI> VVI;
vector<string> res,mbd,sbd;
in n;
int main(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin>>n;
  mbd.resize(n);
  sbd.resize(n,string(n,'.'));
  res.resize(2*n-1,string(2*n-1,'x'));
  res[n-1][n-1]='o';
  forn(i,n){
    cin>>mbd[i];
    forn(j,n)
      if(mbd[i][j]=='o')
	sbd[i][j]='o';
  }
  forn(i,n){
    forn(j,n){
      if(mbd[i][j]=='o'){
	forn(a,n){
	  forn(b,n){
	    if(mbd[a][b]=='.')
	      res[n-1+a-i][n-1+b-j]='.';
	  }
	}
      }
    }
  }
  forn(i,n){
    forn(j,n){
      if(sbd[i][j]=='o'){
	forn(a,n){
	  forn(b,n){
	    if(sbd[a][b]=='.' && res[n-1+a-i][n-1+b-j]=='x')
	      sbd[a][b]='x';
	  }
	}
      }
    }
  }
  if(sbd==mbd){
    cout<<"YES"<<endl;
    forv(i,res)
      cout<<res[i]<<endl;
  }
  else
    cout<<"NO"<<endl;
  return 0;
}


#include <bits/stdc++.h>
#define ll long long
#define _n 2020
#define C continue
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define gc getchar
#define pc putchar
#define mem(a,b) memset(a,b,sizeof(a))
#define _for(i,a,b) for( int i=(a); i<=(b); i++)
#define _rep(i,a,b) for( int i=(a); i>=(b); i--)
using namespace std;
inline int rd()
{
    int x=0,f=1;char ch=gc();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=gc();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=gc();}
    return x*f;
}
char ch[200];
inline void rt(int x )
{
    int cnt=0,tmp=x>0?x:-x;
    if (!x) {pc('0');return;}
    if(x<0) pc('-');
    while(tmp>0) {ch[cnt++]=tmp%10+'0';tmp/=10;}
    while(cnt>0) pc(ch[--cnt]);
}
char s[60][60],c[150][150],d[60][60];
int a[1000][2];
int main()
{
	int n=rd();
	_for(i,1,n)
		scanf("%s",s[i]+1);
	int cnt=0;
	_for(i,1,n) _for(j,1,n) d[i][j]='.';
	_for(i,1,n)
	{
		_for(j,1,n)
		{
			if (s[i][j]=='o')
			{
				cnt++;
//				printf("%d %d\n",i,j);
				a[cnt][0]=i;
				a[cnt][1]=j;
				d[i][j]='o';
			}
		}
	}
//	printf("%d\n",cnt);
//	_for(i,1,cnt)
//	{
//		printf("%d %d\n",a[i][0],a[i][1]);
//	}
	_for(i,1,2*n-1) _for(j,1,2*n-1) c[i][j]='x';
	c[n][n]='o';
	_for(i,1,n) _for(j,1,n) if (s[i][j]=='.') _for(k,1,cnt) c[n+i-a[k][0]][n+j-a[k][1]]='.';
	_for(i,1,cnt)
	{
		_for(j,1,n)
		{
			_for(k,1,n)
			{
				//��ǰj,k ԭ�� a[i][0,1]
				if (d[j][k]=='.' && c[n+j-a[i][0]][n+k-a[i][1]]=='x') d[j][k]='x';
			}
		}
	}

	_for(i,1,n)
	{
		_for(j,1,n)
		{
		//	printf("%c",d[i][j]);
			if (s[i][j]!=d[i][j])
			{
				printf("NO");
				return 0;
			}
		}
	//	printf("\n");
	}
	printf("YES\n");
	_for(i,1,2*n-1)
	{
		_for(j,1,2*n-1)
		printf("%c",c[i][j]);
		printf("\n");
	}

    return 0;
}


#include <bits/stdc++.h>
#define pb push_back
#define long long long
using namespace std;
long n,i,j,visi[51][51]={0},dx,dy;
vector < pair < long , long > > v;
string s[51],a[102];
long check(long x,long y)
{
    long i,j,f=0;
    for(i=0;i<n;++i)
    for(j=0;j<n;++j)
    if(s[i][j]=='o')
    if(i+x>=0 && i+x<n && j+y>=0 && j+y<n)
    {
        if(s[i+x][j+y]!='x') return 0;
        else f=1;
    }
    for(i=0;i<n;++i)
    for(j=0;j<n;++j)
    if(s[i][j]=='o')
    if(i+x>=0 && i+x<n && j+y>=0 && j+y<n)
    if(s[i+x][j+y]=='x')
    visi[i+x][j+y]=1;
    return f;
}
int main()
{
    cin>>n;
    for(i=0;i<n;i++)
    cin>>s[i];
    for(i=-n+1;i<n;++i)
    for(j=-n+1;j<n;++j)
    if(check(i,j))
    v.pb({i,j});
    for(i=0;i<n;++i)
    for(j=0;j<n;++j)
    if(s[i][j]=='x' && visi[i][j]==0) {cout<<"NO";exit(0);}
    for(i=0;i<2*n-1;++i)
    for(j=0;j<2*n-1;++j)
    a[i].pb('.');
    for(i=0;i<v.size();++i)
    {
        dx=v[i].first;
        dy=v[i].second;
        a[n-1+dx][n-1+dy]='x';
    }
    a[n-1][n-1]='o';
    if(v.size()==0) {cout<<"NO";exit(0);}
    cout<<"YES"<<endl;
    for(i=0;i<2*n-1;++i)
    cout<<a[i]<<endl;
    return 0;
}


#include <bits/stdc++.h>
#define pb push_back
#define long long long
using namespace std;
long n,i,j,visi[51][51]={0},dx,dy;
vector < pair < long , long > > v;
string s[51],a[102];
long check(long x,long y)
{
    long i,j,f=0;
    for(i=0;i<n;++i)
    for(j=0;j<n;++j)
    if(s[i][j]=='o')
    if(i+x>=0 && i+x<n && j+y>=0 && j+y<n)
    {
        if(s[i+x][j+y]!='x') return 0;
        else f=1;
    }
    for(i=0;i<n;++i)
    for(j=0;j<n;++j)
    if(s[i][j]=='o')
    if(i+x>=0 && i+x<n && j+y>=0 && j+y<n)
    if(s[i+x][j+y]=='x')
    visi[i+x][j+y]=1;
    return f;
}
int main()
{
    long g=0;
    cin>>n;
    for(i=0;i<n;i++)
    cin>>s[i];
    for(i=-n+1;i<n;++i)
    for(j=-n+1;j<n;++j)
    if(check(i,j))
    v.pb({i,j});
    for(i=0;i<n;++i)
    for(j=0;j<n;++j)
    if(s[i][j]=='x') g=1;
    for(i=0;i<n;++i)
    for(j=0;j<n;++j)
    if(s[i][j]=='x' && visi[i][j]==0) {cout<<"NO";exit(0);}
    for(i=0;i<2*n-1;++i)
    for(j=0;j<2*n-1;++j)
    a[i].pb('.');
    for(i=0;i<v.size();++i)
    {
        dx=v[i].first;
        dy=v[i].second;
        a[n-1+dx][n-1+dy]='x';
    }
    a[n-1][n-1]='o';
    if(v.size()==0 && g==1) {cout<<"NO";exit(0);}
    cout<<"YES"<<endl;
    for(i=0;i<2*n-1;++i)
    cout<<a[i]<<endl;
    return 0;
}


#include <iostream>
#include <string>
using namespace std;
int n;
string a[64], c[64];
string ans[128];

bool pos ( int dx, int dy ) {
    for (int i = 0 ; i < n ; i ++ ) {
        for ( int j = 0 ; j < n ; j ++ ) {
            if ( a[i][j] != 'o' ) { continue; }

            if ( i + dy >= 0 && i +dy < n && j + dx >= 0 && j + dx < n ) {
                if ( a[i+dy][j+dx] == '.' ) { return 0; }
            }
        }
    }
    return 1;
}

void sett( int dx, int dy ) {

    ans[n+dx-1][n-1+dy] = 'x';

    for (int i = 0 ; i < n ; i ++ ) {
        for ( int j = 0 ; j < n ; j ++ ) {
            if ( a[i][j] != 'o' ) { continue; }

            if ( i + dy >= 0 && i +dy < n && j + dx >= 0 && j + dx < n ) {
                if ( c[i+dy][j+dx] == '.' ) { c[i+dy][j+dx] = 'x'; }
            }
        }
    }
}

int main () {
    cin >> n;
    for ( int i = 0 ; i < n ; i ++ ) {
        cin >> a[i];
        for ( int j = 0 ; j < n ; j ++ ) {
            if ( a[i][j] == 'o' ) { c[i] += 'o'; }
            else { c[i] += '.'; }
        }
    }
    for ( int i = 0 ; i < 2*n-1 ; i ++ ) {
        for ( int j = 0 ; j < 2*n-1 ; j ++ ) {
            ans[i] += '.';
        }
    }
    ans[n-1][n-1] = 'o';

    for ( int dx = -n+1; dx < n ; dx ++ ) {
        for ( int dy = -n+1 ; dy < n ; dy ++ ) {
            if ( dx == 0 && dy == 0 ) { continue; }
            if ( pos( dx, dy ) ) {
                sett( dx, dy );
            }
        }
    }

    for (int i = 0 ; i < n ; i ++ ) {
        if ( a[i] != c[i] ) { cout << "NO\n"; return 0; }
    }
    cout << "YES\n";
    for ( int i = 0 ; i <2*n-1 ; i ++ ) {
        cout << ans[i] << "\n";
    }

    return 0;
}


#include <iostream>
#include <string>
using namespace std;
int n;
string a[64], c[64];
string ans[128];

bool pos ( int dx, int dy ) {
    for (int i = 0 ; i < n ; i ++ ) {
        for ( int j = 0 ; j < n ; j ++ ) {
            if ( a[i][j] != 'o' ) { continue; }

            if ( i + dy >= 0 && i +dy < n && j + dx >= 0 && j + dx < n ) {
                if ( a[i+dy][j+dx] == '.' ) { return 0; }
            }
        }
    }
    return 1;
}

void sett( int dx, int dy ) {

    ans[n+dy-1][n-1+dx] = 'x';

    for (int i = 0 ; i < n ; i ++ ) {
        for ( int j = 0 ; j < n ; j ++ ) {
            if ( a[i][j] != 'o' ) { continue; }

            if ( i + dy >= 0 && i +dy < n && j + dx >= 0 && j + dx < n ) {
                if ( c[i+dy][j+dx] == '.' ) { c[i+dy][j+dx] = 'x'; }
            }
        }
    }
}

int main () {
    cin >> n;
    for ( int i = 0 ; i < n ; i ++ ) {
        cin >> a[i];
        for ( int j = 0 ; j < n ; j ++ ) {
            if ( a[i][j] == 'o' ) { c[i] += 'o'; }
            else { c[i] += '.'; }
        }
    }
    for ( int i = 0 ; i < 2*n-1 ; i ++ ) {
        for ( int j = 0 ; j < 2*n-1 ; j ++ ) {
            ans[i] += '.';
        }
    }
    ans[n-1][n-1] = 'o';

    for ( int dx = -n+1; dx < n ; dx ++ ) {
        for ( int dy = -n+1 ; dy < n ; dy ++ ) {
            if ( dx == 0 && dy == 0 ) { continue; }
            if ( pos( dx, dy ) ) {
                sett( dx, dy );
            }
        }
    }
    for (int i = 0 ; i < n ; i ++ ) {
        if ( a[i] != c[i] ) { cout << "NO\n"; return 0; }
    }

    cout << "YES\n";
    for ( int i = 0 ; i < 2*n-1 ; i ++ ) {
        cout << ans[i] << "\n";
    }

    return 0;
}


#include <iostream>
#include <string>
using namespace std;
int n;
string a[64], c[64];
string ans[128];

bool pos ( int dx, int dy ) {
    for (int i = 0 ; i < n ; i ++ ) {
        for ( int j = 0 ; j < n ; j ++ ) {
            if ( a[i][j] != 'o' ) { continue; }

            if ( i + dy >= 0 && i +dy < n && j + dx >= 0 && j + dx < n ) {
                if ( a[i+dy][j+dx] == '.' ) { return 0; }
            }
        }
    }
    return 1;
}

void sett( int dx, int dy ) {

    ans[n+dx-1][n-1+dy] = 'x';

    for (int i = 0 ; i < n ; i ++ ) {
        for ( int j = 0 ; j < n ; j ++ ) {
            if ( a[i][j] != 'o' ) { continue; }

            if ( i + dy >= 0 && i +dy < n && j + dx >= 0 && j + dx < n ) {
                if ( c[i+dy][j+dx] == '.' ) { c[i+dy][j+dx] = 'x'; }
            }
        }
    }
}

int main () {
    cin >> n;
    if ( n == 1 ) { cout << 12/0 << "\n"; }
    for ( int i = 0 ; i < n ; i ++ ) {
        cin >> a[i];
        for ( int j = 0 ; j < n ; j ++ ) {
            if ( a[i][j] == 'o' ) { c[i] += 'o'; }
            else { c[i] += '.'; }
        }
    }
    for ( int i = 0 ; i < 2*n-1 ; i ++ ) {
        for ( int j = 0 ; j < 2*n-1 ; j ++ ) {
            ans[i] += '.';
        }
    }
    ans[n-1][n-1] = 'o';

    for ( int dx = -n+1; dx < n ; dx ++ ) {
        for ( int dy = -n+1 ; dy < n ; dy ++ ) {
            if ( dx == 0 && dy == 0 ) { continue; }
            if ( pos( dx, dy ) ) {
                sett( dx, dy );
            }
        }
    }

    for (int i = 0 ; i < n ; i ++ ) {
        if ( a[i] != c[i] ) { cout << "NO\n"; return 0; }
    }

    cout << "YES\n";
    for ( int i = 0 ; i < 2*n-1 ; i ++ ) {
        cout << ans[i] << "\n";
    }

    return 0;
}


#include <iostream>
#include <string>
using namespace std;
int n;
string a[64], c[64];
string ans[128];

bool pos ( int dy, int dx ) {
    for (int i = 0 ; i < n ; i ++ ) {
        for ( int j = 0 ; j < n ; j ++ ) {
            if ( a[i][j] != 'o' ) { continue; }

            if ( i + dy >= 0 && i +dy < n && j + dx >= 0 && j + dx < n ) {
                if ( a[i+dy][j+dx] == '.' ) { return 0; }
            }
        }
    }
    return 1;
}

void sett( int dy, int dx ) {

    ans[n+dx-1][n-1+dy] = 'x';

    for (int i = 0 ; i < n ; i ++ ) {
        for ( int j = 0 ; j < n ; j ++ ) {
            if ( a[i][j] != 'o' ) { continue; }

            if ( i + dy >= 0 && i +dy < n && j + dx >= 0 && j + dx < n ) {
                if ( c[i+dy][j+dx] == '.' ) { c[i+dy][j+dx] = 'x'; }
            }
        }
    }
}

int main () {
    cin >> n;
    for ( int i = 0 ; i < n ; i ++ ) {
        cin >> a[i];
        for ( int j = 0 ; j < n ; j ++ ) {
            if ( a[i][j] == 'o' ) { c[i] += 'o'; }
            else { c[i] += '.'; }
        }
    }
    for ( int i = 0 ; i < 2*n-1 ; i ++ ) {
        for ( int j = 0 ; j < 2*n-1 ; j ++ ) {
            ans[i] += '.';
        }
    }
    ans[n-1][n-1] = 'o';

    for ( int dx = -n+1; dx < n ; dx ++ ) {
        for ( int dy = -n+1 ; dy < n ; dy ++ ) {
            if ( dx == 0 && dy == 0 ) { continue; }
            if ( pos( dx, dy ) ) {
                sett( dx, dy );
            }
        }
    }
    for (int i = 0 ; i < n ; i ++ ) {
        if ( a[i] != c[i] ) { cout << "NO\n"; return 0; }
    }

    cout << "YES\n";
    for ( int i = 0 ; i < 2*n-1 ; i ++ ) {
        cout << ans[i] << "\n";
    }

    return 0;
}


#include <iostream>
#include <string>
using namespace std;
int n;
string a[64], c[64];
string ans[128];

bool pos ( int dx, int dy ) {
    for (int i = 0 ; i < n ; i ++ ) {
        for ( int j = 0 ; j < n ; j ++ ) {
            if ( a[i][j] != 'o' ) { continue; }

            if ( i + dy >= 0 && i +dy < n && j + dx >= 0 && j + dx < n ) {
                if ( a[i+dy][j+dx] == '.' ) { return 0; }
            }
        }
    }
    return 1;
}

void sett( int dx, int dy ) {

    ans[n+dx-1][n-1+dy] = 'x';

    for (int i = 0 ; i < n ; i ++ ) {
        for ( int j = 0 ; j < n ; j ++ ) {
            if ( a[i][j] != 'o' ) { continue; }

            if ( i + dy >= 0 && i +dy < n && j + dx >= 0 && j + dx < n ) {
                if ( c[i+dy][j+dx] == '.' ) { c[i+dy][j+dx] = 'x'; }
            }
        }
    }
}

int main () {
    cin >> n;

    for ( int i = 0 ; i < n ; i ++ ) {
        cin >> a[i];
        for ( int j = 0 ; j < n ; j ++ ) {
            if ( a[i][j] == 'o' ) { c[i] += 'o'; }
            else { c[i] += '.'; }
        }
    }
    for ( int i = 0 ; i < 2*n-1 ; i ++ ) {
        for ( int j = 0 ; j < 2*n-1 ; j ++ ) {
            ans[i] += '.';
        }
    }
    ans[n-1][n-1] = 'o';
    bool b = 0;
    for ( int dx = -n+1; dx < n ; dx ++ ) {
        for ( int dy = -n+1 ; dy < n ; dy ++ ) {
            if ( dx == 0 && dy == 0 ) { continue; }
            if ( pos( dx, dy ) ) {
                b = 1;
                sett( dx, dy );
            }
        }
    }

    for (int i = 0 ; i < n ; i ++ ) {
        if ( !b || a[i] != c[i] ) { cout << "NO\n"; return 0; }
    }

    cout << "YES\n";
    for ( int i = 0 ; i < 2*n-1 ; i ++ ) {
        cout << ans[i] << "\n";
    }

    return 0;
}


//#include<bits/stdc++.h>
#define ll long long
#define pub push_back
#define pob pop_back
#define puf push_front
#define pof pop_front
#define mp make_pair
#define fo(i , n) for(ll i = 0 ; i < n ; i++)
#include<iomanip>
#include<cmath>
#include<cstdio>
#include<utility>
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<queue>
#include<stack>
//ios_base::sync_with_stdio(0);
//cin.tie(0); cout.tie(0);
using namespace std ;
ll gcd(ll a , ll b){ if(b > a) return gcd(b , a) ; if(b == 0) return a ; return gcd(b , a%b) ;}
int main()
{
	ll n ;
	cin >> n ;
	string str[n] ;
	fo(i , n)
	{
		cin >> str[i] ;
	}
	string ans[(2*n) - 1] ;
	fo(i , (2*n)-1)
	{
		fo(j , (2*n)-1)
		{
			ans[i] += 'x' ;
		}
	}
	ans[n-1][n-1] = 'o' ;
	/*fo(i , (2*n)-1)
		{
			fo(j , (2*n)-1)
			{
				cout << ans[i][j] ;
			}
			cout << '\n' ;
		}
	cout << '\n' ;*/
	fo(i , n)
	{
		fo(j , n)
		{
			if(str[i][j] == '.')
			{
				fo(x , n)
				{
					fo(y , n)
					{
						if(str[x][y] == 'o')
						{
							ll dx = i - x ;
							ll dy = j - y ;
							ans[(n-1) + dx][(n-1) + dy] = '.' ;

						}
					}
				}
			}
		}
	}
	int flag = 1 ;
	fo(i , n)
	{
		fo(j , n)
		{
			if(str[i][j] == 'x')
			{
			    int f = 0 ;
				fo(x , n)
				{
					fo(y , n)
					{
						if(str[x][y] == 'o')
						{
							ll dx = i - x ;
							ll dy = j - y ;
							if(ans[(n-1) + dx][(n-1) + dy] == 'x')
							{
							    //cout << "i = " << i << " j = " << j << " x = " << x << " y = " << y << endl;
							    f = 1 ;
							}

						}
					}
				}
				if(f == 0)
                    flag = 0 ;
			}
		}
	}

	ll cnt = 0 ;
	fo(i , (2*n)-1)
	{
		fo(j , (2*n)-1)
		{
			if(ans[i][j] == 'x')
				cnt++ ;
		}
	}
	if( flag == 1)
	{
		cout << "YES" << '\n' ;
		fo(i , (2*n)-1)
		{
			fo(j , (2*n)-1)
			{
				cout << ans[i][j] ;
			}
			cout << '\n' ;
		}
	}
	else
	{
		cout << "NO" << endl ;
	}
	return 0;
}


#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <queue>
#include <cstring>
#include <string>
#include <memory.h>
using namespace std;

int n, k;
pair<int, int> a[111111];
#define A(i) a[i].first

int main() {
    //freopen("in.txt", "r", stdin);

    scanf("%d%d", &n, &k);
    for(int i = 1; i <= n; i++) {
        scanf("%d", &a[i].first);
        a[i].second = i;
    }
    sort(a+1, a+1+n);
    int ret1 = (A(n)+A(n-1)) - (A(1)+A(2));
    int m1 = A(n)+A(1)+k, m2 = A(n)+A(1)+k;
    for(int i = 2; i < n; i++) {
        m1 = max(m1, A(n)+A(i));
        m2 = min(m2, A(n)+A(i));
        if (i > 2) m2 = min(m2, A(i)+A(2));
    }
    if (ret1 < m1-m2) {
        printf("%d\n", ret1);
        for(int i = 1; i <= n; i++)
            printf("1 ");
    }
    else {
        printf("%d\n", m1-m2);
        for(int i = 1; i <= n; i++)
            if (i == a[1].second) printf("1 ");
            else printf("2 ");
    }
    return 0;
}


#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <queue>
#include <cstring>
#include <string>
#include <memory.h>
using namespace std;

int n, k;
pair<int, int> a[111111];
#define A(i) a[i].first

int main() {
    //freopen("in.txt", "r", stdin);

    scanf("%d%d", &n, &k);
    for(int i = 1; i <= n; i++) {
        scanf("%d", &a[i].first);
        a[i].second = i;
    }
    sort(a+1, a+1+n);
    int ret1 = (A(n)+A(n-1)) - (A(1)+A(2));
    int m1 = A(n)+A(1)+k, m2 = A(n)+A(1)+k;
    for(int i = 2; i < n; i++) {
        m1 = max(m1, A(n)+A(i));
        m2 = min(m2, A(1)+A(i)+k);
        if (i > 2) m2 = min(m2, A(i)+A(2));
    }
    if (ret1 < m1-m2) {
        printf("%d\n", ret1);
        for(int i = 1; i <= n; i++)
            printf("1 ");
    }
    else {
        printf("%d\n", m1-m2);
        for(int i = 1; i <= n; i++)
            if (i == a[1].second) printf("1 ");
            else printf("2 ");
    }
    return 0;
}


#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <queue>
#include <cstring>
#include <string>
#include <memory.h>
using namespace std;

int n, k;
pair<int, int> a[111111];
#define A(i) a[i].first

int main() {
    //freopen("in.txt", "r", stdin);

    scanf("%d%d", &n, &k);
    for(int i = 1; i <= n; i++) {
        scanf("%d", &a[i].first);
        a[i].second = i;
    }
    sort(a+1, a+1+n);
    int ret1 = (A(n)+A(n-1)) - (A(1)+A(2));
    int m1 = A(n)+A(1)+k, m2 = A(n)+A(1)+k;
    for(int i = 2; i < n; i++) {
        m1 = max(m1, A(n)+A(i));
        m2 = min(m2, A(n)+A(i));
        if (i > 2) m2 = min(m2, A(i)+A(2));
    }
    if (ret1 < m1-m2) {
        printf("%d\n", ret1);
        for(int i = 1; i <= n; i++)
            printf("1 ");
    }
    else {
        printf("%d %d %d\n", m1, m2, m1-m2);
        for(int i = 1; i <= n; i++)
            if (i == a[1].second) printf("1 ");
            else printf("2 ");
    }
    return 0;
}


#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <queue>
#include <cstring>
#include <string>
#include <memory.h>
using namespace std;

int n, k;
pair<int, int> a[111111];
#define A(i) a[i].first
int flag[111111];

int main() {
    //freopen("in.txt", "r", stdin);

    scanf("%d%d", &n, &k);
    for(int i = 1; i <= n; i++) {
        scanf("%d", &a[i].first);
        a[i].second = i;
    }
    sort(a+1, a+1+n);
    int ret1 = (A(n)+A(n-1)) - (A(1)+A(2));
    flag[a[1].second] = 1;
    flag[a[n].second] = 2;
    int m1 = A(n)+A(1)+k, m2 = A(n)+A(1)+k;
    for(int i = 2; i < n; i++)
        if (max(m1, A(n)+A(i)+k)-min(m2, A(1)+A(i)) < max(m1, A(n)+A(i))-min(m2, A(1)+A(i)+k)) {
            m1 = max(m1, A(n)+A(i)+k);
            m2 = min(m2, A(1)+A(i));
            flag[a[i].second] = 1;
        }
        else {
            m1 = max(m1, A(n)+A(i));
            m2 = min(m2, A(1)+A(i)+k);
            flag[a[i].second] = 2;
        }
    if (ret1 < m1-m2) {
        printf("%d\n", ret1);
        for(int i = 1; i <= n; i++)
            printf("1 ");
    }
    else {
        printf("%d\n", m1-m2);
        for(int i = 1; i <= n; i++)
            printf("%d ", flag[i]);
    }
    return 0;
}


//============================================================================
// Author : PUSHKAR SINGH
//============================================================================
#include <bits/stdc++.h>
using namespace std;
// Input macros
#define s(n) scanf("%d",&n)
#define sc(n) scanf("%c",&n)
#define sl(n) scanf("%lld",&n)
#define sf(n) scanf("%lf",&n)
#define ss(n) scanf("%s",n)
#define ll long long
// Useful constants
#define INF (int)2e9
#define EPS 1e-9
// Useful hardware instructions
#define bitcount __builtin_popcount
#define gcd __gcd
// Useful container manipulation / traversal macros
#define all(a) a.begin(), a.end()
#define in(a,b) ( (b).find(a) != (b).end())
#define pb push_back
#define fill(a,v) memset(a, v, sizeof a)// fill originally
//#define sz(a) ((int)(a.size()))
#define mp make_pair

#if defined(_MSC_VER) || __cplusplus > 199711L
#define aut(r,v) auto r = (v)
#else
#define aut(r,v) typeof(v) r = (v)
#endif

//#define tr(container, it) for(auto it = container.begin(); it != container.end(); it++)
//#define tr(container, it) for(typeof(container.begin()) it = container.begin(); it != container.end(); it++)

#define tr(container, it) for(aut(it,container.begin()); it != container.end(); it++)

#define llu long long unsigned
#define ld long
/*
int scan_d() {int ip=getchar_unlocked(),ret=0,flag=1;for(;ip<'0'||ip>'9';ip=getchar_unlocked())if(ip=='-'){flag=-1;ip=getchar_unlocked();break;}for(;ip>='0'&&ip<='9';ip=getchar_unlocked())ret=ret*10+ip-'0';return flag*ret;}
ld scan_ld() {int ip=getchar_unlocked(),flag=1;ld ret=0;for(;ip<'0'||ip>'9';ip=getchar_unlocked())if(ip=='-'){flag=-1;ip=getchar_unlocked();break;}for(;ip>='0'&&ip<='9';ip=getchar_unlocked())ret=ret*10+ip-'0';return flag*ret;}
ll scan_ll() {int ip=getchar_unlocked(),flag=1;ll ret=0;for(;ip<'0'||ip>'9';ip=getchar_unlocked())if(ip=='-'){flag=-1;ip=getchar_unlocked();break;}for(;ip>='0'&&ip<='9';ip=getchar_unlocked())ret=ret*10+ip-'0';return flag*ret;}
llu scan_llu() {int ip=getchar_unlocked();llu ret=0;for(;ip<'0'||ip>'9';ip=getchar_unlocked());for(;ip>='0'&&ip<='9';ip=getchar_unlocked())ret=ret*10+ip-'0';return ret;}
//end of fast input
//fast output
//no line break
void print_d(int n) {if(n<0){n=-n;putchar_unlocked('-');}int i=10;char output_buffer[10];do{output_buffer[--i]=(n%10)+'0';n/=10;}while(n);do{putchar_unlocked(output_buffer[i]);}while(++i<10);}
void print_ld(ld n) {if(n<0){n=-n;putchar_unlocked('-');}int i=11;char output_buffer[11];do{output_buffer[--i]=(n%10)+'0';n/=10;}while(n);do{putchar_unlocked(output_buffer[i]);}while(++i<11);}
void print_ll(ll n) {if(n<0){n=-n;putchar_unlocked('-');}int i=21;char output_buffer[21];do{output_buffer[--i]=(n%10)+'0';n/=10;}while(n);do{putchar_unlocked(output_buffer[i]);}while(++i<21);}
void print_llu(llu n) {int i=21;char output_buffer[21];do{output_buffer[--i]=(n%10)+'0';n/=10;}while(n);do{putchar_unlocked(output_buffer[i]);}while(++i<21);}
*/
#define DEBUG 1
#define debug(x) {if (DEBUG)cout <<#x <<" = " <<x <<endl; }
#define debugv(x) {if (DEBUG) {cerr <<#x <<" = "; tr((x),it) cerr <<*it <<", "; cerr <<endl; }}
#define mod 1000000007

#define checkbit(n,b) ( (n >> b) & 1)
#define unsetbit(n,b) (n & (~(1 << b)))
#define INFL 0x3f3f3f3f3f3f3f3fLL
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
#define each(it,o) for(aut(it, (o).begin()); it != (o).end(); ++ it)
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<pair<int, int> > vpii;
typedef vector<long long> vl;
typedef pair<long long, long long> pll;
typedef vector<pair<long long, long long> > vpll;
typedef vector<string> vs;

ll n,h;
int data[100009];
int main()
{
    sl(n);
    sl(h);

    ll sum,mini=0,tmp,maxi;

    for(int i=0;i<n;i++)
    {
        s(data[i]);
    }

    sort(data,data+n);

    if(n == 3)
    {
        mini = data[0] + data[1];
        maxi = data[1] + data[2];
        mini = maxi - mini;

        if(data[2] + data[0] + h>= maxi)
        {
            maxi = data[2] + data[0] + h;
            tmp = data[1] + data[2];
            if(maxi-tmp < mini)
            {
                cout<<maxi-tmp<<endl;
                cout<<1<<" "<<2<<" "<<2<<endl;
                return 0;
            }
        }

        cout<<mini<<endl<<1<<" "<<1<<" "<<1<<endl;
        return 0;
    }

    maxi = data[n-1] + data[n-2];

    mini = data[0] + data[1] + h;

    if(mini > maxi)
    {
        mini = data[0] + data[1];

        cout<<maxi-mini<<endl;
        for(int i=0;i<n;i++)
            printf("1 ");
        return 0;
    }

    int indx=1;
    for(int i=1;i<n-3;i++)
    {
        tmp = data[i] + data[i+1] + h;

        if(tmp > maxi)
        {
            if(mini > (ll)data[i] + data[i+1])
            {
                indx = i;
                mini = min(mini,(ll)data[i] + data[i+1]);
            }
            break;
        }

    }

    cout<<maxi-mini<<endl;

    for(int i=0;i<n;i++)
    {
        if(i >= indx)
        {
            printf("2 ");
        }
        else printf("%d ",(i%2)+1);
    }

}


//============================================================================
// Author : PUSHKAR SINGH
//============================================================================
#include <bits/stdc++.h>
using namespace std;
// Input macros
#define s(n) scanf("%d",&n)
#define sc(n) scanf("%c",&n)
#define sl(n) scanf("%lld",&n)
#define sf(n) scanf("%lf",&n)
#define ss(n) scanf("%s",n)
#define ll long long
// Useful constants
#define INF (int)2e9
#define EPS 1e-9
// Useful hardware instructions
#define bitcount __builtin_popcount
#define gcd __gcd
// Useful container manipulation / traversal macros
#define all(a) a.begin(), a.end()
#define in(a,b) ( (b).find(a) != (b).end())
#define pb push_back
#define fill(a,v) memset(a, v, sizeof a)// fill originally
//#define sz(a) ((int)(a.size()))
#define mp make_pair

#if defined(_MSC_VER) || __cplusplus > 199711L
#define aut(r,v) auto r = (v)
#else
#define aut(r,v) typeof(v) r = (v)
#endif

//#define tr(container, it) for(auto it = container.begin(); it != container.end(); it++)
//#define tr(container, it) for(typeof(container.begin()) it = container.begin(); it != container.end(); it++)

#define tr(container, it) for(aut(it,container.begin()); it != container.end(); it++)

#define llu long long unsigned
#define ld long
/*
int scan_d() {int ip=getchar_unlocked(),ret=0,flag=1;for(;ip<'0'||ip>'9';ip=getchar_unlocked())if(ip=='-'){flag=-1;ip=getchar_unlocked();break;}for(;ip>='0'&&ip<='9';ip=getchar_unlocked())ret=ret*10+ip-'0';return flag*ret;}
ld scan_ld() {int ip=getchar_unlocked(),flag=1;ld ret=0;for(;ip<'0'||ip>'9';ip=getchar_unlocked())if(ip=='-'){flag=-1;ip=getchar_unlocked();break;}for(;ip>='0'&&ip<='9';ip=getchar_unlocked())ret=ret*10+ip-'0';return flag*ret;}
ll scan_ll() {int ip=getchar_unlocked(),flag=1;ll ret=0;for(;ip<'0'||ip>'9';ip=getchar_unlocked())if(ip=='-'){flag=-1;ip=getchar_unlocked();break;}for(;ip>='0'&&ip<='9';ip=getchar_unlocked())ret=ret*10+ip-'0';return flag*ret;}
llu scan_llu() {int ip=getchar_unlocked();llu ret=0;for(;ip<'0'||ip>'9';ip=getchar_unlocked());for(;ip>='0'&&ip<='9';ip=getchar_unlocked())ret=ret*10+ip-'0';return ret;}
//end of fast input
//fast output
//no line break
void print_d(int n) {if(n<0){n=-n;putchar_unlocked('-');}int i=10;char output_buffer[10];do{output_buffer[--i]=(n%10)+'0';n/=10;}while(n);do{putchar_unlocked(output_buffer[i]);}while(++i<10);}
void print_ld(ld n) {if(n<0){n=-n;putchar_unlocked('-');}int i=11;char output_buffer[11];do{output_buffer[--i]=(n%10)+'0';n/=10;}while(n);do{putchar_unlocked(output_buffer[i]);}while(++i<11);}
void print_ll(ll n) {if(n<0){n=-n;putchar_unlocked('-');}int i=21;char output_buffer[21];do{output_buffer[--i]=(n%10)+'0';n/=10;}while(n);do{putchar_unlocked(output_buffer[i]);}while(++i<21);}
void print_llu(llu n) {int i=21;char output_buffer[21];do{output_buffer[--i]=(n%10)+'0';n/=10;}while(n);do{putchar_unlocked(output_buffer[i]);}while(++i<21);}
 */
#define DEBUG 1
#define debug(x) {if (DEBUG)cout <<#x <<" = " <<x <<endl; }
#define debugv(x) {if (DEBUG) {cerr <<#x <<" = "; tr((x),it) cerr <<*it <<", "; cerr <<endl; }}
#define mod 1000000007

#define checkbit(n,b) ( (n >> b) & 1)
#define unsetbit(n,b) (n & (~(1 << b)))
#define INFL 0x3f3f3f3f3f3f3f3fLL
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
#define each(it,o) for(aut(it, (o).begin()); it != (o).end(); ++ it)
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<pair<int, int> > vpii;
typedef vector<long long> vl;
typedef pair<long long, long long> pll;
typedef vector<pair<long long, long long> > vpll;
typedef vector<string> vs;

ll n,h;
int data[100009];
pii da[100009];
int maping[100009];
int main()
{
    sl(n);
    sl(h);

    ll sum,mini=0,tmp,maxi;

    for(int i=0;i<n;i++)
    {
        s(data[i]);

        da[i].first = data[i];
        da[i].second = i;

    }

    sort(da,da+n);

    sort(data,data+n);

    if(n == 3)
    {
        mini = data[0] + data[1];
        maxi = data[1] + data[2];
        mini = maxi - mini;

        ll maximum  = max(data[2] + data[0] + h,maxi);
        ll minimum = min(data[1] + (ll)data[2], data[0] + data[1] + h);
        ll mini2 = maximum - minimum;
        if(mini2< mini)
        {
                cout<<mini2<<endl;
                maping[da[0].second] = 1;
                maping[da[1].second] = 2;
                maping[da[2].second] = 2;

                for(int i=0;i<3;i++) printf("%d ",maping[i]);
                return 0;

        }

        cout<<mini<<endl<<1<<" "<<1<<" "<<1<<endl;
        return 0;
    }

    maxi = data[n-1] + data[n-2];

    mini = data[0] + data[1];

    ll mini1 = maxi-mini;

    maxi = max(data[n-1] + (ll)data[n-2],data[n-1] + data[0] + h);
    mini = data[0] + data[1] + h;

    for(int i=1;i<n-1;i++)
    {
        mini = min(mini,data[i] + (ll)data[i+1]);
    }

    ll mini2 = maxi-mini;

    if(mini1 > mini2)
    {

        cout<<mini2<<endl;

        maping[da[0].second] = 1;
        for(int i=1;i<n;i++)
        {
            maping[da[i].second] = 2;
        }

        for(int i=0;i<n;i++)
        {
            printf("%d ",maping[i]);
        }
    }
    else
    {
        cout<<mini1<<endl;

        for(int i=0;i<n;i++)
        {printf("1 ");
        }

    }

}


//============================================================================
// Author : PUSHKAR SINGH
//============================================================================
#include <bits/stdc++.h>
using namespace std;
// Input macros
#define s(n) scanf("%d",&n)
#define sc(n) scanf("%c",&n)
#define sl(n) scanf("%lld",&n)
#define sf(n) scanf("%lf",&n)
#define ss(n) scanf("%s",n)
#define ll long long
// Useful constants
#define INF (int)2e9
#define EPS 1e-9
// Useful hardware instructions
#define bitcount __builtin_popcount
#define gcd __gcd
// Useful container manipulation / traversal macros
#define all(a) a.begin(), a.end()
#define in(a,b) ( (b).find(a) != (b).end())
#define pb push_back
#define fill(a,v) memset(a, v, sizeof a)// fill originally
//#define sz(a) ((int)(a.size()))
#define mp make_pair

#if defined(_MSC_VER) || __cplusplus > 199711L
#define aut(r,v) auto r = (v)
#else
#define aut(r,v) typeof(v) r = (v)
#endif

//#define tr(container, it) for(auto it = container.begin(); it != container.end(); it++)
//#define tr(container, it) for(typeof(container.begin()) it = container.begin(); it != container.end(); it++)

#define tr(container, it) for(aut(it,container.begin()); it != container.end(); it++)

#define llu long long unsigned
#define ld long
/*
int scan_d() {int ip=getchar_unlocked(),ret=0,flag=1;for(;ip<'0'||ip>'9';ip=getchar_unlocked())if(ip=='-'){flag=-1;ip=getchar_unlocked();break;}for(;ip>='0'&&ip<='9';ip=getchar_unlocked())ret=ret*10+ip-'0';return flag*ret;}
ld scan_ld() {int ip=getchar_unlocked(),flag=1;ld ret=0;for(;ip<'0'||ip>'9';ip=getchar_unlocked())if(ip=='-'){flag=-1;ip=getchar_unlocked();break;}for(;ip>='0'&&ip<='9';ip=getchar_unlocked())ret=ret*10+ip-'0';return flag*ret;}
ll scan_ll() {int ip=getchar_unlocked(),flag=1;ll ret=0;for(;ip<'0'||ip>'9';ip=getchar_unlocked())if(ip=='-'){flag=-1;ip=getchar_unlocked();break;}for(;ip>='0'&&ip<='9';ip=getchar_unlocked())ret=ret*10+ip-'0';return flag*ret;}
llu scan_llu() {int ip=getchar_unlocked();llu ret=0;for(;ip<'0'||ip>'9';ip=getchar_unlocked());for(;ip>='0'&&ip<='9';ip=getchar_unlocked())ret=ret*10+ip-'0';return ret;}
//end of fast input
//fast output
//no line break
void print_d(int n) {if(n<0){n=-n;putchar_unlocked('-');}int i=10;char output_buffer[10];do{output_buffer[--i]=(n%10)+'0';n/=10;}while(n);do{putchar_unlocked(output_buffer[i]);}while(++i<10);}
void print_ld(ld n) {if(n<0){n=-n;putchar_unlocked('-');}int i=11;char output_buffer[11];do{output_buffer[--i]=(n%10)+'0';n/=10;}while(n);do{putchar_unlocked(output_buffer[i]);}while(++i<11);}
void print_ll(ll n) {if(n<0){n=-n;putchar_unlocked('-');}int i=21;char output_buffer[21];do{output_buffer[--i]=(n%10)+'0';n/=10;}while(n);do{putchar_unlocked(output_buffer[i]);}while(++i<21);}
void print_llu(llu n) {int i=21;char output_buffer[21];do{output_buffer[--i]=(n%10)+'0';n/=10;}while(n);do{putchar_unlocked(output_buffer[i]);}while(++i<21);}
 */
#define DEBUG 1
#define debug(x) {if (DEBUG)cout <<#x <<" = " <<x <<endl; }
#define debugv(x) {if (DEBUG) {cerr <<#x <<" = "; tr((x),it) cerr <<*it <<", "; cerr <<endl; }}
#define mod 1000000007

#define checkbit(n,b) ( (n >> b) & 1)
#define unsetbit(n,b) (n & (~(1 << b)))
#define INFL 0x3f3f3f3f3f3f3f3fLL
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
#define each(it,o) for(aut(it, (o).begin()); it != (o).end(); ++ it)
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<pair<int, int> > vpii;
typedef vector<long long> vl;
typedef pair<long long, long long> pll;
typedef vector<pair<long long, long long> > vpll;
typedef vector<string> vs;

ll n,h;
int data[100009];
int main()
{
    sl(n);
    sl(h);

    ll sum,mini=0,tmp,maxi;

    for(int i=0;i<n;i++)
    {
        s(data[i]);
    }

    sort(data,data+n);

    if(n == 3)
    {
        mini = data[0] + data[1];
        maxi = data[1] + data[2];
        mini = maxi - mini;

        if(data[2] + data[0] + h>= maxi)
        {
            maxi = data[2] + data[0] + h;
            tmp = data[1] + data[2];
            if(maxi-tmp < mini)
            {
                cout<<maxi-tmp<<endl;
                cout<<1<<" "<<2<<" "<<2<<endl;
                return 0;
            }
        }

        cout<<mini<<endl<<1<<" "<<1<<" "<<1<<endl;
        return 0;
    }

    maxi = data[n-1] + data[n-2];

    mini = data[0] + data[1];

    ll mini1 = maxi-mini;

    maxi = max(data[n-1] + (ll)data[n-2],data[n-1] + data[0] + h);
    mini = data[0] + data[1] + h;

    for(int i=1;i<n-1;i++)
    {
        mini = min(mini,data[i] + (ll)data[i+1]);
    }

    ll mini2 = maxi-mini;

    if(mini1 > mini2)
    {

        cout<<mini2<<endl;

        for(int i=0;i<n;i++)
        {
            if(i >= 1)
            {
                printf("2 ");
            }
            else printf("1 ");
        }

    }
    else
    {
        cout<<mini1<<endl;

        for(int i=0;i<n;i++)
        {printf("1 ");
        }

    }

}


//============================================================================
// Author : PUSHKAR SINGH
//============================================================================
#include <bits/stdc++.h>
using namespace std;
// Input macros
#define s(n) scanf("%d",&n)
#define sc(n) scanf("%c",&n)
#define sl(n) scanf("%lld",&n)
#define sf(n) scanf("%lf",&n)
#define ss(n) scanf("%s",n)
#define ll long long
// Useful constants
#define INF (int)2e9
#define EPS 1e-9
// Useful hardware instructions
#define bitcount __builtin_popcount
#define gcd __gcd
// Useful container manipulation / traversal macros
#define all(a) a.begin(), a.end()
#define in(a,b) ( (b).find(a) != (b).end())
#define pb push_back
#define fill(a,v) memset(a, v, sizeof a)// fill originally
//#define sz(a) ((int)(a.size()))
#define mp make_pair

#if defined(_MSC_VER) || __cplusplus > 199711L
#define aut(r,v) auto r = (v)
#else
#define aut(r,v) typeof(v) r = (v)
#endif

//#define tr(container, it) for(auto it = container.begin(); it != container.end(); it++)
//#define tr(container, it) for(typeof(container.begin()) it = container.begin(); it != container.end(); it++)

#define tr(container, it) for(aut(it,container.begin()); it != container.end(); it++)

#define llu long long unsigned
#define ld long

int scan_d() {int ip=getchar_unlocked(),ret=0,flag=1;for(;ip<'0'||ip>'9';ip=getchar_unlocked())if(ip=='-'){flag=-1;ip=getchar_unlocked();break;}for(;ip>='0'&&ip<='9';ip=getchar_unlocked())ret=ret*10+ip-'0';return flag*ret;}
ld scan_ld() {int ip=getchar_unlocked(),flag=1;ld ret=0;for(;ip<'0'||ip>'9';ip=getchar_unlocked())if(ip=='-'){flag=-1;ip=getchar_unlocked();break;}for(;ip>='0'&&ip<='9';ip=getchar_unlocked())ret=ret*10+ip-'0';return flag*ret;}
ll scan_ll() {int ip=getchar_unlocked(),flag=1;ll ret=0;for(;ip<'0'||ip>'9';ip=getchar_unlocked())if(ip=='-'){flag=-1;ip=getchar_unlocked();break;}for(;ip>='0'&&ip<='9';ip=getchar_unlocked())ret=ret*10+ip-'0';return flag*ret;}
llu scan_llu() {int ip=getchar_unlocked();llu ret=0;for(;ip<'0'||ip>'9';ip=getchar_unlocked());for(;ip>='0'&&ip<='9';ip=getchar_unlocked())ret=ret*10+ip-'0';return ret;}
//end of fast input
//fast output
//no line break
void print_d(int n) {if(n<0){n=-n;putchar_unlocked('-');}int i=10;char output_buffer[10];do{output_buffer[--i]=(n%10)+'0';n/=10;}while(n);do{putchar_unlocked(output_buffer[i]);}while(++i<10);}
void print_ld(ld n) {if(n<0){n=-n;putchar_unlocked('-');}int i=11;char output_buffer[11];do{output_buffer[--i]=(n%10)+'0';n/=10;}while(n);do{putchar_unlocked(output_buffer[i]);}while(++i<11);}
void print_ll(ll n) {if(n<0){n=-n;putchar_unlocked('-');}int i=21;char output_buffer[21];do{output_buffer[--i]=(n%10)+'0';n/=10;}while(n);do{putchar_unlocked(output_buffer[i]);}while(++i<21);}
void print_llu(llu n) {int i=21;char output_buffer[21];do{output_buffer[--i]=(n%10)+'0';n/=10;}while(n);do{putchar_unlocked(output_buffer[i]);}while(++i<21);}

#define DEBUG 1
#define debug(x) {if (DEBUG)cout <<#x <<" = " <<x <<endl; }
#define debugv(x) {if (DEBUG) {cerr <<#x <<" = "; tr((x),it) cerr <<*it <<", "; cerr <<endl; }}
#define mod 1000000007

#define checkbit(n,b) ( (n >> b) & 1)
#define unsetbit(n,b) (n & (~(1 << b)))
#define INFL 0x3f3f3f3f3f3f3f3fLL
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
#define each(it,o) for(aut(it, (o).begin()); it != (o).end(); ++ it)
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<pair<int, int> > vpii;
typedef vector<long long> vl;
typedef pair<long long, long long> pll;
typedef vector<pair<long long, long long> > vpll;
typedef vector<string> vs;

ll n,h;
int data[100009];
int main()
{
    sl(n);
    sl(h);

    ll sum,mini=0,tmp,maxi;

    for(int i=0;i<n;i++)
    {
        s(data[i]);
    }

    sort(data,data+n);

    if(n == 3)
    {
        mini = data[0] + data[1];
        maxi = data[1] + data[2];
        mini = maxi - mini;

        if(data[2] + data[0] + h>= maxi)
        {
            maxi = data[2] + data[0] + h;
            tmp = data[1] + data[2];
            if(maxi-tmp < mini)
            {
                cout<<maxi-tmp<<endl;
                cout<<1<<" "<<2<<" "<<2<<endl;
                return 0;
            }
        }

        cout<<mini<<endl<<1<<" "<<1<<" "<<1<<endl;
        return 0;
    }

    maxi = data[n-1] + data[n-2];

    mini = data[0] + data[1] + h;

    if(mini > maxi)
    {
        mini = data[0] + data[1];

        cout<<maxi-mini<<endl;
        for(int i=0;i<n;i++)
            printf("1 ");
        return 0;
    }

    int indx=1;
    for(int i=1;i<n-3;i++)
    {
        tmp = data[i] + data[i+1] + h;

        if(tmp > maxi)
        {
            if(mini > (ll)data[i] + data[i+1])
            {
                indx = i;
                mini = min(mini,(ll)data[i] + data[i+1]);
            }
            break;
        }

    }

    cout<<maxi-mini<<endl;

    for(int i=0;i<n;i++)
    {
        if(i >= indx)
        {
            printf("2 ");
        }
        else printf("%d ",(i%2)+1);
    }

}


//============================================================================
// Author : PUSHKAR SINGH
//============================================================================
#include <bits/stdc++.h>
using namespace std;
// Input macros
#define s(n) scanf("%d",&n)
#define sc(n) scanf("%c",&n)
#define sl(n) scanf("%lld",&n)
#define sf(n) scanf("%lf",&n)
#define ss(n) scanf("%s",n)
#define ll long long
// Useful constants
#define INF (int)2e9
#define EPS 1e-9
// Useful hardware instructions
#define bitcount __builtin_popcount
#define gcd __gcd
// Useful container manipulation / traversal macros
#define all(a) a.begin(), a.end()
#define in(a,b) ( (b).find(a) != (b).end())
#define pb push_back
#define fill(a,v) memset(a, v, sizeof a)// fill originally
//#define sz(a) ((int)(a.size()))
#define mp make_pair

#if defined(_MSC_VER) || __cplusplus > 199711L
#define aut(r,v) auto r = (v)
#else
#define aut(r,v) typeof(v) r = (v)
#endif

//#define tr(container, it) for(auto it = container.begin(); it != container.end(); it++)
//#define tr(container, it) for(typeof(container.begin()) it = container.begin(); it != container.end(); it++)

#define tr(container, it) for(aut(it,container.begin()); it != container.end(); it++)

#define llu long long unsigned
#define ld long
/*
int scan_d() {int ip=getchar_unlocked(),ret=0,flag=1;for(;ip<'0'||ip>'9';ip=getchar_unlocked())if(ip=='-'){flag=-1;ip=getchar_unlocked();break;}for(;ip>='0'&&ip<='9';ip=getchar_unlocked())ret=ret*10+ip-'0';return flag*ret;}
ld scan_ld() {int ip=getchar_unlocked(),flag=1;ld ret=0;for(;ip<'0'||ip>'9';ip=getchar_unlocked())if(ip=='-'){flag=-1;ip=getchar_unlocked();break;}for(;ip>='0'&&ip<='9';ip=getchar_unlocked())ret=ret*10+ip-'0';return flag*ret;}
ll scan_ll() {int ip=getchar_unlocked(),flag=1;ll ret=0;for(;ip<'0'||ip>'9';ip=getchar_unlocked())if(ip=='-'){flag=-1;ip=getchar_unlocked();break;}for(;ip>='0'&&ip<='9';ip=getchar_unlocked())ret=ret*10+ip-'0';return flag*ret;}
llu scan_llu() {int ip=getchar_unlocked();llu ret=0;for(;ip<'0'||ip>'9';ip=getchar_unlocked());for(;ip>='0'&&ip<='9';ip=getchar_unlocked())ret=ret*10+ip-'0';return ret;}
//end of fast input
//fast output
//no line break
void print_d(int n) {if(n<0){n=-n;putchar_unlocked('-');}int i=10;char output_buffer[10];do{output_buffer[--i]=(n%10)+'0';n/=10;}while(n);do{putchar_unlocked(output_buffer[i]);}while(++i<10);}
void print_ld(ld n) {if(n<0){n=-n;putchar_unlocked('-');}int i=11;char output_buffer[11];do{output_buffer[--i]=(n%10)+'0';n/=10;}while(n);do{putchar_unlocked(output_buffer[i]);}while(++i<11);}
void print_ll(ll n) {if(n<0){n=-n;putchar_unlocked('-');}int i=21;char output_buffer[21];do{output_buffer[--i]=(n%10)+'0';n/=10;}while(n);do{putchar_unlocked(output_buffer[i]);}while(++i<21);}
void print_llu(llu n) {int i=21;char output_buffer[21];do{output_buffer[--i]=(n%10)+'0';n/=10;}while(n);do{putchar_unlocked(output_buffer[i]);}while(++i<21);}
 */
#define DEBUG 1
#define debug(x) {if (DEBUG)cout <<#x <<" = " <<x <<endl; }
#define debugv(x) {if (DEBUG) {cerr <<#x <<" = "; tr((x),it) cerr <<*it <<", "; cerr <<endl; }}
#define mod 1000000007

#define checkbit(n,b) ( (n >> b) & 1)
#define unsetbit(n,b) (n & (~(1 << b)))
#define INFL 0x3f3f3f3f3f3f3f3fLL
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
#define each(it,o) for(aut(it, (o).begin()); it != (o).end(); ++ it)
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<pair<int, int> > vpii;
typedef vector<long long> vl;
typedef pair<long long, long long> pll;
typedef vector<pair<long long, long long> > vpll;
typedef vector<string> vs;

ll n,h;
int data[100009];
pii da[100009];
int maping[100009];
int main()
{
    sl(n);
    sl(h);

    ll sum,mini=0,tmp,maxi;

    for(int i=0;i<n;i++)
    {
        s(data[i]);

        da[i].first = data[i];
        da[i].second = i;

    }

    sort(da,da+n);

    sort(data,data+n);

    if(n == 3)
    {
        mini = data[0] + data[1];
        maxi = data[1] + data[2];
        mini = maxi - mini;

        if(data[2] + data[0] + h>= maxi)
        {
            maxi = data[2] + data[0] + h;
            tmp = data[1] + data[2];
            if(maxi-tmp < mini)
            {
                cout<<maxi-tmp<<endl;
                maping[da[0].second] = 1;
                maping[da[1].second] = 2;
                maping[da[2].second] = 2;

                for(int i=0;i<3;i++) printf("%d ",maping[i]);
                return 0;
            }
        }

        cout<<mini<<endl<<1<<" "<<1<<" "<<1<<endl;
        return 0;
    }

    maxi = data[n-1] + data[n-2];

    mini = data[0] + data[1];

    ll mini1 = maxi-mini;

    maxi = max(data[n-1] + (ll)data[n-2],data[n-1] + data[0] + h);
    mini = data[0] + data[1] + h;

    for(int i=1;i<n-1;i++)
    {
        mini = min(mini,data[i] + (ll)data[i+1]);
    }

    ll mini2 = maxi-mini;

    if(mini1 > mini2)
    {

        cout<<mini2<<endl;

        maping[da[0].second] = 1;
        for(int i=1;i<n;i++)
        {
            maping[da[i].second] = 2;
        }

        for(int i=0;i<n;i++)
        {
            printf("%d ",maping[i]);
        }
    }
    else
    {
        cout<<mini1<<endl;

        for(int i=0;i<n;i++)
        {printf("1 ");
        }

    }

}


#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<iostream>
#include<algorithm>
using namespace std;
const int inf=1<<30;
int n,m;
int a[100101],s[100100],u[100100];
bool cmp(const int &A,const int &B)
{
	return a[A]>a[B];
}
void Gans()
{
	int A=0,ans=inf,e[100];
	e[1]=1;
	for(int i=2;i<=n;++i) e[i]=e[i-1]<<1;
	for(int k=0;k<(1<<n);++k)
	{
		int x=inf,y=-inf,p;
		for(int i=1;i<=n;++i)
			for(int j=i+1;j<=n;++j)
			{
				if ( ((k&e[i])>0)==((k&e[j])>0) ) p=a[i]+a[j];
					else p=a[i]+a[j]+m;
				if ( p>y ) y=p;
				if ( p<x ) x=p;
			}
		if ( ans>y-x ) ans=y-x,A=k;
	}
	cout<<ans<<endl;
	for(int i=1;i<=n;++i)
		printf("%d ",A&e[i]?1:2);
}
void work()
{
	sort(s+1,s+1+n,cmp);
	int A=0,ans=inf;
	for(int i=2;i<n;++i)
	{
		int X=-inf,Y=inf,Z;
		if ( i>2 ) X=Y=a[s[1]]+a[s[2]];
		Z=a[s[1]]+a[s[i]]+m;
		if ( Z>X ) X=Z;
		if ( Z<Y ) Y=Z;
		Z=a[s[n]]+a[s[i-1]];
		if ( Z>X ) X=Z;
		if ( Z<Y ) Y=Z;
		Z=a[s[n]]+a[s[n-1]]+m;
		if ( Z>X ) X=Z;
		if ( Z<Y ) Y=Z;
		if ( i+1<n )
		{
			Z=a[s[n-1]]+a[s[n-2]];
			if ( Z>X ) X=Z;
			if ( Z<Y ) Y=Z;
		}
		if ( X-Y<ans ) ans=X-Y,A=i;
	}
	int X=a[s[1]]+max(a[s[n]]+m,a[s[2]]),Y=a[s[n-1]]+min(a[s[n]]+m,a[s[n-2]]);
	if ( X-Y<ans ) ans=Y-X,A=1;
	X=a[s[1]]+a[s[2]],Y=a[s[n]]+a[s[n-1]];
	if ( X-Y<ans ) ans=X-Y,A=0;
	cout<<ans<<endl;
	if ( A==0 )
	{
		for(int i=1;i<=n;++i)
		printf("1 ");
	}else if ( A==1 )
	{
		for(int i=1;i<=n;++i)
			u[s[i]]=1;
		u[s[n]]=2;
		for(int i=1;i<=n;++i)
			printf("%d ",u[i]);
	}else{
		u[s[n]]=1;
		for(int i=1;i<A;++i)
			u[s[i]]=1;
		for(int i=A;i<n;++i)
			u[s[i]]=2;
		for(int i=1;i<=n;++i)
			printf("%d ",u[i]);
	}
}
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;++i)
		scanf("%d",&a[i]),s[i]=i;
	if ( n<=8 ) Gans();
	else work();
	return 0;
}


#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<iostream>
#include<algorithm>
using namespace std;
const int inf=1<<30;
int n,m;
int a[100101],s[100100],u[100100];
bool cmp(const int &A,const int &B)
{
	return a[A]>a[B];
}
void Gans()
{
	int A=0,ans=inf,e[100];
	e[1]=1;
	for(int i=2;i<=n;++i) e[i]=e[i-1]<<1;
	for(int k=0;k<(1<<n);++k)
	{
		int x=inf,y=-inf,p;
		for(int i=1;i<=n;++i)
			for(int j=i+1;j<=n;++j)
			{
				if ( ((k&e[i])>0)==((k&e[j])>0) ) p=a[i]+a[j];
					else p=a[i]+a[j]+m;
				if ( p>y ) y=p;
				if ( p<x ) x=p;
			}
		if ( ans>y-x ) ans=y-x,A=k;
	}
	cout<<ans<<endl;
	for(int i=1;i<=n;++i)
		printf("%d ",A&e[i]?1:2);
}
void work()
{
	sort(s+1,s+1+n,cmp);
	int A=0,ans=inf;
	for(int i=2;i<n;++i)
	{
		int X=-inf,Y=inf,Z;
		if ( i>2 ) X=Y=a[s[1]]+a[s[2]];
		Z=a[s[1]]+a[s[i]]+m;
		if ( Z>X ) X=Z;
		if ( Z<Y ) Y=Z;
		Z=a[s[n]]+a[s[i-1]];
		if ( Z>X ) X=Z;
		if ( Z<Y ) Y=Z;
		Z=a[s[n]]+a[s[n-1]]+m;
		if ( Z>X ) X=Z;
		if ( Z<Y ) Y=Z;
		if ( i+1<n )
		{
			Z=a[s[n-1]]+a[s[n-2]];
			if ( Z>X ) X=Z;
			if ( Z<Y ) Y=Z;
		}
		if ( X-Y<ans ) ans=X-Y,A=i;
	}
	int X=a[s[1]]+max(a[s[n]]+m,a[s[2]]),Y=a[s[n-1]]+min(a[s[n]]+m,a[s[n-2]]);
	if ( X-Y<ans ) ans=X-Y,A=1;
	X=a[s[1]]+a[s[2]],Y=a[s[n]]+a[s[n-1]];
	if ( X-Y<ans ) ans=X-Y,A=0;
	cout<<ans<<endl;
	if ( A==0 )
	{
		for(int i=1;i<=n;++i)
		printf("1 ");
	}else if ( A==1 )
	{
		for(int i=1;i<=n;++i)
			u[s[i]]=1;
		u[s[n]]=2;
		for(int i=1;i<=n;++i)
			printf("%d ",u[i]);
	}else{
		u[s[n]]=1;
		for(int i=1;i<A;++i)
			u[s[i]]=1;
		for(int i=A;i<n;++i)
			u[s[i]]=2;
		for(int i=1;i<=n;++i)
			printf("%d ",u[i]);
	}
}
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;++i)
		scanf("%d",&a[i]),s[i]=i;
	if ( n<=8 ) Gans();
	else work();
	return 0;
}


#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<iostream>
#include<algorithm>
using namespace std;
const int inf=1<<30;
int n,m;
int a[100101],s[100100],u[100100];
bool cmp(const int &A,const int &B)
{
	return a[A]>a[B];
}
void Gans()
{
	int A=0,ans=inf,e[100];
	e[1]=1;
	for(int i=2;i<=n;++i) e[i]=e[i-1]<<1;
	for(int k=0;k<(1<<n);++k)
	{
		int x=inf,y=-inf,p;
		for(int i=1;i<=n;++i)
			for(int j=i+1;j<=n;++j)
			{
				if ( ((k&e[i])>0)==((k&e[j])>0) ) p=a[i]+a[j];
					else p=a[i]+a[j]+m;
				if ( p>y ) y=p;
				if ( p<x ) x=p;
			}
		if ( ans>y-x ) ans=y-x,A=k;
	}
	cout<<ans<<endl;
	for(int i=1;i<=n;++i)
		printf("%d ",A&e[i]?1:2);
}
void work()
{
	sort(s+1,s+1+n,cmp);
	int A=0,ans=inf;
	for(int i=2;i<n;++i)
	{
		int X=-inf,Y=inf,Z;
		if ( i>2 ) X=Y=a[s[1]]+a[s[2]];
		Z=a[s[1]]+a[s[i]]+m;
		if ( Z>X ) X=Z;
		if ( Z<Y ) Y=Z;
		Z=a[s[n]]+a[s[i-1]];
		if ( Z>X ) X=Z;
		if ( Z<Y ) Y=Z;
		Z=a[s[n]]+a[s[2]]+m;
		if ( Z>X ) X=Z;
		if ( Z<Y ) Y=Z;
		if ( i+1<n )
		{
			Z=a[s[n-1]]+a[s[n-2]];
			if ( Z>X ) X=Z;
			if ( Z<Y ) Y=Z;
		}
		if ( X-Y<ans ) ans=X-Y,A=i;
	}
	int X=a[s[1]]+max(a[s[n]]+m,a[s[2]]),Y=a[s[n-1]]+min(a[s[n]]+m,a[s[n-2]]);
	if ( X-Y<ans ) ans=Y-X,A=1;
	X=a[s[1]]+a[s[2]],Y=a[s[n]]+a[s[n-1]];
	if ( X-Y<ans ) ans=X-Y,A=0;
	cout<<ans<<endl;
	if ( A==0 )
	{
		for(int i=1;i<=n;++i)
		printf("1 ");
	}else if ( A==1 )
	{
		for(int i=1;i<=n;++i)
			u[s[i]]=1;
		u[s[n]]=2;
		for(int i=1;i<=n;++i)
			printf("%d ",u[i]);
	}else{
		u[s[n]]=1;
		for(int i=1;i<A;++i)
			u[s[i]]=1;
		for(int i=A;i<n;++i)
			u[s[i]]=2;
		for(int i=1;i<=n;++i)
			printf("%d ",u[i]);
	}
}
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;++i)
		scanf("%d",&a[i]),s[i]=i;
	if ( n<=8 ) Gans();
	else work();
	return 0;
}


#include <bits/stdc++.h>
using namespace std;

typedef long long LL;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;
typedef pair<int, LL> PIL;
typedef pair<LL, int> PLI;
typedef vector<int> VI;
typedef vector<PII> VPII;
typedef double DB;

#define pb push_back
#define mset(a, b) memset(a, b, sizeof a)
#define all(x) (x).begin(), (x).end()
#define bit(x) (1 << (x))
#define bitl(x) (1LL << (x))
#define sqr(x) ((x) * (x))
#define sz(x) ((int)(x.size()))
#define cnti(x) (__builtin_popcount(x))
#define cntl(x) (__builtin_popcountll(x))
#define clzi(x) (__builtin_clz(x))
#define clzl(x) (__builtin_clzll(x))
#define ctzi(x) (__builtin_ctz(x))
#define ctzl(x) (__builtin_ctzll(x))

#define X first
#define Y second

#define Error(x) cout << #x << " = " << x << endl

template <typename T, typename U>
inline void chkmax(T& x, U y) {
	if (x < y) x = y;
}

template <typename T, typename U>
inline void chkmin(T& x, U y) {
	if (y < x) x = y;
}

const int MAXN = 111111;

int a[MAXN], id[MAXN], ret[MAXN];

bool cmp(int u, int v) {
	return a[u] < a[v];
}

int main() {
	int n; int h; cin >> n >> h;
	for (int i = 1; i <= n; i++) scanf("%d", &a[i]), id[i] = i;
	sort(id + 1, id + n + 1, cmp);
	for (int i = 1; i <= n; i++) ret[i] = 1;
	int ans = a[id[n]] + a[id[n-1]] - a[id[1]] - a[id[2]];
	if (n > 2) {
		int ans1 = max(a[id[n]] + a[id[n-1]], a[id[n]] + a[id[1]] + h) - min(a[id[2]] + a[id[3]], a[id[1]] + a[id[2]] + h);
		if (ans > ans1) {
			ans = ans1;
			for (int i = 2; i <= n; i++) ret[id[i]] = 2;
		}
	}
	cout << ans << endl;
	for (int i = 1; i <= n; i++) printf("%d%c", ret[i], i < n ? ' ' : '\n');
	return 0;
}


/*
链接：http://codeforces.com/problemset/problem/238/B
题意：把n个数a1,a2,...an分成两组,定义f(ai,aj)=ai+aj(当i,j在同一组），f(ai,aj)=ai+aj+h(当ai+aj在不同组)，
给你n,a1,a2,...,an，你需要求出maxf-minf最小的划分。
思路：
未解决点：
*/
#include<bits/stdc++.h>
int main(){return 0;}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;

const ll MOD = 1e9 + 9;
const int N = 1e5 + 7;

ll bpow(ll a, ll b)
{
     ll ans = 1;
     while (b)
     {
          ans *= (b & 1 ? a : 1), ans %= MOD;
          a *= a, a %= MOD;
          b >>= 1;
     }
     return ans;
}

int main()
{
     ios::sync_with_stdio(false);
     cin.tie(0);
     cout.tie(0);

     int n, m;
     cin >> n >> m;

     ll ans = 1;
     ll num = bpow(2, m);

     for (int i=0; i<n; i++)
          ans *= ((num - i - 1) % MOD + MOD) % MOD, ans %= MOD;

     cout << ans << "\n";

     return 0;
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;

const ll MOD = 1e9 + 9;
const int N = 1e5 + 7;

int a[N], x[N], ans;
pair<int, int> p[N];

int main()
{
     ios::sync_with_stdio(false);
     cin.tie(0);
     cout.tie(0);

     int n, t;
     cin >> n >> t;

     for (int i=0; i<n; i++)
     {
          cin >> p[i].first;
          p[i].second = i;
     }

     for (int i=0; i<n; i++)
          a[i] = p[i].first;

     sort(a, a+n);

     int ans = (a[n-2] + a[n-1]) - (a[0] + a[1]), ind = -1;

     for (int i=n-2; i>=0; i--)
     {
          int mx = max(a[n-1] + a[n-2], a[n-1] + a[i] + t);

          int mn;

          if (i == 0)
               mn = min(a[1] + a[2], a[0] + a[1] + t);
          else
          if (i == 1)
               mn = min(a[0] + a[2], a[0] + a[1] + t);
          else
          {
               mn = min(a[1] + a[i], a[0] + a[1] + t);
               mn = min(mn, a[0] + a[i+1]);
          }

          if (mx - mn < ans)
          {
               ans = mx - mn;
               ind = i;
          }
     }

     cout << ans << "\n";

     if (ind == 0)
          x[p[0].second] = 2;
     else
          x[p[0].second] = 1;

     for (int i=1; i<=ind; i++)
          x[p[i].second] = 2;

     for (int i=ind+1; i<n; i++)
          x[p[i].second] = 1;

     for (int i=0; i<n; i++)
          cout << x[i] << " ";

     return 0;
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;

const ll MOD = 1e9 + 9;
const int N = 1e5 + 7;

int a[N], x[N], ans;
pair<int, int> p[N];

int main()
{
     ios::sync_with_stdio(false);
     cin.tie(0);
     cout.tie(0);

     int n, t;
     cin >> n >> t;

     for (int i=0; i<n; i++)
     {
          cin >> p[i].first;
          p[i].second = i;
     }

     for (int i=0; i<n; i++)
          a[i] = p[i].first;

     sort(a, a+n);

     int ans = (a[n-2] + a[n-1]) - (a[0] + a[1]), ind = -1;

     for (int i=n-2; i>=0; i--)
     {
          int mx = max(a[n-1] + a[n-2], a[n-1] + a[i] + t);

          int mn;

          if (i == 0)
               mn = min(a[1] + a[2], a[0] + a[1] + t);
          else
          if (i == 1)
               mn = min(a[0] + a[2], a[0] + a[1] + t);
          else
          {
               mn = min(a[1] + a[2], a[0] + a[1] + t);
               mn = min(mn, a[0] + a[i+1]);
          }

          if (mx - mn < ans)
          {
               ans = mx - mn;
               ind = i;
          }
     }

     cout << ans << "\n";

     {
          if (ind == 0)
               x[p[0].second] = 2;
          else
               x[p[0].second] = 1;
          for (int i=1; i<=ind; i++)
               x[p[i].second] = 2;
          for (int i=ind+1; i<n; i++)
               x[p[i].second] = 1;
          for (int i=0; i<n; i++)
               cout << x[i] << " ";
     }

     return 0;
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;

const ll MOD = 1e9 + 9;
const int N = 1e5 + 7;

int a[N], x[N], ans;
pair<int, int> p[N];

int main()
{
     ios::sync_with_stdio(false);
     cin.tie(0);
     cout.tie(0);

     int n, t;
     cin >> n >> t;

     for (int i=0; i<n; i++)
     {
          cin >> p[i].first;
          p[i].second = i;
     }

     sort(p, p+n);

     for (int i=0; i<n; i++)
          a[i] = p[i].first;

     int ans = (a[n-2] + a[n-1]) - (a[0] + a[1]), ind = -1;

     for (int i=n-2; i>=0; i--)
     {
          int mx = max(a[n-1] + a[n-2], a[n-1] + a[i] + t);

          int mn;

          if (i == 0)
               mn = min(a[1] + a[2], a[0] + a[1] + t);
          else
          if (i == 1)
               mn = min(a[0] + a[2], a[0] + a[1] + t);
          else
          {
               mn = min(a[1] + a[2], a[0] + a[1] + t);
               mn = min(mn, a[0] + a[i+1]);
          }

          if (mx - mn < ans)
          {
               ans = mx - mn;
               ind = i;
          }
     }

     cout << ans << "\n";

     if (ind == 0)
          x[p[0].second] = 2;
     else
          x[p[0].second] = 1;

     for (int i=1; i<=ind; i++)
          x[p[i].second] = 2;

     for (int i=ind+1; i<n; i++)
          x[p[i].second] = 1;

     for (int i=0; i<n; i++)
          cout << x[i] << " ";

     return 0;
}