#include #include #include using namespace std; using namespace __gnu_pbds; #define debug(x) cerr << '[' << (#x) << "] = " << x << '\n'; template using ordered_set = tree , rb_tree_tag , tree_order_statistics_node_update> ; int n, k; char g[8][8]; int dx[] {1, -1, 0, 0}; int dy[] {0, 0, 1, -1}; map>,int>dp; vector>v; bool valid(int i, int j) { return i>-1 && j>-1 && i> v2 = v; sort(v2.begin(), v2.end()); if(dp.count(v2)) { v.pop_back(); g[i][j] = '.'; return; } dp[v2] = 1; if((int)v.size()==k) { v.pop_back(); g[i][j] = '.'; return; } int sz = v.size(); for(int th=0; th> n >> k; for(int i=0; i> g[i][j]; } } for(int i=0; i