#include using namespace std; using ll=long long; //#define int ll #define rep(i,a,b) for(int i=a;i<(b);i++) #define sz(x) (int)(x).size() #define all(x) begin(x), end(x) using pii=pair; using vi=vector; #define fi first #define se second #define pb push_back vector > a[2]; string s[55]; bool cl[55]; int n; void check(int clcol, int midcol) { int cntcl = 0, cntmid = 0; for (int i = 0; i < n; i++) if (cl[i]) cntcl++; else cntmid++; if (cntcl == 0 || cntmid == 0) return; cntmid *= 2; cntcl--; for (auto [x, y]: a[midcol]) { if (cl[x] && cl[y]) cntmid++; } int k = 0; int l = 0; for (auto [x, y]: a[clcol]) { if (!cl[x] && !cl[y]) l++; if (cl[x] != cl[y]) k++; } cntmid += l; cntmid += min(k, k/2+1); int crit = (3*n+3)/4; if (cntmid <= crit && cntcl <= crit) { for (int i=0; isync_with_stdio(0); cin.exceptions(cin.failbit); cin>>n; for (int i=0; i>s[i]; //for (int i=0; i i) if (s[i][j] == 'F') a[0].pb({i, j}); else if (s[i][j] == 'S') a[1].pb({i, j}); } mt19937_64 mt(time(0)); while (true) { //cout<<"H"; for (int i=0; i