#include using namespace std; using ll = long long; using ld = long double; using ull = unsigned long long; #define rep(i,n) for(ll i=0;i T div_floor(T a, T b) { return a / b - ((a ^ b) < 0 && a % b); } template T div_ceil(T a, T b) { return a / b + ((a ^ b) > 0 && a % b); } template inline bool chmin(T &x, U y) { return (y < x) ? (x = y, true) : false; } template inline bool chmax(T &x, U y) { return (x < y) ? (x = y, true) : false; } template ostream &operator<<(ostream &os,const pair &p){ return os< ostream &operator<<(ostream &os, const vector &a){ if (a.empty()) return os; os << a.front(); for (auto e : a | views::drop(1)){ os << ' ' << e; } return os; } void dump(auto ...vs){ ((cout << vs << ' '), ...) << endl; } void solve() { ll N; cin>>N; vector A(N,vector (N,0)); rep(i,N){ string s; cin>>s; rep(j,N){ A[i][j]=s[j]-'0'; } } vector B(N,string(N,'.')); auto check=[&](ll i,ll j){ ll cnt=0; for (ll k=i-1;k<=i+1;k++){ for (ll l=j-1;l<=j+1;l++){ if (k<0 or k>=N or l<0 or l>=N)continue; if (B[k][l]=='o'){ cnt++; } } } if (B[i][j]=='o'){ if (A[i][j]cnt)return false; } return true; }; stack> st; rep(i,N){ rep(j,N){ if (!check(i,j)){ st.emplace(i,j); // dump(i,j); } } } auto flip=[](char &c){ if (c=='o')c='.'; else c='o'; return; }; while (st.size()>0){ auto [ci,cj]=st.top();st.pop(); if (check(ci,cj))continue; // dump(B); flip(B[ci][cj]); // dump(B); assert(check(ci,cj)); for (ll k=ci-1;k<=ci+1;k++){ for (ll l=cj-1;l<=cj+1;l++){ if (k<0 or k>=N or l<0 or l>=N)continue; if (k==ci and l==cj)continue; if (!check(k,l)){ st.emplace(k,l); } } } } rep(i,N){ cout<sync_with_stdio(0); ll T=1; while (T--){ solve(); } return 0; }