#include using namespace std; using lint = long long int; using pint = pair; using plint = pair; struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_; #define ALL(x) (x).begin(), (x).end() #define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i=i##_begin_;i--) #define REP(i, n) FOR(i,0,n) #define IREP(i, n) IFOR(i,0,n) template void ndarray(vector &vec, int len) { vec.resize(len); } template void ndarray(vector &vec, int len, Args... args) { vec.resize(len); for (auto &v : vec) ndarray(v, args...); } template bool chmax(T &m, const T q) { if (m < q) {m = q; return true;} else return false; } template bool chmin(T &m, const T q) { if (m > q) {m = q; return true;} else return false; } template pair operator+(const pair &l, const pair &r) { return make_pair(l.first + r.first, l.second + r.second); } template pair operator-(const pair &l, const pair &r) { return make_pair(l.first - r.first, l.second - r.second); } template istream &operator>>(istream &is, vector &vec){ for (auto &v : vec) is >> v; return is; } template ostream &operator<<(ostream &os, const vector &vec){ os << "["; for (auto v : vec) os << v << ","; os << "]"; return os; } template ostream &operator<<(ostream &os, const deque &vec){ os << "deq["; for (auto v : vec) os << v << ","; os << "]"; return os; } template ostream &operator<<(ostream &os, const set &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; } template ostream &operator<<(ostream &os, const unordered_set &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; } template ostream &operator<<(ostream &os, const multiset &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; } template ostream &operator<<(ostream &os, const unordered_multiset &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; } template ostream &operator<<(ostream &os, const pair &pa){ os << "(" << pa.first << "," << pa.second << ")"; return os; } template ostream &operator<<(ostream &os, const map &mp){ os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; } template ostream &operator<<(ostream &os, const unordered_map &mp){ os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; } #define dbg(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ") " << __FILE__ << endl; /* #include #include #include using namespace __gnu_pbds; // find_by_order(), order_of_key() template using pbds_set = tree, rb_tree_tag, tree_order_statistics_node_update>; template using pbds_map = tree, rb_tree_tag, tree_order_statistics_node_update>; */ constexpr int Wmax = 200 * 200; using BS = bitset; std::vector> gauss_jordan(int W, std::vector> mtr) { int H = mtr.size(), c = 0; for (int h = 0; h < H; h++, c++) { if (c == W) break; int piv = -1; for (int j = h; j < H; j++) if (mtr[j][c]) { piv = j; break; } if (piv == -1) { h--; continue; } std::swap(mtr[piv], mtr[h]); for (int hh = 0; hh < H; hh++) { if (hh != h and mtr[hh][c]) mtr[hh] ^= mtr[h]; } } return mtr; } int rank_gauss_jordan(int W, const std::vector> &mtr) // Rank of Gauss-Jordan eliminated matrix { for (int h = (int)mtr.size() - 1; h >= 0; h--) { if (mtr[h]._Find_first() < W) return h + 1; } return 0; } int main() { int N, M; cin >> N >> M; vector basis; REP(i, N) { BS bs1, bs2; REP(j, N) bs1[i * N + j] = 1; REP(j, N) bs2[j * N + i] = 1; basis.push_back(bs1); basis.push_back(bs2); } REP(s, N * 2 - 1) { BS b; REP(i, N) { int j = s - i; if (j >= 0 and j < N) { b[i * N + j] = 1; } } basis.push_back(b); } FOR(d, -N + 1, N) { BS b; REP(i, N) { int j = i - d; if (j >= 0 and j < N) { b[i * N + j] = 1; } } basis.push_back(b); } basis = gauss_jordan(N * N, basis); vector O; for (auto &b : basis) O.emplace_back(b._Find_first()); vector hyojun; REP(i, M) { vector A(N); cin >> A; BS b; REP(i, N) REP(j, N) if (A[i][j] == '#') b[i * N + j] = 1; REP(i, basis.size()) if (O[i] >= 0 and b[O[i]]) { b ^= basis[i]; } hyojun.emplace_back(b); } REP(i, M - 1) { FOR(j, i + 1, M) { if (hyojun[i] == hyojun[j]) printf("1"); else printf("0"); } puts(""); } }