Problem:
Ranks
A
finite field
F
2
consists of two elements: 0 and 1. Addition and multiplication on
F
2
are those on integers modulo two, as defined below.
+
0
1
0
0
1
1
1
0
$\times$
0
1
0
0
0
1
0
1
A set of vectors $v_1, ... , v_k$ over
F
2
with the same dimension is said to be
linearly independent
when, for $c_1, ... , c_k \in $
F
2
, $c_1v_1 + ... + c_kv_k = 0$ is equivalent to $c_1 = ... = c_k = 0$, where $0$ is the zero vector, the vector with all its elements being zero.
The
rank
of a matrix is the maximum cardinality of its linearly independent sets of column vectors. For example, the rank of the matrix

$
  \left[
    \begin{array}{rrr}
      0 & 0 & 1 \\
      1 & 0 & 1
    \end{array}
  \right]
$
  
  is two; the column vectors

 $
  \left[
    \begin{array}{rrr}
      0 \\
      1 
    \end{array}
  \right]
$ 
  
and

   $
  \left[
    \begin{array}{rrr}
      1 \\
      1 
    \end{array}
  \right]
$ 

  
  (the first and the third columns) are linearly independent while the set of all three column vectors is
not
linearly independent. Note that the rank is zero for the zero matrix.
Given the above definition of the rank of matrices, the following may be an intriguing question.
How does a modification of an entry in a matrix change the rank of the matrix?
To investigate this question, let us suppose that we are given a matrix $A$ over
F
2
. For any indices $i$ and $j$, let $A^{(ij)}$ be a matrix equivalent to $A$ except that the $(i, j)$ entry is flipped.
\begin{equation*}
A^{(ij)}_{kl}= \left \{
\begin{array}{ll}
A_{kl} + 1　         &   (k = i \; {\rm and} \; l = j)          \\
A_{kl}　         &  ({\rm otherwise}) \\

\end{array}
\right.
  \end{equation*}
In this problem, we are interested in the rank of the matrix $A^{(ij)}$. Let us denote the rank of $A$ by $r$, and that of $A^{(ij)}$ by $r^{(ij)}$. Your task is to determine, for all $(i, j)$ entries, the relation of ranks before and after flipping the entry out of the following possibilities: $(i) r^{(ij)} < r, (ii) r^{(ij)} = r$, or $(iii) r^{(ij)} > r$.
Input
The input consists of a single test case of the following format.
$n$ $m$
$A_{11}$ ... $A_{1m}$
.
.
.
$A_{n1}$ ... $A_{nm}$
$n$ and $m$ are the numbers of rows and columns in the matrix $A$, respectively ($1 \leq n \leq 1000, 1 \leq m \leq 1000$). In the next $n$ lines, the entries of $A$ are listed without spaces in between. $A_{ij}$ is the entry in the $i$-th row and $j$-th column, which is either 0 or 1.
Output
Output $n$ lines, each consisting of $m$ characters. The character in the $i$-th line at the $j$-th position must be either
-
(minus),
0
(zero), or
+
(plus). They correspond to the possibilities (i), (ii), and (iii) in the problem statement respectively.
Sample Input 1
2 3
001
101
Sample Output 1
-0-
-00
Sample Input 2
5 4
1111
1000
1000
1000
1000
Sample Output 2
0000
0+++
0+++
0+++
0+++
Sample Input 3
10 10
1000001001
0000010100
0000100010
0001000001
0010000010
0100000100
1000001000
0000010000
0000100000
0001000001
Sample 
...(truncated)

Submitted solutions:

code_snippet: #include "bits/stdc++.h"
#define rep(i,a,n) for(int i=a;i<=n;i++)
#define per(i,a,n) for(int i=n;i>=a;i--)
#define pb push_back
#define mp make_pair
#define FI first
#define SE second
#define maxn 2000
#define mod 998244353
#define inf 0x3f3f3f3f
template<class T> bool chmax(T &a, const T &b) {if(a<b) {a=b; return 1;} return 0;}
template<class T> bool chmin(T &a, const T &b) {if(b<a) {a=b; return 1;} return 0;}
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<short,short> pss;
typedef vector<int> vi;
typedef long double db;

typedef bitset<maxn+5> bs;

int n,m; 
struct Base
{
    bs a[1005];
    pair<int,bs> eliminate(bs x)
    {
        per(i,0,n-1) if(x[i]==1) 
        {
            if(a[i].any()) x=x^a[i];
            else return mp(i,x);
        }
        return mp(-1,x);
    }
    void ins(int i,bs x) {a[i]=x;}
}B;
int ind[1005];
char s[maxn+5][maxn+5];
bool ans[maxn+5][maxn+5];

int main()
{
    scanf("%d%d",&n,&m);
    rep(i,0,n-1) scanf("%s",s[i]);
    rep(i,0,m-1)
    {
        bs x;
        rep(j,0,n-1) if(s[j][i]=='1') x.set(j);
        x.set(n+i);
        auto RES=B.eliminate(x);
        auto bit=RES.FI;
        auto res=RES.SE;
        if(bit==-1)
        {
            rep(j,0,m-1) if(res[n+j]==1) ind[j]=0;
        }
        else ind[i]=1,B.ins(bit,res);
    }
    rep(i,0,n-1)
    {
        bs e; e.set(i);
        auto RES=B.eliminate(e);
        auto bit=RES.FI;
        auto res=RES.SE;
        bool ok=bit==-1;
        rep(j,0,m-1)
        {
            if(ind[j]==0) ans[i][j]=ok^1;
            else 
            {
                if(ok==0) ans[i][j]=1;
                else ans[i][j]=res[n+j]^1;
            }
        }
    }
    rep(i,0,n-1) rep(j,0,m-1) 
    {
        if(ans[i][j]==ind[j]) putchar('0');
        else if(ind[j]) putchar('-');
        else putchar('+');
        if(j==m-1) puts("");
    }
    return 0;
}
accuracy: 1
time_ms: 20
memory_kb: 9852
final_rank: 16

code_snippet: #include<bits/stdc++.h>
#define rep(i,s,n) for (int i = (int)(s); i < (int)(n); i++)
#define all(v) begin(v),end(v)
using namespace std;
using ll = long long;
using vl=vector<ll>;
bool chmin(auto &a, auto b){ return a > b ? a = b, 1 : 0; }
bool chmax(auto &a, auto b){ return a < b ? a = b, 1 : 0; }

const ll N=1000;
bitset<N> A[N],B[N],C[N];

int main() {
    cin.tie(0)->sync_with_stdio(0);

    rep(i,0,N) B[i][i]=1;
    ll m,n;
    cin>>m>>n;
    rep(i,0,m) {
        rep(j,0,n) {
            char c;
            cin>>c;
            if (c=='1') A[i][j]=1;
        }
    }
    vl ud(m),d(n,-1);
    rep(j,0,n) {
        rep(i,0,m)if (!ud[i]&&A[i][j]) {
            rep(k,0,m)if (k!=i&&A[k][j]) {
                A[k]^=A[i];
                B[k]^=B[i];
            }
            ud[i]=1;
            d[j]=i;
            break;
        }
    }
    rep(i,0,m)rep(j,0,m)if (!ud[i]) C[j][i]=B[i][j];
    vl e(n);
    rep(i,0,m)if (ud[i]&&A[i].count()==1) {
        rep(j,0,n)if (A[i][j]) e[j]=1;
    }
    vector<string> rs(m,string(n,'0'));
    rep(i,0,m){
        if (!ud[i]) {
            rep(j,0,n)if (!e[j]) rs[i][j]='+';
        }
        else {
            rep(j,0,n) {
                if (d[j]>=0) {
//                    rep(l,0,m)if (B[l][i]) A[l].flip(j);
//                    ll new_rk=rank();
//                    if (new_rk<rk) rs[i][j]='-';
//                    if (new_rk>rk) rs[i][j]='+';
                    ll t=0;
                    ll I=d[j];
                    if (B[I][i]) {
                        ll t=0;
                        if (e[j]) t--;
                        if (C[i].any()) {
                            t++;
                        }
                        if (t==1) rs[i][j]='+';
                        if (t==-1) rs[i][j]='-';
                    }
                    else if (!e[j]){
                        if (C[i].any()) {
                            rs[i][j]='+';
                        }
                    }
//                    rep(l,0,m)if (B[l][i]) A[l].flip(j);
                }
                else {
                    if (C[i].any()) {
                        rs[i][j]='+';
                    }
                }
            }
        }
    }
    rep(i,0,m) cout<<rs[i]<<endl;
}
accuracy: 1
time_ms: 30
memory_kb: 4736
final_rank: 1

code_snippet: #include <bitset>
#include <complex>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
using namespace std;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define per(i, n) for (int i = (n)-1; i >= 0; i--)
#define rep2(i, l, r) for (int i = (l); i < (r); i++)
#define per2(i, l, r) for (int i = (r)-1; i >= (l); i--)
#define each(e, x) for (auto &e : x)
#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
#define eb emplace_back
#define MM << ' ' <<
#define TT template <typename T>
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

TT bool chmin(T &x, T y) { return x > y ? (x = y, true) : false; }
TT bool chmax(T &x, T y) { return x < y ? (x = y, true) : false; }

TT using minheap = priority_queue<T, vector<T>, greater<T>>;
TT using maxheap = priority_queue<T>;

TT void print(vector<T> v, T x = 0) {
    int n = sz(v);
    rep(i, n) cout << v[i] + x << (i == n - 1 ? '\n' : ' ');
    if (n == 0) cout << '\n';
}

TT void printn(vector<T> v, T x = 0) {
    int n = sz(v);
    rep(i, n) cout << v[i] + x << '\n';
}

TT void rearrange(vector<T> &v) {
    sort(all(v));
    v.erase(unique(all(v)), end(v));
}

TT int lb(vector<T> &v, T x) { return lower_bound(all(v), x) - begin(v); }
TT int ub(vector<T> &v, T x) { return upper_bound(all(v), x) - begin(v); }

const int inf = (1 << 30) - 1;
const ll INF = (1LL << 60) - 1;

struct io_setup {
    io_setup() {
        ios_base::sync_with_stdio(false);
        cin.tie(NULL);
        cout << fixed << setprecision(15);
    }
} io_setup;

using Bitset = bitset<1024>;

int main() {
    int N, M;
    cin >> N >> M;

    vector<Bitset> a(N);

    rep(i, N) {
        string S;
        cin >> S;

        rep(j, M) {
            if (S[j] == '1') a[i].set(j);
        }
    }

    auto getMsb = [&](Bitset b) -> int {
        if (b.none()) return M;
        return b._Find_first();
    };

    auto mergeBitset = [&](vector<Bitset> &bs, vector<int> &msb, Bitset b) {
        rep(i, sz(bs)) {
            if (b[msb[i]]) b ^= bs[i];
        }
        if (b.any()) {
            int m = getMsb(b);
            each(e, bs) {
                if (e[m]) e ^= b;
            }
            bs.eb(b);
            msb.eb(m);
        }
    };

    auto solve = [&](vector<Bitset> bs, vector<int> msb, Bitset b) {
        rep(i, sz(bs)) {
            if (b[msb[i]]) b ^= bs[i];
        }

        if (b.none()) {
            string ret(M, '+');
            rep(i, sz(bs)) {
                bs[i].reset(msb[i]);
                if (bs[i].none()) ret[msb[i]] = '0';
            }
            return ret;
        }

        string ret(M, '0');

        rep(i, sz(bs)) {
            bs[i] ^= b;
            bs[i].reset(msb[i]);
            if (bs[i].none()) ret[msb[i]] = '-';
        }

        rep(j, M) {
            if (b[j]) {
                b.reset(j);
                if (b.none()) ret[j] = '-';
                b.set(j);
            }
        }

        return ret;
    };

    vector<vector<Bitset>> bss;
    vector<vector<int>> msbs;

    bss.eb();
    msbs.eb(0);

    vector<string> ans(N);

    auto rec = [&](auto &&rec, int l, int r) -> void {
        if (r - l == 1) {
            ans[l] = solve(bss.back(), msbs.back(), a[l]);
            return;
        }

        int m = (l + r) / 2;

        {
            bss.eb(bss.back()), msbs.eb(msbs.back());
            rep2(i, m, r) mergeBitset(bss.back(), msbs.back(), a[i]);
            rec(rec, l, m);
            bss.pop_back(), msbs.pop_back();
        }
        {
            bss.eb(bss.back()), msbs.eb(msbs.back());
            rep2(i, l, m) mergeBitset(bss.back(), msbs.back(), a[i]);
            rec(rec, m, r);
            bss.pop_back(), msbs.pop_back();
        }
    };

    rec(rec, 0, N);

    rep(i, N) cout << ans[i] << '\n';
}
accuracy: 1
time_ms: 210
memory_kb: 6824
final_rank: 2

code_snippet: // #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>

int ri() {
	int n;
	scanf("%d", &n);
	return n;
}

#define LEN 2000

int main() {
	int n = ri();
	int m = ri();
	std::vector<std::bitset<LEN> > a(n);
	for (int i = 0; i < n; i++) {
		std::string s;
		std::cin >> s;
		for (int j = 0; j < m; j++) a[i][j] = s[j] == '1';
	}
	for (int i = 0; i < n; i++) a[i][m + i] = 1;
	
	std::vector<int> base_index(m, -1);
	std::vector<int> bases;
	int head = 0;
	for (int i = 0; i < m; i++) {
		int nonzero = -1;
		for (int j = head; j < n; j++) if (a[j][i]) {
			nonzero = j;
			break;
		}
		if (nonzero != -1) {
			std::swap(a[nonzero], a[head]);
			for (int j = 0; j < n; j++) if (j != head && a[j][i]) a[j] ^= a[head];
			base_index[i] = head++;
			bases.push_back(i);
		}
	}
	
	std::vector<bool> makable(n, true);
	for (int i = 0; i < n; i++) 
		for (int j = head; j < n; j++) if (a[j][m + i]) makable[i] = false;
	
	
	std::vector<std::vector<int> > res(n, std::vector<int>(m));
	for (int i = 0; i < m; i++) {
		if (base_index[i] != -1) {
			int row = base_index[i];
			
			bool used_other = false;
			for (int j = i + 1; j < m; j++) if (a[row][j]) used_other = true;
			
			if (used_other) {
				for (int j = 0; j < n; j++) res[j][i] = makable[j] ? 0 : 1;
			} else {
				for (int j = 0; j < n; j++) res[j][i] = makable[j] && a[row][m + j] ? -1 : 0;
			}
		} else for (int j = 0; j < n; j++) res[j][i] = makable[j] ? 0 : 1;
	}
	for (auto &i : res) {
		for (auto j : i) std::cout << (j < 0 ? '-' : j > 0 ? '+' : '0');
		std::cout << std::endl;
	}
	
	
	return 0;
}
accuracy: 1
time_ms: 50
memory_kb: 7444
final_rank: 3

code_snippet: #include <bits/stdc++.h>
using namespace std;
template<typename T>
void rd(T &a) {
  cin >> a;
}
template<typename A, typename... B>
void rd(A &a, B& ...b) {
  cin >> a;
  rd(b...);
}
template<typename A>
void print(const A& a) {
  cout << a;
}
template<typename A, typename... B>
void print(const A& a, const B& ...b) {
  cout << a;
  print(b...);
}
template<typename A>
void println(const A& a) {
  cout << a << '\n';
}
template<typename A, typename... B>
void println(const A& a, const B& ...b) {
  cout << a << ' ';
  println(b...);
}
typedef long long i64;
typedef unsigned long long u64;
typedef unsigned u32;
typedef pair<int, int> pii;
#define mkp make_pair
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define FOR(i, j, k) for (int i = (j); i < (k); ++i)
#define ROF(i, j, k) for (int i = ((k) - 1); i >= j; --i)
template<typename T>
inline void chkmin(T &a, const T b) {
  a = min(a, b);
}
template<typename T>
inline void chkmax(T &a, const T b) {
  a = max(a, b);
}

//#define MULTI
const int N = 1005;
int n, m;
typedef bitset<N> bs;
bs a[N];
struct base {
  bs a[N];
  int rk;
  void operator+= (bs x) {
    ROF(i, 0, m) {
      if (!x[i]) continue;
      if (a[i][i]) x ^= a[i];
      else {
        FOR(j, 0, i) if (a[j][j] && x[j]) x ^= a[j];
        FOR(j, i+1, m) if (a[j][i]) a[j] ^= x;
        a[i] = x;
        ++rk;
        return;
      }
    }
  }
} b[20], all;
int rk[N][N];
int L, R;

void cdq(int p, int l, int r) {
  b[p] = b[p-1];
  while (L < l) b[p] += a[L++];
  while (R > r) b[p] += a[R--];
  if (l == r) {
    bs x = a[l];
    ROF(i, 0, m) if (b[p].a[i][i] && x[i]) x ^= b[p].a[i];
    FOR(i, 0, m) {
      x.flip(i);
      rk[l][i] = b[p].rk;
      if (b[p].a[i][i] && x[i]) {
        rk[l][i] += (b[p].a[i] ^ x).count() != 0;
      } else rk[l][i] += x.count() != 0;
      x.flip(i);
    }
    return;
  }
  int mid = (l + r) >> 1;
  cdq(p+1, l, mid);
  L = l, R = r;
  cdq(p+1, mid+1, r);
}

inline void solve() {
  rd(n, m);
  FOR(i, 0, n) cin >> a[i], all += a[i];
  L = 0, R = n-1;
  cdq(1, 0, n-1);
  int RK = all.rk;
  FOR(i, 0, n) {
    ROF(j, 0, m) {
      if (rk[i][j] < RK) cout << '-';
      else if (rk[i][j] == RK) cout << '0';
      else cout << '+';
    }
    cout << '\n';
  }
}

int main() {
#ifndef MISAKA
  //freopen(".in", "r", stdin);
  //freopen(".out", "w", stdout);
  ios::sync_with_stdio(0);
  cin.tie(0);
#endif
#ifdef MULTI
  int T;
  cin >> T;
  while (T--)
#endif
  solve();
  return 0;
}
/* Checklist:
 * - data type
 * - overflow
 * - typo/logic
 * - special cases
 * - cleanup (multi-test)
 * - bounds
 * - memory usage
 * - file IO
 */
accuracy: 1
time_ms: 200
memory_kb: 10132
final_rank: 18

code_snippet: #include <bits/stdc++.h>

using namespace std;

#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define REV(i,n) for(ll (i) = (n) - 1;(i) >= 0;--i)
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {REP(WW,n)cerr << v[WW] << ' ';cerr << endl << endl;}
#define SHOW2d(v,WW,HH) {REP(W_,WW){REP(H_,HH)cerr << v[W_][H_] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 1000000007

#define BIT_N 2002
typedef long long ll;
typedef pair<ll,ll> P;
typedef bitset<BIT_N> Bit;
vector<int> baseNum;

char ans[1001][1001];
ll n,m,ran;

void Gaussian_elimination(vector<Bit> &v){
	int v_size = v.size();
    REP(i, m) {
        int pla = -1;
        for(int j = ran;j < v_size;j++){
            if(v[j][i] == 1){
                pla = j;
                break;
            }
        }

        if(pla != -1){
            swap(v[ran], v[pla]);
            for(int j = 0;j < v_size;j++){
				if(j == ran)continue;
                if(v[j][i] == 1)v[j] ^= v[ran];
            }
            ran++;
        }
    }
}

void makeBaseNum(vector<Bit> v) {
    REP(i,n){
        REP(j,BIT_N){
            if(v[i][j] == 1){
                baseNum.EB(j);
                break;
            }
        }
    }
}

void check(int c, vector<Bit> v){

    vector<int> num = baseNum;
    bool ism = false;
    REP(i,n){
        if(v[i][c] == 1){
            v[i][m] = 1;
            if(num[i] == c){
                do{
                    num[i]++;
                }while(v[i][num[i]] != 1);
            }
        }
        if(num[i] == m)ism = true;
        v[i][c] = 0;
    }

    REP(i,n-1){
        if(num[i] > num[i+1]){
            swap(num[i], num[i+1]);
            swap(v[i], v[i+1]);
        }
    }

    REP(i,n){
        bool pla = false;
        bool mai = false;
        REP(j,n){
            auto tmp = v[j][m] ^ v[j][m + 1 + i];
            if(j >= ran && tmp){
                pla = true;
            }
            if(j == ran - 1 && num[ran - 1] == m && !tmp)mai = true;
        }
        if(ism && !pla && mai){
            ans[i][c] = '-';
        }
        else if(!ism && pla){
            ans[i][c] = '+';
        }
        else {
            ans[i][c] = '0';
        }
    }

}

int main(){
	cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);

    vector<Bit> v;
    cin >> n >> m;
    REP(i,n){
        Bit tmp;
        REP(j,m){
            char c;cin >> c;
            if(c == '1')tmp[j] = 1;
        }
        v.EB(tmp);
    }

    REP(i,n){
        v[i][m + 1 + i] = 1;
    }

    Gaussian_elimination(v);
    makeBaseNum(v);

    REP(i,m){
        check(i, v);
    }

    REP(i,n){
        REP(j,m){
            cout << ans[i][j];
        }
        cout << "\n";
    }

    return 0;
}
accuracy: 1
time_ms: 2090
memory_kb: 4464
final_rank: 8

code_snippet: #include <bits/stdc++.h>

using namespace std;

#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define REV(i,n) for(ll (i) = (n) - 1;(i) >= 0;--i)
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {REP(WW,n)cerr << v[WW] << ' ';cerr << endl << endl;}
#define SHOW2d(v,WW,HH) {REP(W_,WW){REP(H_,HH)cerr << v[W_][H_] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 1000000007

#define BIT_N 2002
typedef long long ll;
typedef pair<ll,ll> P;
typedef bitset<BIT_N> Bit;
vector<int> baseNum;

char ans[1001][1001];
ll n,m,ran;

void Gaussian_elimination(vector<Bit> &v){
	int v_size = v.size();
    REP(i, m) {
        int pla = -1;
        for(int j = ran;j < v_size;j++){
            if(v[j][i] == 1){
                pla = j;
                break;
            }
        }

        if(pla != -1){
            swap(v[ran], v[pla]);
            for(int j = 0;j < v_size;j++){
                if(j != ran && v[j][i] == 1)v[j] ^= v[ran];
            }
            ran++;
        }
    }
}

void makeBaseNum(vector<Bit> v) {
    REP(i,n){
        REP(j,BIT_N){
            if(v[i][j] == 1){
                baseNum.EB(j);
                break;
            }
        }
    }
}

void check(int c, vector<Bit> v){

    vector<int> num = baseNum;
    bool ism = false;
    REP(i,n){
        if(v[i][c] == 1){
            v[i][m] = 1;
            if(num[i] == c){
                do{
                    num[i]++;
                }while(v[i][num[i]] != 1);
            }
        }
        if(num[i] == m)ism = true;
        v[i][c] = 0;
    }

    REP(i,n-1){
        if(num[i] > num[i+1]){
            swap(num[i], num[i+1]);
            swap(v[i], v[i+1]);
        }
    }

    REP(i,n){
        bool pla = false;
        bool mai = false;
        REP(j,n){
            auto tmp = v[j][m] ^ v[j][m + 1 + i];
            if(j >= ran && tmp){
                pla = true;
            }
            if(j == ran - 1 && num[ran - 1] == m && !tmp)mai = true;
        }
        if(ism && !pla && mai){
            ans[i][c] = '-';
        }
        else if(!ism && pla){
            ans[i][c] = '+';
        }
        else {
            ans[i][c] = '0';
        }
    }

}

int main(){
	cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);

    vector<Bit> v;
    cin >> n >> m;
    REP(i,n){
        Bit tmp;
        REP(j,m){
            char c;cin >> c;
            if(c == '1')tmp[j] = 1;
        }
        v.EB(tmp);
    }

    REP(i,n){
        v[i][m + 1 + i] = 1;
    }

    Gaussian_elimination(v);
    makeBaseNum(v);

    REP(i,m){
        check(i, v);
    }

    REP(i,n){
        REP(j,m){
            cout << ans[i][j];
        }
        cout << "\n";
    }

    return 0;
}
accuracy: 1
time_ms: 2010
memory_kb: 4460
final_rank: 4

code_snippet: #include <bits/stdc++.h>

using namespace std;

#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define REV(i,n) for(ll (i) = (n) - 1;(i) >= 0;--i)
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {REP(WW,n)cerr << v[WW] << ' ';cerr << endl << endl;}
#define SHOW2d(v,WW,HH) {REP(W_,WW){REP(H_,HH)cerr << v[W_][H_] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 1000000007

#define BIT_N 2002
typedef long long ll;
typedef pair<ll,ll> P;
typedef bitset<BIT_N> Bit;
vector<int> baseNum;

char ans[1001][1001];
ll n,m,ran;

vector<Bit> Gaussian_elimination(vector<Bit> v){
	int v_size = v.size();
    REP(i, m) {
        int pla = -1;
        for(int j = ran;j < v_size;j++){
            if(v[j][i] == 1){
                pla = j;
                break;
            }
        }

        if(pla != -1){
            swap(v[ran], v[pla]);
            for(int j = 0;j < v_size;j++){
                if(j != ran && v[j][i] == 1)v[j] ^= v[ran];
            }
            ran++;
        }
    }
    return v;
}

void makeBaseNum(vector<Bit> v) {
    REP(i,n){
        REP(j,BIT_N){
            if(v[i][j] == 1){
                baseNum.EB(j);
                break;
            }
        }
    }
}

void check(int c, vector<Bit> v){

    vector<int> num = baseNum;
    bool ism = false;
    REP(i,n){
        if(v[i][c] == 1){
            v[i][m] = 1;
            if(num[i] == c){
                do{
                    num[i]++;
                }while(v[i][num[i]] != 1);
            }
        }
        if(num[i] == m)ism = true;
        v[i][c] = 0;
    }

    REP(i,n-1){
        if(num[i] > num[i+1]){
            swap(num[i], num[i+1]);
            swap(v[i], v[i+1]);
        }
    }

    REP(i,n){
        bool pla = false;
        bool mai = false;
        REP(j,n){
            auto tmp = v[j][m] ^ v[j][m + 1 + i];
            if(j >= ran && tmp){
                pla = true;
            }
            if(j == ran - 1 && num[ran - 1] == m && !tmp)mai = true;
        }
        if(ism && !pla && mai){
            ans[i][c] = '-';
        }
        else if(!ism && pla){
            ans[i][c] = '+';
        }
        else {
            ans[i][c] = '0';
        }
    }

}

int main(){
	cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);

    vector<Bit> v;
    cin >> n >> m;
    REP(i,n){
        Bit tmp;
        REP(j,m){
            char c;cin >> c;
            if(c == '1')tmp[j] = 1;
        }
        v.EB(tmp);
    }

    REP(i,n){
        v[i][m + 1 + i] = 1;
    }

    v = Gaussian_elimination(v);
    makeBaseNum(v);

    REP(i,m){
        check(i, v);
    }

    REP(i,n){
        REP(j,m){
            cout << ans[i][j];
        }
        cout << "\n";
    }

    return 0;
}
accuracy: 1
time_ms: 2270
memory_kb: 4476
final_rank: 13

code_snippet: #include <bits/stdc++.h>

using namespace std;

#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define REV(i,n) for(ll (i) = (n) - 1;(i) >= 0;--i)
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {REP(WW,n)cerr << v[WW] << ' ';cerr << endl << endl;}
#define SHOW2d(v,WW,HH) {REP(W_,WW){REP(H_,HH)cerr << v[W_][H_] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 1000000007

#define BIT_N 2002
typedef long long ll;
typedef pair<ll,ll> P;
typedef bitset<BIT_N> Bit;
vector<int> baseNum;

char ans[1001][1001];
ll n,m,ran;

vector<Bit> Gaussian_elimination(vector<Bit> v){
    REP(i,m) {
        int pla = -1;
        for(int j = ran;j < n;j++){
            if(v[j][i] == 1){
                pla = j;
                break;
            }
        }

        if(pla != -1){
            swap(v[ran], v[pla]);
            for(int j = 0;j < n;j++){
                if(j != ran && v[j][i] == 1)v[j] ^= v[ran];
            }
            ran++;
        }
    }
    return v;
}

void makeBaseNum(vector<Bit> v) {
    REP(i,n){
        REP(j,BIT_N){
            if(v[i][j] == 1){
                baseNum.EB(j);
                break;
            }
        }
    }
}

void check(int c, vector<Bit> v){

    vector<int> num = baseNum;
    bool ism = false;
    REP(i,n){
        if(v[i][c] == 1){
            v[i][m] = 1;
            if(num[i] == c){
                do{
                    num[i]++;
                }while(v[i][num[i]] != 1);
            }
        }
        if(num[i] == m)ism = true;
        v[i][c] = 0;
    }

    REP(i,n-1){
        if(num[i] > num[i+1]){
            swap(num[i], num[i+1]);
            swap(v[i], v[i+1]);
        }
    }

    REP(i,n){
        bool pla = false;
        bool mai = false;
        REP(j,n){
            auto tmp = v[j][m] ^ v[j][m + 1 + i];
            if(j >= ran && tmp){
                pla = true;
            }
            if(j == ran - 1 && num[ran - 1] == m && !tmp)mai = true;
        }
        if(ism && !pla && mai){
            ans[i][c] = '-';
        }
        else if(!ism && pla){
            ans[i][c] = '+';
        }
        else {
            ans[i][c] = '0';
        }
    }

}

int main(){
	//cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);

    vector<Bit> v;
    cin >> n >> m;
    REP(i,n){
        Bit tmp;
        REP(j,m){
            char c;cin >> c;
            if(c == '1')tmp[j] = 1;
        }
        v.EB(tmp);
    }

    REP(i,n){
        v[i][m + 1 + i] = 1;
    }

    v = Gaussian_elimination(v);
    makeBaseNum(v);

    REP(i,m){
        check(i, v);
    }

    REP(i,n){
        REP(j,m){
            cout << ans[i][j];
        }
        cout << "\n";
    }

    return 0;
}
accuracy: 1
time_ms: 2200
memory_kb: 4452
final_rank: 10

code_snippet: #include <bits/stdc++.h>

using namespace std;

#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define REV(i,n) for(ll (i) = (n) - 1;(i) >= 0;--i)
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {REP(WW,n)cerr << v[WW] << ' ';cerr << endl << endl;}
#define SHOW2d(v,WW,HH) {REP(W_,WW){REP(H_,HH)cerr << v[W_][H_] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 1000000007

#define BIT_N 2002
typedef long long ll;
typedef pair<ll,ll> P;
typedef bitset<BIT_N> Bit;
vector<int> baseNum;

char ans[1001][1001];
ll n,m,ran;

vector<Bit> Gaussian_elimination(vector<Bit> v){
    REP(i,m) {
        int pla = -1;
        for(int j = ran;j < n;j++){
            if(v[j][i] == 1){
                pla = j;
                break;
            }
        }

        if(pla != -1){
            swap(v[ran], v[pla]);
            for(int j = 0;j < n;j++){
                if(j != ran && v[j][i] == 1)v[j] ^= v[ran];
            }
            ran++;
        }
    }
    return v;
}

void makeBaseNum(vector<Bit> v) {
    REP(i,n){
        REP(j,BIT_N){
            if(v[i][j] == 1){
                baseNum.EB(j);
                break;
            }
        }
    }
}

void check(int c, vector<Bit> v){

    vector<int> num = baseNum;
    bool ism = false;
    REP(i,n){
        if(v[i][c] == 1){
            v[i][m] = 1;
            if(num[i] == c){
                do{
                    num[i]++;
                }while(v[i][num[i]] != 1);
            }
        }
        if(num[i] == m)ism = true;
        v[i][c] = 0;
    }

    REP(i,n-1){
        if(num[i] > num[i+1]){
            swap(num[i], num[i+1]);
            swap(v[i], v[i+1]);
        }
    }

    REP(i,n){
        bool pla = false;
        bool mai = false;
        REP(j,n){
            auto tmp = v[j][m] ^ v[j][m + 1 + i];
            if(j >= ran && tmp){
                pla = true;
            }
            if(j == ran - 1 && num[ran - 1] == m && !tmp)mai = true;
        }
        if(ism && !pla && mai){
            ans[i][c] = '-';
        }
        else if(!ism && pla){
            ans[i][c] = '+';
        }
        else {
            ans[i][c] = '0';
        }
    }

}

int main(){
	cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);

    vector<Bit> v;
    cin >> n >> m;
    REP(i,n){
        Bit tmp;
        REP(j,m){
            char c;cin >> c;
            if(c == '1')tmp[j] = 1;
        }
        v.EB(tmp);
    }

    REP(i,n){
        v[i][m + 1 + i] = 1;
    }

    v = Gaussian_elimination(v);
    makeBaseNum(v);

    REP(i,m){
        check(i, v);
    }

    REP(i,n){
        REP(j,m){
            cout << ans[i][j];
        }
        cout << endl;
    }

    return 0;
}
accuracy: 1
time_ms: 2230
memory_kb: 4468
final_rank: 12

code_snippet: #include <bits/stdc++.h>

using namespace std;

#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define REV(i,n) for(ll (i) = (n) - 1;(i) >= 0;--i)
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {REP(WW,n)cerr << v[WW] << ' ';cerr << endl << endl;}
#define SHOW2d(v,WW,HH) {REP(W_,WW){REP(H_,HH)cerr << v[W_][H_] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 1000000007

#define BIT_N 2002
typedef long long ll;
typedef pair<ll,ll> P;
typedef bitset<BIT_N> Bit;
vector<int> baseNum;

char ans[1001][1001];
ll n,m,ran;

vector<Bit> Gaussian_elimination(vector<Bit> v){
    REP(i,m) {
        int pla = -1;
        for(int j = ran;j < n;j++){
            if(v[j][i] == 1){
                pla = j;
                break;
            }
        }

        if(pla != -1){
            swap(v[ran], v[pla]);
            for(int j = 0;j < n;j++){
                if(j != ran && v[j][i] == 1)v[j] ^= v[ran];
            }
            ran++;
        }
    }
    return v;
}

void makeBaseNum(vector<Bit> v) {
    REP(i,n){
        REP(j,BIT_N){
            if(v[i][j] == 1){
                baseNum.EB(j);
                break;
            }
        }
    }
}

void check(int c, vector<Bit> v){

    vector<int> num = baseNum;
    bool ism = false;
    REP(i,n){
        if(v[i][c] == 1){
            v[i][m] = 1;
            if(num[i] == c){
                do{
                    num[i]++;
                }while(v[i][num[i]] != 1);
            }
        }
        if(num[i] == m)ism = true;
        v[i][c] = 0;
    }

    REP(i,n-1){
        if(num[i] > num[i+1]){
            swap(num[i], num[i+1]);
            swap(v[i], v[i+1]);
        }
    }

    REP(i,n){
        bool pla = false;
        bool mai = false;
        REP(j,n){
            auto tmp = v[j][m] ^ v[j][m + 1 + i];
            if(j >= ran && tmp){
                pla = true;
            }
            if(j == ran - 1 && num[ran - 1] == m && !tmp)mai = true;
        }
        if(ism && !pla && mai){
            ans[i][c] = '-';
        }
        else if(!ism && pla){
            ans[i][c] = '+';
        }
        else {
            ans[i][c] = '0';
        }
    }

}

int main(){

    vector<Bit> v;
    cin >> n >> m;
    REP(i,n){
        Bit tmp;
        REP(j,m){
            char c;cin >> c;
            if(c == '1')tmp[j] = 1;
        }
        v.EB(tmp);
    }

    REP(i,n){
        v[i][m + 1 + i] = 1;
    }

    v = Gaussian_elimination(v);
    makeBaseNum(v);

    REP(i,m){
        check(i, v);
    }

    REP(i,n){
        REP(j,m){
            cout << ans[i][j];
        }
        cout << endl;
    }

    return 0;
}
accuracy: 1
time_ms: 2040
memory_kb: 4452
final_rank: 6

code_snippet: #include <bits/stdc++.h>

using namespace std;

#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define REV(i,n) for(ll (i) = (n) - 1;(i) >= 0;--i)
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {REP(WW,n)cerr << v[WW] << ' ';cerr << endl << endl;}
#define SHOW2d(v,WW,HH) {REP(W_,WW){REP(H_,HH)cerr << v[W_][H_] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 1000000007

#define BIT_N 2002
typedef long long ll;
typedef pair<ll,ll> P;
typedef bitset<BIT_N> Bit;
vector<int> baseNum;

char ans[1001][1001];
ll n,m,ran;

vector<Bit> gauss(vector<Bit> v){
    REP(i,m) {
        int pla = -1;
        for(int j = ran;j < n;j++){
            if(v[j][i] == 1){
                pla = j;
                break;
            }
        }

        if(pla != -1){
            swap(v[ran], v[pla]);
            for(int j = 0;j < n;j++){
                if(j != ran && v[j][i] == 1)v[j] ^= v[ran];
            }
            ran++;
        }
    }
    return v;
}

void makeBaseNum(vector<Bit> v) {
    REP(i,n){
        REP(j,BIT_N){
            if(v[i][j] == 1){
                baseNum.EB(j);
                break;
            }
        }
    }
}

void check(int c, vector<Bit> v){

    vector<int> num = baseNum;
    bool ism = false;
    REP(i,n){
        if(v[i][c] == 1){
            v[i][m] = 1;
            if(num[i] == c){
                do{
                    num[i]++;
                }while(v[i][num[i]] != 1);
            }
        }
        if(num[i] == m)ism = true;
        v[i][c] = 0;
    }

    REP(i,n-1){
        if(num[i] > num[i+1]){
            swap(num[i], num[i+1]);
            swap(v[i], v[i+1]);
        }
    }

    REP(i,n){
        bool pla = false;
        bool mai = false;
        REP(j,n){
            auto tmp = v[j][m] ^ v[j][m + 1 + i];
            if(j >= ran && tmp){
                pla = true;
            }
            if(j == ran - 1 && num[ran - 1] == m && !tmp)mai = true;
        }
        if(ism && !pla && mai){
            ans[i][c] = '-';
        }
        else if(!ism && pla){
            ans[i][c] = '+';
        }
        else {
            ans[i][c] = '0';
        }
    }

}

int main(){

    vector<Bit> v;
    cin >> n >> m;
    REP(i,n){
        Bit tmp;
        REP(j,m){
            char c;cin >> c;
            if(c == '1')tmp[j] = 1;
        }
        v.EB(tmp);
    }

    REP(i,n){
        v[i][m + 1 + i] = 1;
    }

    v = gauss(v);
    makeBaseNum(v);

    REP(i,m){
        check(i, v);
    }

    REP(i,n){
        REP(j,m){
            cout << ans[i][j];
        }
        cout << endl;
    }

    return 0;
}
accuracy: 1
time_ms: 2100
memory_kb: 4408
final_rank: 7

code_snippet: #include <bits/stdc++.h>

using namespace std;

#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define REV(i,n) for(ll (i) = (n) - 1;(i) >= 0;--i)
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {REP(WW,n)cerr << v[WW] << ' ';cerr << endl << endl;}
#define SHOW2d(v,WW,HH) {REP(W_,WW){REP(H_,HH)cerr << v[W_][H_] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 1000000007

#define BIT_N 2002
typedef long long ll;
typedef pair<ll,ll> P;
typedef bitset<BIT_N> Bit;
vector<int> baseNum;

char ans[1111][1111];
ll n,m,ran;

vector<Bit> gauss(vector<Bit> v){
    REP(i,m) {
        int pla = -1;
        for(int j = ran;j < n;j++){
            if(v[j][i] == 1){
                pla = j;
                break;
            }
        }

        if(pla != -1){
            swap(v[ran], v[pla]);
            for(int j = 0;j < n;j++){
                if(j != ran && v[j][i] == 1)v[j] ^= v[ran];
            }
            ran++;
        }
    }
    return v;
}

void makeBaseNum(vector<Bit> v) {
    REP(i,n){
        REP(j,BIT_N){
            if(v[i][j] == 1){
                baseNum.EB(j);
                break;
            }
        }
    }
}

void check(int c, vector<Bit> v){

    vector<int> num = baseNum;
    bool ism = false;
    REP(i,n){
        if(v[i][c] == 1){
            v[i][m] = 1;
            if(num[i] == c){
                do{
                    num[i]++;
                }while(v[i][num[i]] != 1);
            }
        }
        if(num[i] == m)ism = true;
        v[i][c] = 0;
    }

    REP(i,n-1){
        if(num[i] > num[i+1]){
            swap(num[i], num[i+1]);
            swap(v[i], v[i+1]);
        }
    }

    REP(i,n){
        bool pla = false;
        bool mai = false;
        REP(j,n){
            auto tmp = v[j][m] ^ v[j][m + 1 + i];
            if(j >= ran && tmp){
                pla = true;
            }
            if(j == ran - 1 && num[ran - 1] == m && !tmp)mai = true;
        }
        if(ism && !pla && mai){
            ans[i][c] = '-';
        }
        else if(!ism && pla){
            ans[i][c] = '+';
        }
        else {
            ans[i][c] = '0';
        }
    }

}

int main(){

    vector<Bit> v;
    cin >> n >> m;
    REP(i,n){
        Bit tmp;
        REP(j,m){
            char c;cin >> c;
            if(c == '1')tmp[j] = 1;
        }
        v.EB(tmp);
    }

    REP(i,n){
        v[i][m + 1 + i] = 1;
    }

    v = gauss(v);
    makeBaseNum(v);

    REP(i,m){
        check(i, v);
    }

    REP(i,n){
        REP(j,m){
            cout << ans[i][j];
        }
        cout << endl;
    }

    return 0;
}
accuracy: 1
time_ms: 1980
memory_kb: 4528
final_rank: 5

code_snippet: #include <bits/stdc++.h>

using namespace std;

#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define REV(i,n) for(ll (i) = (n) - 1;(i) >= 0;--i)
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {REP(WW,n)cerr << v[WW] << ' ';cerr << endl << endl;}
#define SHOW2d(v,WW,HH) {REP(W_,WW){REP(H_,HH)cerr << v[W_][H_] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 1000000007

#define BIT_N 2002
typedef long long ll;
typedef pair<ll,ll> P;
typedef bitset<BIT_N> Bit;
vector<int> baseNum;

char ans[1111][1111];
ll n,m,ran;

void gauss(vector<Bit> &v){
    REP(i,m) {
        int pla = -1;
        for(int j = ran;j < n;j++){
            if(v[j][i] == 1){
                pla = j;
                break;
            }
        }

        if(pla != -1){
            swap(v[ran], v[pla]);
            for(int j = 0;j < n;j++){
                if(j != ran && v[j][i] == 1)v[j] ^= v[ran];
            }
            ran++;
        }
    }
}

void makeBaseNum(vector<Bit> v) {
    REP(i,n){
        REP(j,BIT_N){
            if(v[i][j] == 1){
                baseNum.EB(j);
                break;
            }
        }
    }
}

void check(int c, vector<Bit> v){

    vector<int> num = baseNum;
    bool ism = false;
    REP(i,n){
        if(v[i][c] == 1){
            v[i][m] = 1;
            if(num[i] == c){
                do{
                    num[i]++;
                }while(v[i][num[i]] != 1);
            }
        }
        if(num[i] == m)ism = true;
        v[i][c] = 0;
    }

    REP(i,n-1){
        if(num[i] > num[i+1]){
            swap(num[i], num[i+1]);
            swap(v[i], v[i+1]);
        }
    }

    REP(i,n){
        bool pla = false;
        bool mai = false;
        REP(j,n){
            auto tmp = v[j][m] ^ v[j][m + 1 + i];
            if(j >= ran && tmp){
                pla = true;
            }
            if(j == ran - 1 && num[ran - 1] == m && !tmp)mai = true;
        }
        if(ism && !pla && mai){
            ans[i][c] = '-';
        }
        else if(!ism && pla){
            ans[i][c] = '+';
        }
        else {
            ans[i][c] = '0';
        }
    }

}

int main(){

    vector<Bit> v;
    cin >> n >> m;
    REP(i,n){
        Bit tmp;
        REP(j,m){
            char c;cin >> c;
            if(c == '1')tmp[j] = 1;
        }
        v.EB(tmp);
    }

    REP(i,n){
        v[i][m + 1 + i] = 1;
    }

    gauss(v);
    makeBaseNum(v);

    REP(i,m){
        check(i, v);
    }

    REP(i,n){
        REP(j,m){
            cout << ans[i][j];
        }
        cout << endl;
    }

    return 0;
}
accuracy: 1
time_ms: 2370
memory_kb: 4520
final_rank: 15

code_snippet: #include <bits/stdc++.h>

using namespace std;

#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define REV(i,n) for(ll (i) = (n) - 1;(i) >= 0;--i)
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {REP(WW,n)cerr << v[WW] << ' ';cerr << endl << endl;}
#define SHOW2d(v,WW,HH) {REP(W_,WW){REP(H_,HH)cerr << v[W_][H_] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 1000000007

#define BIT_N 2002
typedef long long ll;
typedef pair<ll,ll> P;
typedef bitset<BIT_N> Bit;
vector<int> baseNum;

char ans[1111][1111];
ll n,m,ran;

vector<Bit> gauss(vector<Bit> v){
	REP(i,m) {
		int pla = -1;
		for(int j = ran;j < n;j++){
			if(v[j][i] == 1){
				pla = j;
				break;
			}
		}
		
		if(pla != -1){
			swap(v[ran], v[pla]);
			for(int j = 0;j < n;j++){
				if(j != ran && v[j][i] == 1)v[j] ^= v[ran];
			}
			ran++;
		}
	}
	return v;
}

void makeBaseNum(vector<Bit> v) {
	REP(i,n){
		REP(j,BIT_N){
			if(v[i][j] == 1){
				baseNum.EB(j);
				break;
			}
		}
	}
}

void check(int c, vector<Bit> v){
	
	vector<int> num = baseNum;
	bool ism = false;
	REP(i,n){
		if(v[i][c] == 1){
			v[i][m] = 1;
			if(num[i] == c){
				do{
					num[i]++;
				}while(v[i][num[i]] != 1);
			}
		}
		if(num[i] == m)ism = true;
		v[i][c] = 0;
	}	
	
	REP(i,n-1){
		if(num[i] > num[i+1]){
			swap(num[i], num[i+1]);
			swap(v[i], v[i+1]);
		}
	}
		
	REP(i,n){
		bool pla = false;
		bool mai = false;
		REP(j,n){
			auto tmp = v[j][m] ^ v[j][m + 1 + i];
			if(j >= ran && tmp){
				pla = true;
			}
			if(j == ran - 1 && num[ran - 1] == m && !tmp)mai = true;
		}
		if(ism && !pla && mai){
			ans[i][c] = '-';
		}
		else if(!ism && pla){
			ans[i][c] = '+';
		}
		else {
			ans[i][c] = '0';
		}
	}
	
}

int main(){
	
	vector<Bit> v;
	cin >> n >> m;
	REP(i,n){
		Bit tmp;
		REP(j,m){
			char c;cin >> c;
			if(c == '1')tmp[j] = 1;
		}
		v.EB(tmp);
	}
	
	REP(i,n){
		v[i][m + 1 + i] = 1;
	}
	
	v = gauss(v);
	makeBaseNum(v);
	
	REP(i,m){
		check(i, v);
	}
	
	REP(i,n){
		REP(j,m){
			cout << ans[i][j];
		}
		cout << endl;
	}
	
	return 0;
}
accuracy: 1
time_ms: 2150
memory_kb: 4476
final_rank: 9

code_snippet: #include <bits/stdc++.h>

using namespace std;

#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define REV(i,n) for(ll (i) = (n) - 1;(i) >= 0;--i)
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {REP(WW,n)cerr << v[WW] << ' ';cerr << endl << endl;}
#define SHOW2d(v,WW,HH) {REP(W_,WW){REP(H_,HH)cerr << v[W_][H_] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 1000000007

#define BIT_N 2002
typedef long long ll;
typedef pair<ll,ll> P;
typedef bitset<BIT_N> Bit;
vector<int> baseNum;

char ans[1111][1111];
ll n,m,ran;

vector<Bit> gauss(vector<Bit> v){
	REP(i,m) {
		int pla = -1;
		for(int j = ran;j < n;j++){
			if(v[j][i] == 1){
				pla = j;
				break;
			}
		}
		
		if(pla != -1){
			swap(v[ran], v[pla]);
			for(int j = 0;j < n;j++){
				if(j != ran && v[j][i] == 1)v[j] ^= v[ran];
			}
			ran++;
		}
	}
	return v;
}

void makeBaseNum(vector<Bit> v) {
	REP(i,n){
		REP(j,BIT_N){
			if(v[i][j] == 1){
				baseNum.EB(j);
				break;
			}
		}
	}
}

void check(int c, vector<Bit> v){
	
	vector<int> num = baseNum;
	bool ism = false;
	REP(i,n){
		if(v[i][c] == 1){
			v[i][m] = 1;
			if(num[i] == c){
				do{
					num[i]++;
				}while(v[i][num[i]] != 1);
			}
		}
		if(num[i] == m)ism = true;
		v[i][c] = 0;
	}	
	
	REP(i,n-1){
		if(num[i] > num[i+1]){
			swap(num[i], num[i+1]);
			swap(v[i], v[i+1]);
		}
	}
		
	REP(i,n){
		bool pla = false;
		bool mai = false;
		REP(j,n){
			auto tmp = v[j][m] ^ v[j][m + 1 + i];
			if(j >= ran && tmp){
				pla = true;
			}
			if(j == ran - 1 && num[ran - 1] == m && !tmp)mai = true;
		}
		if(ism && !pla && mai){
			ans[i][c] = '-';
		}
		else if(!ism && pla){
			ans[i][c] = '+';
		}
		else {
			ans[i][c] = '0';
		}
	}
	
}

int main(){
	
	vector<Bit> v;
	cin >> n >> m;
	REP(i,n){
		Bit tmp;
		REP(j,m){
			char c;cin >> c;
			if(c == '1')tmp[j] = 1;
		}
		v.EB(tmp);
	}
	
	REP(i,n){
		v[i][m + 1 + i] = 1;
	}
	
	v = gauss(v);
	makeBaseNum(v);
	
	REP(i,m){
		check(i, v);
	}
	
	REP(i,n){
		REP(j,m){
			printf("%c",ans[i][j]);
		}
		puts("");
	}
	
	return 0;
}
accuracy: 1
time_ms: 2280
memory_kb: 4496
final_rank: 14

code_snippet: #include <bits/stdc++.h>

using namespace std;

#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define REV(i,n) for(ll (i) = (n) - 1;(i) >= 0;--i)
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {REP(WW,n)cerr << v[WW] << ' ';cerr << endl << endl;}
#define SHOW2d(v,WW,HH) {REP(W_,WW){REP(H_,HH)cerr << v[W_][H_] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 1000000007

#define BIT_N 2020
typedef long long ll;
typedef pair<ll,ll> P;
typedef bitset<BIT_N> Bit;
vector<int> baseNum;

char ans[1111][1111];
ll n,m,ran;

vector<Bit> gauss(vector<Bit> v){
	REP(i,m) {
		int pla = -1;
		for(int j = ran;j < n;j++){
			if(v[j][i] == 1){
				pla = j;
				break;
			}
		}
		
		if(pla != -1){
			swap(v[ran], v[pla]);
			for(int j = 0;j < n;j++){
				if(j != ran && v[j][i] == 1)v[j] ^= v[ran];
			}
			ran++;
		}
	}
	return v;
}

void makeBaseNum(vector<Bit> v) {
	REP(i,n){
		REP(j,BIT_N){
			if(v[i][j] == 1){
				baseNum.EB(j);
				break;
			}
		}
	}
}

void check(int c, vector<Bit> v){
	
	vector<int> num = baseNum;
	bool ism = false;
	REP(i,n){
		if(v[i][c] == 1){
			v[i][m] = 1;
			if(num[i] == c){
				do{
					num[i]++;
				}while(v[i][num[i]] != 1);
			}
		}
		if(num[i] == m)ism = true;
		v[i][c] = 0;
	}	
	
	REP(i,n-1){
		if(num[i] > num[i+1]){
			swap(num[i], num[i+1]);
			swap(v[i], v[i+1]);
		}
	}
	
	//SHOW1d(num,num.size());
		
	REP(i,n){
		bool pla = false;
		bool mai = false;
		REP(j,n){
			auto tmp = v[j][m] ^ v[j][m + 1 + i];
			if(j >= ran && tmp){
				pla = true;
			}
			if(j == ran - 1 && num[ran - 1] == m && !tmp)mai = true;
		}
		//cout << m << " " << c << endl;
		//SHOW2d(v,n,BIT_N);
		if(ism && !pla && mai){
			ans[i][c] = '-';
		}
		else if(!ism && pla){
			ans[i][c] = '+';
		}
		else {
			ans[i][c] = '0';
		}
	}
	
}

int main(){
	
	vector<Bit> v;
	cin >> n >> m;
	REP(i,n){
		Bit tmp;
		REP(j,m){
			char c;cin >> c;
			if(c == '1')tmp[j] = 1;
		}
		v.EB(tmp);
	}
	
	REP(i,n){
		v[i][m + 1 + i] = 1;
	}
	
	v = gauss(v);
	makeBaseNum(v);
	
	REP(i,m){
		check(i, v);
	}
	
	REP(i,n){
		REP(j,m){
			cout << ans[i][j];
		}
		cout << endl;
	}
	
	return 0;
}
accuracy: 1
time_ms: 2200
memory_kb: 4496
final_rank: 11

code_snippet: #include <bits/stdc++.h>

using namespace std;

#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define REV(i,n) for(ll (i) = (n) - 1;(i) >= 0;--i)
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {REP(WW,n)cerr << v[WW] << ' ';cerr << endl << endl;}
#define SHOW2d(v,WW,HH) {REP(W_,WW){REP(H_,HH)cerr << v[W_][H_] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 1000000007

#define BIT_N 2020
typedef long long ll;
typedef pair<ll,ll> P;
typedef bitset<BIT_N> Bit;

char ans[1111][1111];
ll n,m,ran;

vector<Bit> gauss(vector<Bit> v){
	REP(i,m) {
		int pla = -1;
		for(int j = ran;j < n;j++){
			if(v[j][i] == 1){
				pla = j;
				break;
			}
		}
		
		if(pla != -1){
			swap(v[ran], v[pla]);
			for(int j = 0;j < n;j++){
				if(j != ran && v[j][i] == 1)v[j] ^= v[ran];
			}
			ran++;
		}
	}
	return v;
}

void check(int c, vector<Bit> v){
	REP(i,n){
		if(v[i][c] == 1)v[i][m] = 1;
		v[i][c] = 0;
	}	
	
	vector<int> num;
	bool ism = false;
	REP(i,n){
		REP(j,BIT_N){
			if(v[i][j] == 1){
				num.EB(j);
				if(j == m)ism = true;
				break;
			}
		}
	}
	
	REP(i,n-1){
		if(num[i] > num[i+1]){
			swap(num[i], num[i+1]);
			swap(v[i], v[i+1]);
		}
	}
	
	//SHOW1d(num,num.size());
		
	REP(i,n){
		bool pla = false;
		bool mai = false;
		REP(j,n){
			auto tmp = v[j][m] ^ v[j][m + 1 + i];
			if(j >= ran && tmp){
				pla = true;
			}
			if(j == ran - 1 && num[ran - 1] == m && !tmp)mai = true;
		}
		//cout << m << " " << c << endl;
		//SHOW2d(v,n,BIT_N);
		if(ism && !pla && mai){
			ans[i][c] = '-';
		}
		else if(!ism && pla){
			ans[i][c] = '+';
		}
		else {
			ans[i][c] = '0';
		}
	}
	
}

int main(){
	
	vector<Bit> v;
	cin >> n >> m;
	REP(i,n){
		Bit tmp;
		REP(j,m){
			char c;cin >> c;
			if(c == '1')tmp[j] = 1;
		}
		v.EB(tmp);
	}
	
	REP(i,n){
		v[i][m + 1 + i] = 1;
	}
	
	v = gauss(v);
	//cout << "ran " << ran << endl;
	//SHOW2d(v,n,BIT_N);

	REP(i,m){
		check(i, v);
	}
	
	REP(i,n){
		REP(j,m){
			cout << ans[i][j];
		}
		cout << endl;
	}
	
	return 0;
}
accuracy: 1
time_ms: 2650
memory_kb: 4504
final_rank: 17

code_snippet: #include <bits/stdc++.h>

using namespace std;

#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define REV(i,n) for(ll (i) = (n) - 1;(i) >= 0;--i)
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {REP(WW,n)cerr << v[WW] << ' ';cerr << endl << endl;}
#define SHOW2d(v,WW,HH) {REP(W_,WW){REP(H_,HH)cerr << v[W_][H_] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 1000000007

#define BIT_N 2020
typedef long long ll;
typedef pair<ll,ll> P;
typedef bitset<BIT_N> Bit;

char ans[1111][1111];
ll n,m,ran;

vector<Bit> gauss(vector<Bit> v){
	REP(i,n) {
		int pla = -1;
		for(int j = ran;j < n;j++){
			if(v[j][i] == 1){
				pla = j;
				break;
			}
		}
		
		if(pla != -1){
			swap(v[ran], v[pla]);
			for(int j = 0;j < n;j++){
				if(j != ran && v[j][i] == 1)v[j] ^= v[ran];
			}
			ran++;
		}
	}
	return v;
}

void check(int c, vector<Bit> v){
	REP(i,n){
		if(v[i][c] == 1)v[i][m] = 1;
		v[i][c] = 0;
	}	
	
	vector<int> num;
	bool ism = false;
	REP(i,n){
		REP(j,BIT_N){
			if(v[i][j] == 1){
				num.EB(j);
				if(j == m)ism = true;
				break;
			}
		}
	}
	
	REP(i,n-1){
		if(num[i] > num[i+1]){
			swap(num[i], num[i+1]);
			swap(v[i], v[i+1]);
		}
	}
	
	//SHOW1d(num,num.size());
		
	REP(i,n){
		bool pla = false;
		bool mai = false;
		REP(j,n){
			auto tmp = v[j][m] ^ v[j][m + 1 + i];
			if(j >= ran && tmp){
				pla = true;
			}
			if(j == ran - 1 && num[ran - 1] == m && !tmp)mai = true;
		}
		//cout << m << " " << c << endl;
		//SHOW2d(v,n,BIT_N);
		if(ism && !pla && mai){
			ans[i][c] = '-';
		}
		else if(!ism && pla){
			ans[i][c] = '+';
		}
		else {
			ans[i][c] = '0';
		}
	}
	
}

int main(){
	
	vector<Bit> v;
	cin >> n >> m;
	REP(i,n){
		Bit tmp;
		REP(j,m){
			char c;cin >> c;
			if(c == '1')tmp[j] = 1;
		}
		v.EB(tmp);
	}
	
	REP(i,n){
		v[i][m + 1 + i] = 1;
	}
	
	v = gauss(v);
	//cout << "ran " << ran << endl;
	//SHOW2d(v,n,BIT_N);

	REP(i,m){
		check(i, v);
	}
	
	REP(i,n){
		REP(j,m){
			cout << ans[i][j];
		}
		cout << endl;
	}
	
	return 0;
}
accuracy: 0.5862068965517241
time_ms: 2460
memory_kb: 4496
final_rank: 19

code_snippet: #include <bits/stdc++.h>

using namespace std;

#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define REV(i,n) for(ll (i) = (n) - 1;(i) >= 0;--i)
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {REP(WW,n)cerr << v[WW] << ' ';cerr << endl << endl;}
#define SHOW2d(v,WW,HH) {REP(W_,WW){REP(H_,HH)cerr << v[W_][H_] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 1000000007

#define BIT_N 2020
typedef long long ll;
typedef pair<ll,ll> P;
typedef bitset<BIT_N> Bit;

char ans[1111][1111];
ll n,m,ran;

vector<Bit> gauss(vector<Bit> v){
	REP(i,n) {
		int pla = -1;
		for(int j = ran;j < n;j++){
			if(v[j][i] == 1){
				pla = j;
				break;
			}
		}
		
		if(pla != -1){
			swap(v[ran], v[pla]);
			for(int j = 0;j < n;j++){
				if(j != ran && v[j][i] == 1)v[j] ^= v[ran];
			}
			ran++;
		}
	}
	return v;
}

void check(int c, vector<Bit> v){
	REP(i,n){
		if(v[i][c] == 1)v[i][m] = 1;
		v[i][c] = 0;
	}	
	
	vector<int> num;
	bool ism = false;
	REP(i,n){
		REP(j,BIT_N){
			if(v[i][j] == 1){
				num.EB(j);
				if(j == m)ism = true;
				break;
			}
		}
	}
	
	REP(i,n-1){
		if(num[i] > num[i+1]){
			swap(num[i], num[i+1]);
			swap(v[i], v[i+1]);
		}
	}
	
	//SHOW1d(num,num.size());
		
	REP(i,n){
		bool pla = false;
		bool mai = false;
		REP(j,n){
			auto tmp = v[j][m] ^ v[j][m + 1 + i];
			if(j >= ran && tmp){
				pla = true;
			}
			if(j == ran - 1 && num[ran - 1] == m && !tmp)mai = true;
		}
		//cout << m << " " << c << endl;
		//SHOW2d(v,n,BIT_N);
		if(!pla && mai){
			ans[i][c] = '-';
		}
		else if(!ism && pla){
			ans[i][c] = '+';
		}
		else {
			ans[i][c] = '0';
		}
	}
	
}

int main(){
	
	vector<Bit> v;
	cin >> n >> m;
	REP(i,n){
		Bit tmp;
		REP(j,m){
			char c;cin >> c;
			if(c == '1')tmp[j] = 1;
		}
		v.EB(tmp);
	}
	
	REP(i,n){
		v[i][m + 1 + i] = 1;
	}
	
	v = gauss(v);
	//cout << "ran " << ran << endl;
	//SHOW2d(v,n,BIT_N);

	REP(i,m){
		check(i, v);
	}
	
	REP(i,n){
		REP(j,m){
			cout << ans[i][j];
		}
		cout << endl;
	}
	
	return 0;
}
accuracy: 0.5862068965517241
time_ms: 2630
memory_kb: 4504
final_rank: 20