#include using namespace std; //高速化 struct ponjuice{ponjuice(){cin.tie(0);ios::sync_with_stdio(0);cout<= 0; i--) #define per2(i, n) for(ll i = n-1; i >= 0; i--) #define per3(i, a, b) for(ll i = b-1; i >= a; i--) #define per4(i, a, b, step) for(ll i = b-1; i >= a; i-= step) #define per(...) overload4(__VA_ARGS__, per4, per3, per2, per1)(__VA_ARGS__) //関数 #define all(x) (x).begin(), (x).end() #define rall(x) (x).rbegin(), (x).rend() templateinline bool chmax(S& a, T b){return a < b && ( a = b , true);} templateinline bool chmin(S& a, T b){return a > b && ( a = b , true);} //定数 constexpr ll mod = 998244353; constexpr ll minf=-(1<<29); constexpr ll inf=(1<<29); constexpr ll MINF=-(1LL<<60); constexpr ll INF=(1LL<<60); const int dx[4] ={-1, 0, 1, 0}; const int dy[4] ={ 0, 1, 0,-1}; const int dx8[8] ={-1,-1,-1, 0, 1, 1, 1, 0}; const int dy8[8] ={-1, 0, 1, 1, 1, 0,-1,-1}; void solve(); int main() { int t = 1; // cin >> t; while(t--)solve(); } void solve(){ int n,d; cin >> n >> d; int sx,sy; int tx,ty; cin >> sx >> sy; cin >> tx >> ty; sx--,sy--,tx--,ty--; vector> ans(n, vector(n, 1)); rep(i,0,n) { rep(j,0,n) { if((i+j)%2 == (sx+sy)%2) ans[i][j] = 1; else ans[i][j] = 2; } } ans[sx][sy] = 1; ans[tx][ty] = 1; vector> dist(n, vector(n, inf)); dist[sx][sy] = 0; using S = array; priority_queue, vector, greater<>> q; q.push({0, sx, sy}); while(q.size()) { auto [ddd,x,y] = q.top(); q.pop(); rep(i,0,4) { int nx = x + dx[i], ny = y + dy[i]; if(nx < 0 || nx >= n || ny < 0 || ny >= n) continue; if(chmin(dist[nx][ny], dist[x][y]+(ans[x][y]==ans[nx][ny]?1:2))) { q.push({dist[nx][ny], nx, ny}); } } } if(dist[tx][ty] < d || d < abs(sx-tx)+abs(sy-ty) || (dist[tx][ty]-d)%2 == 1) { cout << -1 << endl; return; } int cnt = (dist[tx][ty] - d) / 2; cerr << cnt << endl; rep(i,0,n) { rep(j,0,n) { if(abs(sx-i)+abs(sy-j) < cnt*2) ans[i][j] = 1; } } for(auto a: ans) { for(auto x: a) cout << (x==1?'.':'#'); cout << endl; } }