#ifdef NACHIA #define _GLIBCXX_DEBUG #else #define NDEBUG #endif #include #include #include #include #include #include #include #include using i64 = long long; using u64 = unsigned long long; #define rep(i,n) for(int i=0; i=0; i--) const i64 INF = 1001001001001001001; const char* yn(bool x){ return x ? "Yes" : "No"; } template void chmin(A& l, const A& r){ if(r < l) l = r; } template void chmax(A& l, const A& r){ if(l < r) l = r; } template using nega_queue = std::priority_queue,std::greater>; template auto ComparingBy(R f){ return [g=std::move(f)](auto l, auto r) -> bool { return g(l) < g(r); }; } #include #include using Modint = atcoder::static_modint<998244353>; using namespace std; void testcase(){ int N; cin >> N; set> ans; vector> Q(N, vector(N)); rep(x,N){ string s; cin >> s; rep(y,N) Q[x][y] = (s[y] == '#' ? 1 : 0); } // rep(x,N){ rep(y,N){ cout << Q[x][y]; } cout << endl; } auto ope = [&](int x, int y){ Q[x][y] ^= 1; Q[x == 0 ? N - 1 : x - 1][y] ^= 1; Q[x][y == 0 ? N - 1 : y - 1] ^= 1; Q[x == 0 ? N - 1 : x - 1][y == 0 ? N - 1 : y - 1] ^= 1; }; auto mov = [&](int x, int y){ ope(x, y); ope(x, 0); ope(0, y); if(ans.count({x,y})) ans.erase({x,y}); else ans.insert({x,y}); }; for(int x=1; x bs(N*4 - 4, nachia::Bitset(N*2-1)); for(int i=N-2; i>0; i--) if(Q[i][0]){ for(int j=1; j=0; i--) if(Q[0][i]){ for(int j=1; j