#include <bits/stdc++.h>
using namespace std;
using lli = long long;

int n,m,arr[200][200];

int main() {
    scanf("%d%d",&n,&m);
    for(int i=0;i<n;i++) for(int j=0;j<m;j++) scanf("%d",&arr[i][j]);

    for(int k=0;k<n;k++) {
        vector<int> a,b;
        int f=1;
        for(int i=0;i<n;i++) if(i!=k) {
            vector<int> ta,tb;
            for(int j=0;j<m;j++) if(arr[i][j]==0) ta.push_back(j); else tb.push_back(j);
            if(ta>tb) swap(ta,tb);
            if(b.empty()) a=ta,b=tb;
            else if(a!=ta) {
                f=0;
                break;
            }
        }
        if(f) {
            vector<int> tmp(arr[k],arr[k]+m);
            for(int i=0,j=0;i<m;i++) {
                if(j<a.size() && i==a[j]) tmp[i]^=1,j++;
            }
            if(tmp[0]==1) for(int j=0;j<m;j++) tmp[j]^=1;

            int j=0;
            for(;j<m && tmp[j]==0;j++);
            for(;j<m && tmp[j]==1;j++);
            if(j==m) {
                puts("YES");
                for(int i=0;i<n;i++) {
                    for(int j=0,k=0;j<m;j++) if(k<a.size() && j==a[k]) arr[i][j]^=1,k++;
                    if((i<=k && arr[i][0]==1) || (i>k && arr[i][0]==0)) printf("1");
                    else printf("0");
                }
                puts("");
                for(int i=0,j=0;i<m;i++) {
                    if(j<a.size() && i==a[j]) printf("1"),j++;
                    else printf("0");
                }
                return 0;
            }
        }
    }
    puts("NO");

    return 0;
}


#include <bits/stdc++.h>
using namespace std;
using lli = long long;

int n,m,arr[200][200];

int main() {
    scanf("%d%d",&n,&m);
    for(int i=0;i<n;i++) for(int j=0;j<m;j++) scanf("%d",&arr[i][j]);
    if(n==1) {
        puts("YES");
        printf("0\n");
        for(int j=0;j<m;j++) {
            if(arr[0][j]==0) printf("0");
            else printf("1");
        }
        return 0;
    }

    for(int k=0;k<n;k++) {
        vector<int> a,b;
        int f=1;
        for(int i=0;i<n;i++) if(i!=k) {
            vector<int> ta,tb;
            for(int j=0;j<m;j++) if(arr[i][j]==0) ta.push_back(j); else tb.push_back(j);
            if(ta>tb) swap(ta,tb);
            if(b.empty()) a=ta,b=tb;
            else if(a!=ta) {
                f=0;
                break;
            }
        }
        if(f) {
            vector<int> tmp(arr[k],arr[k]+m);
            for(int i=0,j=0;i<m;i++) {
                if(j<a.size() && i==a[j]) tmp[i]^=1,j++;
            }
            if(tmp[0]==1) for(int j=0;j<m;j++) tmp[j]^=1;

            int j=0;
            for(;j<m && tmp[j]==0;j++);
            for(;j<m && tmp[j]==1;j++);
            if(j==m) {
                puts("YES");
                for(int i=0;i<n;i++) {
                    for(int j=0,k=0;j<m;j++) if(k<a.size() && j==a[k]) arr[i][j]^=1,k++;
                    if((i<=k && arr[i][0]==1) || (i>k && arr[i][0]==0)) printf("1");
                    else printf("0");
                }
                puts("");
                for(int i=0,j=0;i<m;i++) {
                    if(j<a.size() && i==a[j]) printf("1"),j++;
                    else printf("0");
                }
                return 0;
            }
        }
    }
    puts("NO");

    return 0;
}


#include <map>
#include <set>
#include <ctime>
#include <cmath>
#include <queue>
#include <stack>
#include <vector>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>
using namespace std;
#define For(i, x, y) for(int i=x;i<=y;i++)
#define _For(i, x, y) for(int i=x;i>=y;i--)
#define Mem(f, x) memset(f,x,sizeof(f))
#define Sca(x) scanf("%d", &x)
#define Sca2(x,y) scanf("%d%d",&x,&y)
#define Sca3(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define Scl(x) scanf("%lld",&x);
#define Pri(x) printf("%d\n", x)
#define Prl(x) printf("%lld\n",x);
#define CLR(u) for(int i=0;i<=N;i++)u[i].clear();
#define LL long long
#define ULL unsigned long long
#define mp make_pair
#define PII pair<int,int>
#define PIL pair<int,long long>
#define PLL pair<long long,long long>
#define pb push_back
#define fi first
#define se second
typedef vector<int> VI;
int read(){int x = 0,f = 1;char c = getchar();while (c<'0' || c>'9'){if (c == '-') f = -1;c = getchar();}
while (c >= '0'&&c <= '9'){x = x * 10 + c - '0';c = getchar();}return x*f;}
const double eps = 1e-9;
const int maxn = 210;
const int INF = 0x3f3f3f3f;
const int mod = 1e9 + 7;
int N,M,K;
int a[maxn][maxn];
int cul[maxn],row[maxn];
bool check(){
    int p = 0;
    for(int i = 1; i <= N ; i ++){
        int x = cul[1] ^ a[i][1];
        for(int j = 2; j <= M; j ++){
            if((cul[j] ^ a[i][j]) != x){
                if(p != i && p) return false;
                p = i;
            }
        }
    }
    if(p){
        if((cul[1] ^ a[p][1]) == 1) row[p] = 1;
        else row[p] = 0;
        int flag = 0;
        for(int i = 1; i <= M ; i ++){
            int x = cul[i] ^ a[p][i];
            if(x == 1){
                flag = 1;
            }else if(x == 0){
                if(flag) return false;
            }
        }
    }
    for(int i = 1; i < p ; i ++){
        if((cul[1] ^ a[i][1]) == 1) row[i] = 1;
        else row[i] = 0;
    }
    for(int i = p + 1; i <= N ; i ++){
        if((cul[1] ^ a[i][1]) == 1) row[i] = 0;
        else row[i] = 1;
    }
    return true;
}

int main(){
    Sca2(N,M);
    for(int i = 1; i <= N ; i ++){
        for(int j = 1; j <= M ; j ++){
            Sca(a[i][j]);
        }
    }
    for(int i = 1; i <= M + 1; i ++){
        for(int j = 1; j < i ; j ++){
            if(a[1][j] == 1) cul[j] = 1;
            else cul[j] = 0;
        }
        for(int j = i; j <= M; j ++){
            if(a[1][j] == 1) cul[j] = 0;
            else cul[j] = 1;
        }
        int flag = 0;
        if(check()) flag = 1;
        if(flag){
            puts("YES");
            for(int i = 1; i <= N ; i ++) printf("%d",row[i]);
            puts("");
            for(int i = 1; i <= M ; i ++) printf("%d",cul[i]);
            return 0;
        }
    }
    puts("NO");
    return 0;
}

G


#include <map>
#include <set>
#include <ctime>
#include <cmath>
#include <queue>
#include <stack>
#include <vector>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>
using namespace std;
#define For(i, x, y) for(int i=x;i<=y;i++)
#define _For(i, x, y) for(int i=x;i>=y;i--)
#define Mem(f, x) memset(f,x,sizeof(f))
#define Sca(x) scanf("%d", &x)
#define Sca2(x,y) scanf("%d%d",&x,&y)
#define Sca3(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define Scl(x) scanf("%lld",&x);
#define Pri(x) printf("%d\n", x)
#define Prl(x) printf("%lld\n",x);
#define CLR(u) for(int i=0;i<=N;i++)u[i].clear();
#define LL long long
#define ULL unsigned long long
#define mp make_pair
#define PII pair<int,int>
#define PIL pair<int,long long>
#define PLL pair<long long,long long>
#define pb push_back
#define fi first
#define se second
typedef vector<int> VI;
int read(){int x = 0,f = 1;char c = getchar();while (c<'0' || c>'9'){if (c == '-') f = -1;c = getchar();}
while (c >= '0'&&c <= '9'){x = x * 10 + c - '0';c = getchar();}return x*f;}
const double eps = 1e-9;
const int maxn = 210;
const int INF = 0x3f3f3f3f;
const int mod = 1e9 + 7;
int N,M,K;
int a[maxn][maxn];
int cul[maxn],row[maxn];
bool check(){
    int p = 0;
    for(int i = 1; i <= N ; i ++){
        int x = cul[1] ^ a[i][1];
        for(int j = 2; j <= M; j ++){
            if((cul[j] ^ a[i][j]) != x){
                if(p != i && p) return false;
                p = i;
            }
        }
    }
    if(p){
        if((cul[1] ^ a[p][1]) == 1) row[p] = 1;
        else row[p] = 0;
        int flag = 0;
        for(int i = 1; i <= M ; i ++){
            int x = cul[i] ^ a[p][i];
            if(x == 1){
                flag = 1;
            }else if(x == 0){
                if(flag) return false;
            }
        }
    }
    for(int i = 1; i < p ; i ++){
        if((cul[1] ^ a[i][1]) == 1) row[i] = 1;
        else row[i] = 0;
    }
    for(int i = p + 1; i <= N ; i ++){
        if((cul[1] ^ a[i][1]) == 1) row[i] = 0;
        else row[i] = 1;
    }
    return true;
}

int main(){
    Sca2(N,M);
    for(int i = 1; i <= N ; i ++){
        for(int j = 1; j <= M ; j ++){
            Sca(a[i][j]);
        }
    }
    for(int i = 1; i <= M + 1; i ++){
        for(int j = 1; j < i ; j ++){
            if(a[1][j] == 1) cul[j] = 1;
            else cul[j] = 0;
        }
        for(int j = i; j <= M; j ++){
            if(a[1][j] == 1) cul[j] = 0;
            else cul[j] = 1;
        }
        int flag = 0;
        if(check()) flag = 1;
        if(flag){
            puts("YES");
            for(int i = 1; i <= N ; i ++) printf("%d",row[i]);
            puts("");
            for(int i = 1; i <= M ; i ++) printf("%d",cul[i]);
            return 0;
        }
    }
    puts("NO");
    return 0;
}


//#include<bits/stdc++.h>
#include <map>
//#include <tr1/unordered_map>
#include<limits>
#include <set>
#include <ctime>
#include <cmath>
#include <queue>
#include <stack>
#include <vector>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>
using namespace std;
inline int lowbit(int x){ return x & (-x); }
inline int read(){int X = 0, w = 0; char ch = 0;while(!isdigit(ch)) { w |= ch == '-'; ch = getchar(); }
    while(isdigit(ch)) X = (X << 3) + (X << 1) + (ch ^ 48), ch = getchar();return w ? -X : X;}
template<typename A, typename B, typename C>
inline A fpow(A x, B p, C lyd){A ans = 1;for(; p; p >>= 1, x = 1LL * x * x % lyd)if(p & 1)ans = 1LL * x * ans % lyd;return ans;}
inline int gcd(int a, int b){ return b ? gcd(b, a % b) : a; }
inline int lcm(int a, int b){ return a / gcd(a, b) * b; }
template<typename T>
inline T max(T x, T y, T z){ return max(max(x, y), z); }
template<typename T>
inline T min(T x, T y, T z){ return min(min(x, y), z); }
#define For(i, x, y) for(int i=x;i<=y;i++)
#define _For(i, x, y) for(int i=x;i>=y;i--)
#define Mem(f, x) memset(f,x,sizeof(f))
#define Sca(x) scanf("%d", &x)
#define Sca2(x,y) scanf("%d%d",&x,&y)
#define Sca3(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define Scl(x) scanf("%lld",&x);
#define Pri(x) printf("%d\n", x)
#define Prl(x) printf("%lld\n",x);
#define CLR(u) for(int i=0;i<=N;i++)u[i].clear();
#define LL long long
#define ULL unsigned long long
#define mp make_pair
#define PII pair<int,int>
#define PIL pair<int,long long>
#define PLL pair<long long,long long>
#define pb push_back
#define fi first
#define se second
typedef vector<int> VI;
const double eps = 1e-9;
const int maxn = 220;
const LL INF = 0x3f3f3f3f;
const int mod = 1e9 + 7;

int n, m;
int a[maxn][maxn];
int cul[maxn], row[maxn];

bool check(){
    int p = 0;
    for (int i = 1; i <= n; ++i){
        int x = cul[1] ^ a[i][1];
        for (int j = 2; j <= m; ++j){
            if ((a[i][j] ^ cul[j]) != x){
                if (p && p != i) return false;
                p = i;
            }
        }
    }
    if (p){
        if ((cul[1] ^ a[p][1]) == 1) row[p] = 1;
        else row[p] = 0;
        int flag = 0;
        for (int i = 1; i <= m; ++i){
            int x = cul[i] ^ a[p][i];
            if (x == 1){
                flag = 1;
            }else if (x == 0){
                if (flag) return false;
            }
        }
    }
    for (int i = 1; i < p; ++i){
        if ((a[i][1] ^ cul[1]) == 1) row[i] = 1;
        else row[i] = 0;
    }
    for (int i = p + 1; i <= n; ++i){
        if ((a[i][1] ^ cul[1]) == 1) row[i] = 0;
        else row[i] = 1;
    }
    return true;
}

int main(){
    n = read(); m = read();
    for (int i = 1; i <= n; ++i)
    for (int j = 1; j <= m; ++j)
        a[i][j] = read();
    for (int i = 1; i <= m + 1; ++i){
        for (int j = 1; j < i; ++j){
            if (a[1][j] == 1) cul[j] = 1;
            else cul[j] = 0;
        }
        for (int j = i; j <= m; ++j){
            if (a[1][j] == 1) cul[j] = 0;
            else cul[j] = 1;
        }
        int flag = 0;
        if (check()) flag = 1;
        if (flag){
            puts("YES");
            for (int i = 1; i <= n; ++i) printf("%d", row[i]);
            puts("");
            for (int i = 1; i <= m; ++i) printf("%d", cul[i]);
            return 0;
        }
    }
    puts("NO");

    return 0;
}


#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define vi vector<int>
#define xx first
#define yy second
#define sz(x) ((int)(x).size())
#define rep(x,y,z) for(int x=y;x<z;x++)
#define per(x,y,z) for(int x=z-1;x>=y;x--)
#define trav(y,x) for(auto& y:x)
typedef long long ll;
using namespace std;

const int N = 201;
int n,m,a[N][N];
vi r,c;

bool dfs(int x,bool w) {
	if (x==n) return 1;
	int fi=-1,sm=0;
	if (x) {
		rep(i,0,m) {
			if (fi==-1)
				if (a[x][i]^c[i])
					fi=i;
			sm+=(a[x][i]^c[i]);
		}
		if (sm==m) {
			if (dfs(x+1,1))
				return 1;
			if (!w) {
				r[x]=1;
				return dfs(x+1,0);
			}
			return 0;
		}
		if (w) {
			if (sm&&sm!=m)
				return 0;
			if (!sm)
				r[x]=1;
			return dfs(x+1,1);
		}
		else {
			if (!sm) {
				if (dfs(x+1,0))
					return 1;
				r[x]=1;
				return dfs(x+1,1);
			}
			else {
				if (m-fi==sm) {
					if (dfs(x+1,1))
						return 1;
					return 0;
				}
				int se=-1;
				per(i,m,0)
					if ((a[x][i]^c[i])==1) {
						se = i;
						break;
					}
				if (se==sm) {
					r[x]=1;
					return dfs(x+1,1);
				}
			}
		}
	}
	else {
		rep(i,0,m) {
			if (fi==-1)
				if (a[x][i]^r[x]^c[i])
					fi=i;
			sm+=(a[x][i]^r[x]^c[i]);
		}
		if (sm) {
			if (m-fi!=sm)
				return 0;
			return dfs(x+1,1);
		}
		else
			return dfs(x+1,0);
	}
	return 0;
}

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

	cin>>n>>m;
	rep(i,0,n) rep(j,0,m) cin>>a[i][j];

	bool w = 0;
	rep(i,0,n) r.pb(0);
	rep(i,0,m) c.pb(0);

	rep(x,0,2) {
		if (w) break;
		r[0]=x; rep(i,1,n) r[i]=0;
		rep(i,0,m)
			if (a[0][i]==x)
				c[i]=1;
		rep(i,0,m) {
			if (!c[i])
				continue;
			w=dfs(0,0);
			if (w) break;
			c[i]=0;
			w=dfs(0,0);
			if (w) break;
		}
	}

	cout<<(w?"YES":"NO")<<"\n";
	if(w) {
		trav(x,r) cout<<x; cout<<"\n";
		trav(x,c) cout<<x; cout<<"\n";
	}
	return 0;
}


#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define vi vector<int>
#define xx first
#define yy second
#define sz(x) ((int)(x).size())
#define rep(x,y,z) for(int x=y;x<z;x++)
#define per(x,y,z) for(int x=z-1;x>=y;x--)
#define trav(y,x) for(auto& y:x)
typedef long long ll;
using namespace std;

const int N = 201;
int n,m,a[N][N];
vi r,c;

bool dfs(int x,bool w) {
	if (x==n) return 1;
	int fi=-1,sm=0;
	rep(i,0,m) {
		if (fi==-1)
			if (a[x][i]^r[x]^c[i])
				fi=i;
		sm+=(a[x][i]^r[x]^c[i]);
	}

	bool b = 0;
	if (x) {
		if (!sm) {
			if (!w) b|=dfs(x+1,0);
			if (!b) {
				r[x]=1;
				b|=dfs(x+1,1);
			}
		}
		else {
			if (sm==m) {
				if (w) b|=dfs(x+1,1);
				if (!w&&!b) {
					r[x]=1;
					b|=dfs(x+1,0);
				}
			}
			else if (w) return 0;
			else {
				int se=-1;
				per(i,m,0) if (a[x][i]^c[i]) se=max(se,i);
				if (se+1==sm) b|=dfs(x+1,1);
				if (!b&&m-fi==sm) b|=dfs(x+1,0);
			}
		}
	}
	else {
		if (!sm) return dfs(x+1,0);
		if (m-fi==sm) return dfs(x+1,1);
	}
	return b;
}

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

	cin>>n>>m;
	rep(i,0,n) rep(j,0,m) cin>>a[i][j];

	bool w=0;
	rep(i,0,n) r.pb(0);
	rep(i,0,m) c.pb(0);

	rep(x,0,2) if (!w) {
		r[0]=x; rep(i,1,n) r[i]=0;
		rep(y,0,2) if (!w) {
			rep(i,0,m) c[i]=(a[0][i]==(x^y));
			if (x) per (i,m,0) {
				rep(j,1,n) r[j]=0;
				w=dfs(0,0);
				if (w) break;
				c[i]^=1;
			}
			else rep(i,0,m) {
				rep(j,1,n) r[j]=0;
				w=dfs(0,0);
				if (w) break;
				c[i]^=1;
			}
			if (w) break;
			rep(j,1,n) r[j]=0;
			w=dfs(0,0);
		}
	}

	cout<<(w?"YES":"NO")<<"\n";
	if(w) {
		trav(x,r) cout<<x; cout<<"\n";
		trav(x,c) cout<<x; cout<<"\n";
	}
	return 0;
}
// *...*


#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define vi vector<int>
#define xx first
#define yy second
#define sz(x) ((int)(x).size())
#define rep(x,y,z) for(int x=y;x<z;x++)
#define per(x,y,z) for(int x=z-1;x>=y;x--)
#define trav(y,x) for(auto& y:x)
typedef long long ll;
using namespace std;

const int N = 201;
int n,m,a[N][N];
vi r,c;

bool dfs(int x,bool w) {
	if (x==n) return 1;
	int fi=-1,sm=0;
	rep(i,0,m) {
		if (fi==-1)
			if (a[x][i]^r[x]^c[i])
				fi=i;
		sm+=(a[x][i]^r[x]^c[i]);
	}

	bool b = 0;
	if (x) {
		if (!sm) {
			if (!w) b|=dfs(x+1,0);
			if (!b) {
				r[x]=1;
				b|=dfs(x+1,1);
			}
		}
		else {
			if (sm==m) {
				if (w) b|=dfs(x+1,1);
				if (!w&&!b) {
					r[x]=1;
					b|=dfs(x+1,0);
				}
			}
			else if (w) return 0;
			else {
				int se=-1;
				per(i,m,0) if (a[x][i]^c[i]) se=max(se,i);
				if (se==sm) b|=dfs(x+1,1);
				if (!b&&m-fi==sm) b|=dfs(x+1,0);
			}
		}
	}
	else {
		if (!sm) return dfs(x+1,0);
		if (m-fi==sm) return dfs(x+1,1);
	}
	return b;
}

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

	cin>>n>>m;
	rep(i,0,n) rep(j,0,m) cin>>a[i][j];

	bool w=0;
	rep(i,0,n) r.pb(0);
	rep(i,0,m) c.pb(0);

	rep(x,0,2) if (!w) {
		r[0]=x; rep(i,1,n) r[i]=0;
		rep(i,0,m) c[i]=(a[0][i]==x);
		rep(i,0,m) {
			rep(j,1,n) r[j]=0;
			w=dfs(0,0);
			if (w) break;
			c[i]^=1;
		}
		if (w) break;
		rep(j,1,n) r[j]=0;
		w=dfs(0,0);
	}

	cout<<(w?"YES":"NO")<<"\n";
	if(w) {
		trav(x,r) cout<<x; cout<<"\n";
		trav(x,c) cout<<x; cout<<"\n";
	}
	return 0;
}
// o\ - /o


#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define vi vector<int>
#define xx first
#define yy second
#define sz(x) ((int)(x).size())
#define rep(x,y,z) for(int x=y;x<z;x++)
#define per(x,z,y) for(int x=z-1;x>=y;x--)
#define trav(y,x) for(auto& y:x)
typedef long long ll;
using namespace std;

const int N = 201;
int n,m,a[N][N];
vi r,c;

bool dfs(int x,bool w) {
	if (x==n) return 1;
	int fi=-1,se=-1,sm=0;
	rep(i,0,m) {
		if (a[x][i]^r[x]^c[i]) {
			if (fi==-1) fi=i;
			se=max(se,i);
		}
		sm+=(a[x][i]^r[x]^c[i]);
	}

	bool b = 0;
	if (x) {
		if (!sm) {
			if (!w) b|=dfs(x+1,0);
			if (!b) {
				r[x]=1;
				b|=dfs(x+1,1);
			}
		}
		else {
			if (sm==m) {
				if (w) b|=dfs(x+1,1);
				if (!w&&!b) {
					r[x]=1;
					b|=dfs(x+1,0);
				}
			}
			else if (w) return 0;
			else {
				if (m-fi==sm) b|=dfs(x+1,1);
				if (!b&&se+1==sm) b|=dfs(x+1,1);
			}
		}
	}
	else {
		if (!sm) {
			b|=dfs(x+1,0);
			if (!b) b|=dfs(x+1,1);
		}
		if (m-fi==sm) b|=dfs(x+1,1);
		if (!b&&se+1==sm) b|=dfs(x+1,1);
	}
	return b;
}

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

	cin>>n>>m;
	rep(i,0,n) rep(j,0,m) cin>>a[i][j];

	bool w=0;
	rep(i,0,n) r.pb(0);
	rep(i,0,m) c.pb(0);

	rep(x,0,2) if (!w) {
		rep(y,0,2) if (!w) {
			rep(i,0,m) c[i]=((a[0][i]^x)==y);
			if (y) per(i,m,0) {
				r[0]=x; rep(j,1,n) r[j]=0;
				w=dfs(0,0);
				if (w) break;
				c[i]^=1;
			}
			else rep(i,0,m) {
				r[0]=x; rep(j,1,n) r[j]=0;
				w=dfs(0,0);
				if (w) break;
				c[i]^=1;
			}
			if (w) break;
			r[0]=x; rep(j,1,n) r[j]=0;
			w=dfs(0,0);
		}
	}

	cout<<(w?"YES":"NO")<<"\n";
	if(w) {
		trav(x,r) cout<<x; cout<<"\n";
		trav(x,c) cout<<x; cout<<"\n";
	}
	return 0;
}
// ..................................


#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define vi vector<int>
#define xx first
#define yy second
#define sz(x) ((int)(x).size())
#define rep(x,y,z) for(int x=y;x<z;x++)
#define per(x,y,z) for(int x=z-1;x>=y;x--)
#define trav(y,x) for(auto& y:x)
typedef long long ll;
using namespace std;

const int N = 201;
int n,m,a[N][N];
vi r,c;

bool dfs(int x,bool w) {
	if (x==n) return 1;
	int fi=-1,sm=0;
	rep(i,0,m) {
		if (fi==-1)
			if (a[x][i]^r[x]^c[i])
				fi=i;
		sm+=(a[x][i]^r[x]^c[i]);
	}

	bool b = 0;
	if (x) {
		if (!sm) {
			if (!w) b|=dfs(x+1,0);
			if (!b) {
				r[x]=1;
				b|=dfs(x+1,1);
			}
		}
		else {
			if (sm==m) {
				if (w) b|=dfs(x+1,1);
				if (!w&&!b) {
					r[x]=1;
					b|=dfs(x+1,0);
				}
			}
			else if (w) return 0;
			else {
				int se=-1;
				per(i,m,0) if (a[x][i]^c[i]) se=max(se,i);
				if (se==sm) b|=dfs(x+1,1);
				if (!b&&m-fi==sm) b|=dfs(x+1,0);
			}
		}
	}
	else {
		if (!sm) return dfs(x+1,0);
		if (m-fi==sm) return dfs(x+1,1);
	}
	return b;
}

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

	cin>>n>>m;
	rep(i,0,n) rep(j,0,m) cin>>a[i][j];

	bool w=0;
	rep(i,0,n) r.pb(0);
	rep(i,0,m) c.pb(0);

	rep(x,0,2) if (!w) {
		r[0]=x; rep(i,1,n) r[i]=0;
		rep(y,0,2) if (!w) {
			rep(i,0,m) c[i]=(a[0][i]==(x^y));
			if (x) per (i,m,0) {
				rep(j,1,n) r[j]=0;
				w=dfs(0,0);
				if (w) break;
				c[i]^=1;
			}
			else rep(i,0,m) {
				rep(j,1,n) r[j]=0;
				w=dfs(0,0);
				if (w) break;
				c[i]^=1;
			}
			if (w) break;
			rep(j,1,n) r[j]=0;
			w=dfs(0,0);
		}
	}

	cout<<(w?"YES":"NO")<<"\n";
	if(w) {
		trav(x,r) cout<<x; cout<<"\n";
		trav(x,c) cout<<x; cout<<"\n";
	}
	return 0;
}
// v-v


#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define vi vector<int>
#define xx first
#define yy second
#define sz(x) ((int)(x).size())
#define rep(x,y,z) for(int x=y;x<z;x++)
#define per(x,y,z) for(int x=z-1;x>=y;x--)
#define trav(y,x) for(auto& y:x)
typedef long long ll;
using namespace std;

const int N = 201;
int n,m,a[N][N];
vi r,c;

bool dfs(int x,bool w) {
	if (x==n) return 1;
	int fi=-1,sm=0;
	if (x) {
		rep(i,0,m) {
			if (fi==-1)
				if (a[x][i]^c[i])
					fi=i;
			sm+=(a[x][i]^c[i]);
		}
		if (sm==m) {
			if (dfs(x+1,1))
				return 1;
			if (!w) {
				r[x]=1;
				return dfs(x+1,0);
			}
			return 0;
		}
		if (w) {
			if (sm&&sm!=m)
				return 0;
			if (!sm)
				r[x]=1;
			return dfs(x+1,1);
		}
		else {
			if (!sm) {
				if (dfs(x+1,0))
					return 1;
				r[x]=1;
				return dfs(x+1,1);
			}
			else {
				if (m-fi==sm) {
					if (dfs(x+1,1))
						return 1;
					return 0;
				}
				int se=-1;
				per(i,m,0)
					if ((a[x][i]^c[i])==1) {
						se = i;
						break;
					}
				if (se==sm) {
					r[x]=1;
					return dfs(x+1,1);
				}
			}
		}
	}
	else {
		rep(i,0,m) {
			if (fi==-1)
				if (a[x][i]^r[x]^c[i])
					fi=i;
			sm+=(a[x][i]^r[x]^c[i]);
		}
		if (sm) {
			if (m-fi!=sm)
				return 0;
			return dfs(x+1,1);
		}
		else
			return dfs(x+1,0);
	}
	return 0;
}

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

	cin>>n>>m;
	rep(i,0,n) rep(j,0,m) cin>>a[i][j];

	bool w = 0;
	rep(i,0,n) r.pb(0);
	rep(i,0,m) c.pb(0);

	rep(x,0,2) if (!w) {
		r[0]=x; rep(i,1,n) r[i]=0;
		rep(y,0,2) {
			rep(i,0,m) c[i]=(a[0][i]==(x^y));
			rep(i,0,m) if (c[i]) {
				w=dfs(0,0);
				if (w) break;
				c[i]=0;
			}
			if (w) break;
			w=dfs(0,0);
			if (w) break;
		}
	}

	cout<<(w?"YES":"NO")<<"\n";
	if(w) {
		trav(x,r) cout<<x; cout<<"\n";
		trav(x,c) cout<<x; cout<<"\n";
	}
	return 0;
}


#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define vi vector<int>
#define xx first
#define yy second
#define sz(x) ((int)(x).size())
#define rep(x,y,z) for(int x=y;x<z;x++)
#define per(x,z,y) for(int x=z-1;x>=y;x--)
#define trav(y,x) for(auto& y:x)
typedef long long ll;
using namespace std;
const int N = 201;
int n,m,a[N][N];
vi z[2];
bool dfs(int x,bool w) {
	if (x==n) return 1;
	int fi=-1,se=-1,sm=0;
	rep(i,0,m) if (a[x][i]^z[0][x]^z[1][i]) {
		if (fi==-1) fi=i; se=max(se,i); ++sm;
	} bool b = 0;
	if (x) {
		if (!sm) {
			if (!w) b|=dfs(x+1,0);
			if (!b) { z[0][x]=1; b|=dfs(x+1,1); }
		} else {
			if (sm==m) {
				if (w) b|=dfs(x+1,1);
				if (!w&&!b) { z[0][x]=1; b|=dfs(x+1,0); }
			} else if (w) return 0;
			else {
				if (m-fi==sm) b|=dfs(x+1,1);
				if (!b&&se+1==sm) { z[0][x]=1; b|=dfs(x+1,1); }
			}
		}
	} else {
		if (!sm) return dfs(x+1,0);
		if (m-fi==sm) return dfs(x+1,1);
	} return b;
}
int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	bool w=0; cin>>n>>m;
	rep(i,0,n) rep(j,0,m) cin>>a[i][j];
	rep(i,0,n) z[0].pb(0); rep(i,0,m) z[1].pb(0);
	vi r0(m,0); rep(x,0,2) if (!w) {
		z[0][0]=x; rep(i,0,m) r0[i]=a[0][i]^x;
		rep(i,0,m) z[1][i]=r0[i];
		per(i,m,0) {
			rep(i,1,n) z[0][i]=0;
			w|=dfs(0,0); if (w) break;
			z[1][i]^=1;
		} if (w) break;
		rep(i,1,n) z[0][i]=0;
		w|=dfs(0,0); if (w) break;
		rep(i,0,m) z[1][i]=!r0[i];
		rep(i,0,m) {
			rep(i,1,n) z[0][i]=0;
			w|=dfs(0,0); if (w) break;
			z[1][i]^=1;
		} if (w) break;
		rep(i,1,n) z[0][i]=0;
		w|=dfs(0,0);
	} cout<<(w?"YES":"NO")<<"\n";
	if(w) rep(x,0,2) { trav(y,z[x]) cout<<y; cout<<"\n"; }
	return 0;
} // nice


#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define vi vector<int>
#define xx first
#define yy second
#define sz(x) ((int)(x).size())
#define rep(x,y,z) for(int x=y;x<z;x++)
#define per(x,z,y) for(int x=z-1;x>=y;x--)
#define trav(y,x) for(auto& y:x)
typedef long long ll;
using namespace std;

const int N = 201;
int n,m,a[N][N];
vi r,c;

bool dfs(int x,bool w) {
	if (x==n) return 1;
	int fi=-1,se=-1,sm=0;
	rep(i,0,m) {
		if (a[x][i]^r[x]^c[i]) {
			if (fi==-1) fi=i;
			se=max(se,i);
		}
		sm+=(a[x][i]^r[x]^c[i]);
	}

	bool b = 0;
	if (x) {
		if (!sm) {
			if (!w) b|=dfs(x+1,0);
			if (!b) {
				r[x]=1;
				b|=dfs(x+1,1);
			}
		}
		else {
			if (sm==m) {
				if (w) b|=dfs(x+1,1);
				if (!w&&!b) {
					r[x]=1;
					b|=dfs(x+1,0);
				}
			}
			else if (w) return 0;
			else {
				if (m-fi==sm) b|=dfs(x+1,1);
				if (!b&&se+1==sm) {
					r[x]=1;
					b|=dfs(x+1,1);
				}
			}
		}
	}
	else {
		if (!sm) return dfs(x+1,0);
		if (m-fi==sm) return dfs(x+1,1);
	}
	return b;
}

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

	cin>>n>>m;
	rep(i,0,n) rep(j,0,m) cin>>a[i][j];

	bool w=0;
	rep(i,0,n) r.pb(0);
	rep(i,0,m) c.pb(0);

	vi r0(m,0);
	rep(x,0,2) {
		r[0]=x;
		rep(i,0,m) r0[i]=a[0][i]^x;

		rep(i,0,m) c[i]=0;
		rep(i,0,m) if (r0[i]) c[i]=1;
		per(i,m,0) {
			rep(i,1,n) r[i]=0;
			w|=dfs(0,0);
			if (w) break;
			c[i]^=1;
		}
		if (w) break;
		rep(i,1,n) r[i]=0;
		w|=dfs(0,0);
		if (w) break;

		rep(i,0,m) c[i]=0;
		rep(i,0,m) if (!r0[i]) c[i]=1;
		rep(i,0,m) {
			rep(i,1,n) r[i]=0;
			w|=dfs(0,0);
			if (w) break;
			c[i]^=1;
		}
		if (w) break;
		rep(i,1,n) r[i]=0;
		w|=dfs(0,0);
		if (w) break;
	}

	cout<<(w?"YES":"NO")<<"\n";
	if(w) {
		trav(x,r) cout<<x; cout<<"\n";
		trav(x,c) cout<<x; cout<<"\n";
	}
	return 0;
}


#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define vi vector<int>
#define xx first
#define yy second
#define sz(x) ((int)(x).size())
#define rep(x,y,z) for(int x=y;x<z;x++)
#define per(x,y,z) for(int x=z-1;x>=y;x--)
#define trav(y,x) for(auto& y:x)
typedef long long ll;
using namespace std;

const int N = 201;
int n,m,a[N][N];
vi r,c;

bool dfs(int x,bool w) {
	if (x==n) return 1;
	int fi=-1,sm=0;
	rep(i,0,m) {
		if (fi==-1)
			if (a[x][i]^r[x]^c[i])
				fi=i;
		sm+=(a[x][i]^r[x]^c[i]);
	}

	bool b = 0;
	if (x) {
		if (!sm) {
			if (!w) b|=dfs(x+1,0);
			if (!b) {
				r[x]=1;
				b|=dfs(x+1,1);
			}
		}
		else {
			if (sm==m) {
				if (w) b|=dfs(x+1,1);
				if (!w&&!b) {
					r[x]=1;
					b|=dfs(x+1,0);
				}
			}
			else if (w) return 0;
			else {
				int se=-1;
				per(i,m,0) if (a[x][i]^c[i]) se=max(se,i);
				if (se==sm) b|=dfs(x+1,1);
				if (!b&&m-fi==sm) b|=dfs(x+1,0);
			}
		}
	}
	else {
		if (!sm) return dfs(x+1,0);
		if (m-fi==sm) return dfs(x+1,1);
	}
	return b;
}

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

	cin>>n>>m;
	rep(i,0,n) rep(j,0,m) cin>>a[i][j];

	bool w=0;
	rep(i,0,n) r.pb(0);
	rep(i,0,m) c.pb(0);

	rep(x,0,2) if (!w) {
		r[0]=x; rep(i,1,n) r[i]=0;
		rep(y,0,2) if (!w) {
			rep(i,0,m) c[i]=(a[0][i]==(x^y));
			rep(i,0,m) {
				rep(j,1,n) r[j]=0;
				w=dfs(0,0);
				if (w) break;
				c[i]^=1;
			}
			if (w) break;
			rep(j,1,n) r[j]=0;
			w=dfs(0,0);
		}
	}

	cout<<(w?"YES":"NO")<<"\n";
	if(w) {
		trav(x,r) cout<<x; cout<<"\n";
		trav(x,c) cout<<x; cout<<"\n";
	}
	return 0;
}


#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define vi vector<int>
#define xx first
#define yy second
#define sz(x) ((int)(x).size())
#define rep(x,y,z) for(int x=y;x<z;x++)
#define per(x,y,z) for(int x=z-1;x>=y;x--)
#define trav(y,x) for(auto& y:x)
typedef long long ll;
using namespace std;

const int N = 201;
int n,m,a[N][N];
vi r,c;

bool dfs(int x,bool w) {
	if (x==n) return 1;
	int fi=-1,sm=0;
	rep(i,0,m) {
		if (fi==-1)
			if (a[x][i]^r[x]^c[i])
				fi=i;
		sm+=(a[x][i]^r[x]^c[i]);
	}

	bool b = 0;
	if (x) {
		if (!sm) {
			if (!w) b|=dfs(x+1,0);
			if (!b) {
				r[x]=1;
				b|=dfs(x+1,1);
			}
		}
		else {
			if (sm==m) {
				if (w) b|=dfs(x+1,1);
				if (!w&&!b) {
					r[x]=1;
					b|=dfs(x+1,0);
				}
			}
			else if (w) return 0;
			else {
				int se=-1;
				per(i,m,0) if (a[x][i]^c[i]) se=max(se,i);
				if (se+1==sm) b|=dfs(x+1,1);
				if (!b&&m-fi==sm) b|=dfs(x+1,0);
			}
		}
	}
	else {
		if (!sm) return dfs(x+1,0);
		if (m-fi==sm) return dfs(x+1,1);
	}
	return b;
}

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

	cin>>n>>m;
	rep(i,0,n) rep(j,0,m) cin>>a[i][j];

	bool w=0;
	rep(i,0,n) r.pb(0);
	rep(i,0,m) c.pb(0);

	rep(x,0,2) if (!w) {
		r[0]=x; rep(i,1,n) r[i]=0;
		rep(y,0,2) if (!w) {
			rep(i,0,m) c[i]=(a[0][i]==(x^y));
			if (y) per (i,m,0) {
				rep(j,1,n) r[j]=0;
				w=dfs(0,0);
				if (w) break;
				c[i]^=1;
			}
			else rep(i,0,m) {
				rep(j,1,n) r[j]=0;
				w=dfs(0,0);
				if (w) break;
				c[i]^=1;
			}
			if (w) break;
			rep(j,1,n) r[j]=0;
			w=dfs(0,0);
		}
	}

	cout<<(w?"YES":"NO")<<"\n";
	if(w) {
		trav(x,r) cout<<x; cout<<"\n";
		trav(x,c) cout<<x; cout<<"\n";
	}
	return 0;
}


#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define vi vector<int>
#define xx first
#define yy second
#define sz(x) ((int)(x).size())
#define rep(x,y,z) for(int x=y;x<z;x++)
#define per(x,z,y) for(int x=z-1;x>=y;x--)
#define trav(y,x) for(auto& y:x)
typedef long long ll;
using namespace std;

const int N = 201;
int n,m,a[N][N];
vi r,c;

bool dfs(int x,bool w) {
	if (x==n) return 1;
	int fi=-1,se=-1,sm=0;
	rep(i,0,m) {
		if (a[x][i]^r[x]^c[i]) {
			if (fi==-1) fi=i;
			se=max(se,i);
		}
		sm+=(a[x][i]^r[x]^c[i]);
	}

	bool b = 0;
	if (x) {
		if (!sm) {
			if (!w) b|=dfs(x+1,0);
			if (!b) {
				r[x]=1;
				b|=dfs(x+1,1);
			}
		}
		else {
			if (sm==m) {
				if (w) b|=dfs(x+1,1);
				if (!w&&!b) {
					r[x]=1;
					b|=dfs(x+1,0);
				}
			}
			else if (w) return 0;
			else {
				if (m-fi==sm) b|=dfs(x+1,1);
				if (!b&&se+1==sm) b|=dfs(x+1,1);
			}
		}
	}
	else {
		if (!sm) b|=dfs(x+1,0);
		if (m-fi==sm) b|=dfs(x+1,1);
	}
	return b;
}

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

	cin>>n>>m;
	rep(i,0,n) rep(j,0,m) cin>>a[i][j];

	bool w=0;
	rep(i,0,n) r.pb(0);
	rep(i,0,m) c.pb(0);

	rep(x,0,2) if (!w) {
		rep(y,0,2) if (!w) {
			rep(i,0,m) c[i]=((a[0][i]^x)==y);
			if (y) per(i,m,0) {
				r[0]=x; rep(j,1,n) r[j]=0;
				w=dfs(0,0);
				if (w) break;
				c[i]^=1;
			}
			else rep(i,0,m) {
				r[0]=x; rep(j,1,n) r[j]=0;
				w=dfs(0,0);
				if (w) break;
				c[i]^=1;
			}
			if (w) break;
			r[0]=x; rep(j,1,n) r[j]=0;
			w=dfs(0,0);
		}
	}

	cout<<(w?"YES":"NO")<<"\n";
	if(w) {
		trav(x,r) cout<<x; cout<<"\n";
		trav(x,c) cout<<x; cout<<"\n";
	}
	return 0;
}
// yarga a dinga dirgen


#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define vi vector<int>
#define xx first
#define yy second
#define sz(x) ((int)(x).size())
#define rep(x,y,z) for(int x=y;x<z;x++)
#define per(x,y,z) for(int x=z-1;x>=y;x--)
#define trav(y,x) for(auto& y:x)
typedef long long ll;
using namespace std;

const int N = 201;
int n,m,a[N][N];
vi r,c;

bool dfs(int x,bool w) {
	if (x==n) return 1;
	int fi=-1,sm=0;
	rep(i,0,m) {
		if (fi==-1)
			if (a[x][i]^r[x]^c[i])
				fi=i;
		sm+=(a[x][i]^r[x]^c[i]);
	}

	bool b = 0;
	if (x) {
		if (!sm) {
			if (!w) b|=dfs(x+1,0);
			if (!b) {
				r[x]=1;
				b|=dfs(x+1,1);
			}
		}
		else {
			if (sm==m) {
				if (w) b|=dfs(x+1,1);
				if (!w&&!b) {
					r[x]=1;
					b|=dfs(x+1,0);
				}
			}
			else if (w) return 0;
			else {
				int se=-1;
				per(i,m,0) if (a[x][i]^c[i]) se=max(se,i);
				if (se==sm) b|=dfs(x+1,1);
				if (!b&&m-fi==sm) b|=dfs(x+1,0);
			}
		}
	}
	else {
		if (!sm) return dfs(x+1,0);
		if (m-fi==sm) return dfs(x+1,1);
	}
	return b;
}

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

	cin>>n>>m;
	rep(i,0,n) rep(j,0,m) cin>>a[i][j];

	bool w=0;
	rep(i,0,n) r.pb(0);
	rep(i,0,m) c.pb(0);

	rep(x,0,2) if (!w) {
		r[0]=x; rep(i,1,n) r[i]=0;
		rep(y,0,2) {
			rep(i,0,m) c[i]=(a[0][i]==(x^y));
			rep(i,0,m) if (c[i]) {
				rep(j,1,n) r[j]=0;
				w=dfs(0,0);
				if (w) break;
				c[i]=0;
			}
			if (w) break;
			rep(j,1,n) r[j]=0;
			w=dfs(0,0);
			if (w) break;
		}
	}

	cout<<(w?"YES":"NO")<<"\n";
	if(w) {
		trav(x,r) cout<<x; cout<<"\n";
		trav(x,c) cout<<x; cout<<"\n";
	}
	return 0;
}


#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define vi vector<int>
#define xx first
#define yy second
#define sz(x) ((int)(x).size())
#define rep(x,y,z) for(int x=y;x<z;x++)
#define per(x,y,z) for(int x=z-1;x>=y;x--)
#define trav(y,x) for(auto& y:x)
typedef long long ll;
using namespace std;

const int N = 201;
int n,m,a[N][N];
vi r,c;

bool dfs(int x,bool w) {
	if (x==n) return 1;
	int fi=-1,sm=0;
	rep(i,0,m) {
		if (fi==-1)
			if (a[x][i]^r[x]^c[i])
				fi=i;
		sm+=(a[x][i]^r[x]^c[i]);
	}

	bool b = 0;
	if (x) {
		if (!sm) {
			if (!w) b|=dfs(x+1,0);
			if (!b) {
				r[x]=1;
				b|=dfs(x+1,1);
			}
		}
		else {
			if (sm==m) {
				if (w) b|=dfs(x+1,1);
				if (!w&&!b) {
					r[x]=1;
					b|=dfs(x+1,0);
				}
			}
			else if (w) return 0;
			else {
				int se=-1;
				per(i,m,0) if (a[x][i]^c[i]) se=max(se,i);
				if (se==sm) b|=dfs(x+1,1);
				if (!b&&m-fi==sm) b|=dfs(x+1,0);
			}
		}
	}
	else {
		if (!sm) return dfs(x+1,0);
		if (m-fi==sm) return dfs(x+1,1);
	}
	return b;
}

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

	cin>>n>>m;
	rep(i,0,n) rep(j,0,m) cin>>a[i][j];

	bool w=0;
	rep(i,0,n) r.pb(0);
	rep(i,0,m) c.pb(0);

	rep(x,0,2) if (!w) {
		r[0]=x; rep(i,1,n) r[i]=0;
		rep(y,0,2) if (!w) {
			rep(i,0,m) c[i]=(a[0][i]==(x^y));
			if (y) per (i,m,0) {
				rep(j,1,n) r[j]=0;
				w=dfs(0,0);
				if (w) break;
				c[i]^=1;
			}
			else rep(i,0,m) {
				rep(j,1,n) r[j]=0;
				w=dfs(0,0);
				if (w) break;
				c[i]^=1;
			}
			if (w) break;
			rep(j,1,n) r[j]=0;
			w=dfs(0,0);
		}
	}

	cout<<(w?"YES":"NO")<<"\n";
	if(w) {
		trav(x,r) cout<<x; cout<<"\n";
		trav(x,c) cout<<x; cout<<"\n";
	}
	return 0;
}
// -.-


#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define vi vector<int>
#define xx first
#define yy second
#define sz(x) ((int)(x).size())
#define rep(x,y,z) for(int x=y;x<z;x++)
#define per(x,z,y) for(int x=z-1;x>=y;x--)
#define trav(y,x) for(auto& y:x)
typedef long long ll;
using namespace std;

const int N = 201;
int n,m,a[N][N];
vi r,c;

bool dfs(int x,bool w) {
	if (x==n) return 1;
	int fi=-1,se=-1,sm=0;
	rep(i,0,m) {
		if (a[x][i]^r[x]^c[i]) {
			if (fi==-1) fi=i;
			se=max(se,i);
		}
		sm+=(a[x][i]^r[x]^c[i]);
	}

	bool b = 0;
	if (x) {
		if (!sm) {
			if (!w) b|=dfs(x+1,0);
			if (!b) {
				r[x]=1;
				b|=dfs(x+1,1);
			}
		}
		else {
			if (sm==m) {
				if (w) b|=dfs(x+1,1);
				if (!w&&!b) {
					r[x]=1;
					b|=dfs(x+1,0);
				}
			}
			else if (w) return 0;
			else {
				if (m-fi==sm) b|=dfs(x+1,1);
				if (!b&&se+1==sm) b|=dfs(x+1,1);
			}
		}
	}
	else {
		if (!sm) {
			b|=dfs(x+1,0);
			if (!b) {
				r[x]^=1;
				b|=dfs(x+1,1);
			}
		}
		else if (sm==m) {
			b|=dfs(x+1,1);
			if (!b) {
				r[x]^=1;
				b|=dfs(x+1,0);
			}
		}
		else {
			if (m-fi==sm) b|=dfs(x+1,1);
			if (!b&&se+1==sm) {
				r[x]^=1;
				b|=dfs(x+1,1);
			}
		}
	}
	return b;
}

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

	cin>>n>>m;
	rep(i,0,n) rep(j,0,m) cin>>a[i][j];

	bool w=0;
	rep(i,0,n) r.pb(0);
	rep(i,0,m) c.pb(0);

	rep(x,0,2) if (!w) {
		rep(y,0,2) if (!w) {
			rep(i,0,m) c[i]=((a[0][i]^x)==y);
			if (y) per(i,m,0) {
				r[0]=x; rep(j,1,n) r[j]=0;
				w=dfs(0,0);
				if (w) break;
				c[i]^=1;
			}
			else rep(i,0,m) {
				r[0]=x; rep(j,1,n) r[j]=0;
				w=dfs(0,0);
				if (w) break;
				c[i]^=1;
			}
			if (w) break;
			r[0]=x; rep(j,1,n) r[j]=0;
			w=dfs(0,0);
		}
	}

	cout<<(w?"YES":"NO")<<"\n";
	if(w) {
		trav(x,r) cout<<x; cout<<"\n";
		trav(x,c) cout<<x; cout<<"\n";
	}
	return 0;
}


#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define vi vector<int>
#define xx first
#define yy second
#define sz(x) ((int)(x).size())
#define rep(x,y,z) for(int x=y;x<z;x++)
#define per(x,y,z) for(int x=z-1;x>=y;x--)
#define trav(y,x) for(auto& y:x)
typedef long long ll;
using namespace std;

const int N = 201;
int n,m,a[N][N];
vi r,c;

bool dfs(int x,bool w) {
	if (x==n) return 1;
	int fi=-1,sm=0;
	if (x) {
		rep(i,0,m) {
			if (fi==-1)
				if (a[x][i]^c[i])
					fi=i;
			sm+=(a[x][i]^c[i]);
		}
		if (sm==m) {
			if (dfs(x+1,1))
				return 1;
			if (!w) {
				r[x]=1;
				return dfs(x+1,0);
			}
			return 0;
		}
		if (w) {
			if (sm&&sm!=m)
				return 0;
			if (!sm)
				r[x]=1;
			return dfs(x+1,1);
		}
		else {
			if (!sm) {
				if (dfs(x+1,0))
					return 1;
				r[x]=1;
				return dfs(x+1,1);
			}
			else {
				if (m-fi==sm) {
					if (dfs(x+1,1))
						return 1;
					return 0;
				}
				int se=-1;
				per(i,m,0)
					if ((a[x][i]^c[i])==1) {
						se = i;
						break;
					}
				if (se==sm) {
					r[x]=1;
					return dfs(x+1,1);
				}
			}
		}
	}
	else {
		rep(i,0,m) {
			if (fi==-1)
				if (a[x][i]^r[x]^c[i])
					fi=i;
			sm+=(a[x][i]^r[x]^c[i]);
		}
		if (sm) {
			if (m-fi!=sm)
				return 0;
			return dfs(x+1,1);
		}
		else
			return dfs(x+1,0);
	}
	return 0;
}

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

	cin>>n>>m;
	rep(i,0,n) rep(j,0,m) cin>>a[i][j];

	bool w=0;
	rep(i,0,n) r.pb(0);
	rep(i,0,m) c.pb(0);

	rep(x,0,2) if (!w) {
		r[0]=x; rep(i,1,n) r[i]=0;
		rep(y,0,2) {
			rep(i,0,m) c[i]=(a[0][i]==(x^y));
			rep(i,0,m) if (c[i]) {
				rep(j,1,n) r[j]=0;
				w=dfs(0,0);
				if (w) break;
				c[i]=0;
			}
			if (w) break;
			rep(j,1,n) r[j]=0;
			w=dfs(0,0);
			if (w) break;
		}
	}

	cout<<(w?"YES":"NO")<<"\n";
	if(w) {
		trav(x,r) cout<<x; cout<<"\n";
		trav(x,c) cout<<x; cout<<"\n";
	}
	return 0;
}


#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define vi vector<int>
#define xx first
#define yy second
#define sz(x) ((int)(x).size())
#define rep(x,y,z) for(int x=y;x<z;x++)
#define per(x,y,z) for(int x=z-1;x>=y;x--)
#define trav(y,x) for(auto& y:x)
typedef long long ll;
using namespace std;

const int N = 201;
int n,m,a[N][N];
vi r,c;

bool dfs(int x,bool w) {
	if (x==n) return 1;
	int fi=-1,sm=0;
	if (x) {
		rep(i,0,m) {
			if (fi==-1)
				if (a[x][i]^c[i])
					fi=i;
			sm+=(a[x][i]^c[i]);
		}
		if (sm==m) {
			if (dfs(x+1,1))
				return 1;
			if (!w) {
				r[x]=1;
				return dfs(x+1,0);
			}
			return 0;
		}
		if (w) {
			if (sm&&sm!=m)
				return 0;
			if (!sm)
				r[x]=1;
			return dfs(x+1,1);
		}
		else {
			if (!sm) {
				if (dfs(x+1,0))
					return 1;
				r[x]=1;
				return dfs(x+1,1);
			}
			else {
				if (m-fi==sm) {
					if (dfs(x+1,1))
						return 1;
					return 0;
				}
				int se=-1;
				per(i,m,0)
					if ((a[x][i]^c[i])==1) {
						se = i;
						break;
					}
				if (se==sm) {
					r[x]=1;
					return dfs(x+1,1);
				}
			}
		}
	}
	else {
		rep(i,0,m) {
			if (fi==-1)
				if (a[x][i]^r[x]^c[i])
					fi=i;
			sm+=(a[x][i]^r[x]^c[i]);
		}
		if (sm) {
			if (m-fi!=sm)
				return 0;
			return dfs(x+1,1);
		}
		else
			return dfs(x+1,0);
	}
	return 0;
}

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

	cin>>n>>m;
	rep(i,0,n) rep(j,0,m) cin>>a[i][j];

	bool w = 0;
	rep(i,0,n) r.pb(0);
	rep(i,0,m) c.pb(0);

	rep(x,0,2) {
		if (w) break;
		r[0]=x; rep(i,1,n) r[i]=0;
		rep(y,0,2) {
			rep(i,0,m) c[i]=(a[0][i]==(x^y));
			rep(i,0,m) if (c[i]) {
				w=dfs(0,0);
				if (w) break;
				c[i]=0;
			}
			w=dfs(0,0);
			if (w) break;
		}
	}

	cout<<(w?"YES":"NO")<<"\n";
	if(w) {
		trav(x,r) cout<<x; cout<<"\n";
		trav(x,c) cout<<x; cout<<"\n";
	}
	return 0;
}


#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define vi vector<int>
#define xx first
#define yy second
#define sz(x) ((int)(x).size())
#define rep(x,y,z) for(int x=y;x<z;x++)
#define per(x,z,y) for(int x=z-1;x>=y;x--)
#define trav(y,x) for(auto& y:x)
typedef long long ll;
using namespace std;

const int N = 201;
int n,m,a[N][N];
vi r,c;

bool dfs(int x,bool w) {
	if (x==n) return 1;
	int fi=-1,sm=0;
	rep(i,0,m) {
		if (fi==-1)
			if (a[x][i]^r[x]^c[i])
				fi=i;
		sm+=(a[x][i]^r[x]^c[i]);
	}

	bool b = 0;
	if (x) {
		if (!sm) {
			if (!w) b|=dfs(x+1,0);
			if (!b) {
				r[x]=1;
				b|=dfs(x+1,1);
			}
		}
		else {
			if (sm==m) {
				if (w) b|=dfs(x+1,1);
				if (!w&&!b) {
					r[x]=1;
					b|=dfs(x+1,0);
				}
			}
			else if (w) return 0;
			else {
				int se=-1;
				per(i,m,0) if (a[x][i]^c[i]) se=max(se,i);
				if (se+1==sm) b|=dfs(x+1,1);
				if (!b&&m-fi==sm) b|=dfs(x+1,0);
			}
		}
	}
	else {
		if (!sm) return dfs(x+1,0);
		if (m-fi==sm) return dfs(x+1,1);
	}
	return b;
}

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

	cin>>n>>m;
	rep(i,0,n) rep(j,0,m) cin>>a[i][j];

	bool w=0;
	rep(i,0,n) r.pb(0);
	rep(i,0,m) c.pb(0);

	rep(x,0,2) if (!w) {
		r[0]=x; rep(i,1,n) r[i]=0;
		rep(y,0,2) if (!w) {
			rep(i,0,m) c[i]=(a[0][i]==(x^y));
			if (y) per(i,m,0) {
				rep(j,1,n) r[j]=0;
				w=dfs(0,0);
				if (w) break;
				c[i]^=1;
			}
			else rep(i,0,m) {
				rep(j,1,n) r[j]=0;
				w=dfs(0,0);
				if (w) break;
				c[i]^=1;
			}
			if (w) break;
			rep(j,1,n) r[j]=0;
			w=dfs(0,0);
		}
	}

	cout<<(w?"YES":"NO")<<"\n";
	if(w) {
		trav(x,r) cout<<x; cout<<"\n";
		trav(x,c) cout<<x; cout<<"\n";
	}
	return 0;
}
// angry cat noises


#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef double db;

typedef pair<int,int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
#define mp make_pair
#define f first
#define s second

typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<ld> vd;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<pd> vpd;

#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define rall(x) (x).rbegin(), (x).rend()
#define rsz resize
#define ins insert
#define ft front()
#define bk back()
#define pf push_front
#define pb push_back
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound

const int MOD = 1000000007;
const ll INF = 1e18;
const ld PI = acos((ld)-1);
const int xd[4] = {1,0,-1,0}, yd[4] = {0,1,0,-1};
const int MAXN = 205;

int N,M,A[MAXN][MAXN],nxt[MAXN][MAXN],tot[MAXN];
bool marked[MAXN],m2[MAXN];

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cin >> N >> M;
    for(int i=1; i<=N; i++)
        for(int k=1; k<=M; k++)
            cin >> A[i][k];
    for(int t=0; t<2; t++){
        for(int f=0; f<=M; f++){
            memset(marked,false,sizeof marked);
            memset(tot,0,sizeof tot);
            for(int i=1; i<=M; i++){
                if(i <= f && A[1][i] == 1) marked[i] = true;
                else if(i > f && A[1][i] == 0) marked[i] = true;
            }
            for(int i=1; i<=M; i++){
                for(int k=1; k<=N; k++){
                    nxt[k][i] = A[k][i];
                    if(marked[i])
                        nxt[k][i]^=1;
                }
            }
            bool fl = false;
            for(int i=1; i<=N; i++)
                for(int k=1; k<=M; k++)
                    tot[i]+=nxt[i][k];
            for(int i=1; i<=N; i++){
                memset(m2,false,sizeof m2);
                if(t) m2[1] = true;
                bool bad2 = false;
                for(int k=1; k<i; k++){
                    if(tot[k] == M) m2[k] = true;
                    else if(tot[k] != 0) bad2 = true;
                }
                if(A[i][1] == 1){
                    m2[i] = true;
                    bool fnd = false;
                    for(int k=1; k<=M; k++){
                        nxt[i][k]^=1;
                        if(nxt[i][k]) fnd = true;
                        else if(fnd) bad2 = true;
                    }
                }
                for(int k=i+1; k<=N; k++){
                    if(tot[k] == 0) m2[k] = true;
                    else if(tot[k] != M) bad2 = true;
                }
                if(!bad2){
                    cout << "YES" << "\n";
                    for(int k=1; k<=N; k++) cout << m2[k];
                    cout << "\n";
                    for(int k=1; k<=M; k++) cout << marked[k];
                    cout << "\n";
                    return 0;
                }
            }
        }
        for(int i=1; i<=M; i++)
            A[1][i]^=1;
    }
    cout << "NO" << "\n";
}


#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef double db;

typedef pair<int,int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
#define mp make_pair
#define f first
#define s second

typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<ld> vd;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<pd> vpd;

#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define rall(x) (x).rbegin(), (x).rend()
#define rsz resize
#define ins insert
#define ft front()
#define bk back()
#define pf push_front
#define pb push_back
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound

const int MOD = 1000000007;
const ll INF = 1e18;
const ld PI = acos((ld)-1);
const int xd[4] = {1,0,-1,0}, yd[4] = {0,1,0,-1};
const int MAXN = 205;

int N,M,A[MAXN][MAXN],nxt[MAXN][MAXN],tot[MAXN];
bool marked[MAXN],m2[MAXN];

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cin >> N >> M;
    for(int i=1; i<=N; i++)
        for(int k=1; k<=M; k++)
            cin >> A[i][k];
    for(int t=0; t<2; t++){
        for(int f=0; f<=M; f++){
            memset(marked,false,sizeof marked);
            memset(tot,0,sizeof tot);
            for(int i=1; i<=M; i++){
                if(i <= f && A[1][i] == 1) marked[i] = true;
                else if(i > f && A[1][i] == 0) marked[i] = true;
            }
            for(int i=1; i<=M; i++){
                for(int k=1; k<=N; k++){
                    nxt[k][i] = A[k][i];
                    if(marked[i])
                        nxt[k][i]^=1;
                }
            }
            bool fl = false;
            for(int i=1; i<=N; i++)
                for(int k=1; k<=M; k++)
                    tot[i]+=nxt[i][k];
            for(int i=1; i<=N; i++){
                memset(m2,false,sizeof m2);
                if(t) m2[1] = true;
                bool bad2 = false;
                for(int k=1; k<i; k++){
                    if(tot[k] == M) m2[k] = true;
                    else if(tot[k] != 0) bad2 = true;
                }
                if(nxt[i][1] == 1){
                    m2[i] = true;
                    bool fnd = false;
                    for(int k=1; k<=M; k++){
                        nxt[i][k]^=1;
                        if(nxt[i][k]) fnd = true;
                        else if(fnd) bad2 = true;
                    }
                }
                for(int k=i+1; k<=N; k++){
                    if(tot[k] == 0) m2[k] = true;
                    else if(tot[k] != M) bad2 = true;
                }
                if(!bad2){
                    cout << "YES" << "\n";
                    for(int k=1; k<=N; k++) cout << m2[k];
                    cout << "\n";
                    for(int k=1; k<=M; k++) cout << marked[k];
                    cout << "\n";
                    return 0;
                }
            }
        }
        for(int i=1; i<=M; i++)
            A[1][i]^=1;
    }
    cout << "NO" << "\n";
}


#include <bits/stdc++.h>

using namespace std;
#define endl '\n'
#define task "ProA"
#define MASK(i) (1LL << (i))
#define c_bit(i) __builtin_popcountll(i) // đếm số bit đang bật
#define BIT(x, i) ((x) & MASK(i)) // trạng thái của bit thứ i trong x
#define SET_ON(x, i) ((x) | MASK(i)) // bật bit thứ i trong x
#define SET_OFF(x, i) ((x) & ~MASK(i)) //  tắt bit thứ i trong x
const int MAXN = 205;
const int INF = 1e9 + 7;
int N, M;
bool A[MAXN][MAXN];
void Input()
{
	cin >> N >> M;
	for(int i = 1; i <= N; i++)
		for(int j = 1; j <= M; j++)
			cin >> A[i][j];
}
bool B[MAXN][MAXN];
void invCol(const int &x)
{
	for(int i = 1; i <= N; i++)
		B[i][x] ^= 1;
}
void invRow(const int &x)
{
	for(int i = 1; i <= M; i++)
		B[x][i] ^= 1;
}
string ansRow, ansCol;
void Refresh()
{
	ansRow.clear();
	ansCol.clear();
	for(int i = 1; i <= N; i++)
		ansRow += '0';
	for(int i = 1; i <= M; i++)
		ansCol += '0';
	for(int i = 1; i <= N; i++)
		for(int j = 1; j <= M; j++)
			B[i][j] = A[i][j];
}
vector <bool> save;
bool check()
{
	save.clear();
	for(int i = 1; i <= N; i++)
		for(int j = 1; j <= M; j++)
			save.push_back(B[i][j]);
	for(int i = 1; i < (int) save.size(); i++)
		if(save[i] < save[i - 1])
			return false;
	return true;
}
void Output()
{
	Refresh();
	if(check())
	{
		cout << "YES" << endl;
		cout << ansRow << endl;
		cout << ansCol;
		return ;
	}
	for(int col = 1; col <= M; col++)
	{
		Refresh();
		for(int i = 1; i <= M; i++)
		{
			if(i < col && B[1][i])
			{
				ansCol[i - 1] = '1';
				invCol(i);
			}
			if(i >= col && !B[1][i])
			{
				ansCol[i - 1] = '1';
				invCol(i);
			}
		}
		for(int i = 2; i <= N; i++)
			if(!B[i][1])
			{
				ansRow[i - 1] = '1';
				invRow(i);
			}
		if(check())
		{
			cout << "YES" << endl;
			cout << ansRow << endl;
			cout << ansCol;
			return ;
		}
	}
	for(int row = 1; row <= N; row++)
	{
		Refresh();
		for(int i = 1; i <= N; i++)
		{
			if(i < row && B[i][1])
			{
				ansRow[i - 1] = '1';
				invRow(i);
			}
			if(i >= row && !B[1][i])
			{
				ansRow[i - 1] = '1';
				invRow(i);
			}
		}
		for(int i = 2; i <= M; i++)
			if(B[1][i])
			{
				ansCol[i - 1] = '1';
				invCol(i);
			}
		if(check())
		{
			cout << "YES" << endl;
			cout << ansRow << endl;
			cout << ansCol;
			return ;
		}
	}
	cout << "NO";
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    // freopen(task".inp", "r", stdin);
    // freopen(task".out", "w", stdout);
    Input();
    Output();
    return 0;
}


#include <bits/stdc++.h>

using namespace std;
#define endl '\n'
#define task "ProA"
#define MASK(i) (1LL << (i))
#define c_bit(i) __builtin_popcountll(i) // đếm số bit đang bật
#define BIT(x, i) ((x) & MASK(i)) // trạng thái của bit thứ i trong x
#define SET_ON(x, i) ((x) | MASK(i)) // bật bit thứ i trong x
#define SET_OFF(x, i) ((x) & ~MASK(i)) //  tắt bit thứ i trong x
const int MAXN = 205;
const int INF = 1e9 + 7;
int N, M;
bool A[MAXN][MAXN];
void Input()
{
	cin >> N >> M;
	for(int i = 1; i <= N; i++)
		for(int j = 1; j <= M; j++)
			cin >> A[i][j];
}
bool B[MAXN][MAXN];
void invCol(const int &x)
{
	for(int i = 1; i <= N; i++)
		B[i][x] ^= 1;
}
void invRow(const int &x)
{
	for(int i = 1; i <= M; i++)
		B[x][i] ^= 1;
}
string ansRow, ansCol;
void Refresh()
{
	ansRow.clear();
	ansCol.clear();
	for(int i = 1; i <= N; i++)
		ansRow += '0';
	for(int i = 1; i <= M; i++)
		ansCol += '0';
	for(int i = 1; i <= N; i++)
		for(int j = 1; j <= M; j++)
			B[i][j] = A[i][j];
}
vector <bool> save;
bool check()
{
	save.clear();
	for(int i = 1; i <= N; i++)
		for(int j = 1; j <= M; j++)
			save.push_back(B[i][j]);
	for(int i = 1; i < (int) save.size(); i++)
		if(save[i] < save[i - 1])
			return false;
	return true;
}
void Output()
{
	Refresh();
	if(check())
	{
		cout << "YES" << endl;
		cout << ansRow << endl;
		cout << ansCol;
		return ;
	}
	for(int col = 1; col <= M + 1; col++)
	{
		Refresh();
		for(int i = 1; i <= M; i++)
		{
			if(i < col && B[1][i])
			{
				ansCol[i - 1] = '1';
				invCol(i);
			}
			if(i >= col && !B[1][i])
			{
				ansCol[i - 1] = '1';
				invCol(i);
			}
		}
		if(col == M + 1)
		{
			for(int i = 2; i <= N; i++)
				if(B[i][1] < B[i - 1][N])
				{
					ansRow[i - 1] = '1';
					invRow(i);
				}
		}
		else
			for(int i = 2; i <= N; i++)
				if(!B[i][1])
				{
					ansRow[i - 1] = '1';
					invRow(i);
				}
		if(check())
		{
			cout << "YES" << endl;
			cout << ansRow << endl;
			cout << ansCol;
			return ;
		}
	}
	for(int row = 1; row <= N + 1; row++)
	{
		Refresh();
		for(int i = 1; i <= N; i++)
		{
			if(i < row && B[i][1])
			{
				ansRow[i - 1] = '1';
				invRow(i);
			}
			if(i >= row && !B[1][i])
			{
				ansRow[i - 1] = '1';
				invRow(i);
			}
		}
		if(row == N + 1)
		{
			for(int i = 2; i <= M; i++)
				if(B[1][i] < B[M][i - 1])
				{
					ansCol[i - 1] = '1';
					invCol(i);
				}
		}
		else
			for(int i = 2; i <= M; i++)
				if(B[1][i])
				{
					ansCol[i - 1] = '1';
					invCol(i);
				}
		if(check())
		{
			cout << "YES" << endl;
			cout << ansRow << endl;
			cout << ansCol;
			return ;
		}
	}
	cout << "NO";
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    // freopen(task".inp", "r", stdin);
    // freopen(task".out", "w", stdout);
    Input();
    Output();
    return 0;
}


#include <bits/stdc++.h>

using namespace std;
#define endl '\n'
#define task "ProA"
#define MASK(i) (1LL << (i))
#define c_bit(i) __builtin_popcountll(i) // đếm số bit đang bật
#define BIT(x, i) ((x) & MASK(i)) // trạng thái của bit thứ i trong x
#define SET_ON(x, i) ((x) | MASK(i)) // bật bit thứ i trong x
#define SET_OFF(x, i) ((x) & ~MASK(i)) //  tắt bit thứ i trong x
const int MAXN = 205;
const int INF = 1e9 + 7;
int N, M;
bool A[MAXN][MAXN];
void Input()
{
	cin >> N >> M;
	for(int i = 1; i <= N; i++)
		for(int j = 1; j <= M; j++)
			cin >> A[i][j];
}
bool B[MAXN][MAXN];
void invCol(const int &x)
{
	for(int i = 1; i <= N; i++)
		B[i][x] ^= 1;
}
void invRow(const int &x)
{
	for(int i = 1; i <= M; i++)
		B[x][i] ^= 1;
}
string ansRow, ansCol;
void Refresh()
{
	ansRow.clear();
	ansCol.clear();
	for(int i = 1; i <= N; i++)
		ansRow += '0';
	for(int i = 1; i <= M; i++)
		ansCol += '0';
	for(int i = 1; i <= N; i++)
		for(int j = 1; j <= M; j++)
			B[i][j] = A[i][j];
}
vector <bool> save;
bool check()
{
	save.clear();
	for(int i = 1; i <= N; i++)
		for(int j = 1; j <= M; j++)
			save.push_back(B[i][j]);
	for(int i = 1; i < (int) save.size(); i++)
		if(save[i] < save[i - 1])
			return false;
	return true;
}
void Output()
{
	Refresh();
	if(check())
	{
		cout << "YES" << endl;
		cout << ansRow << endl;
		cout << ansCol;
		return ;
	}
	for(int col = 1; col <= M + 1; col++)
	{
		Refresh();
		for(int i = 1; i <= M; i++)
		{
			if(i < col && B[1][i])
			{
				ansCol[i - 1] = '1';
				invCol(i);
			}
			if(i >= col && !B[1][i])
			{
				ansCol[i - 1] = '1';
				invCol(i);
			}
		}
		if(col == M + 1)
		{
			for(int i = 2; i <= N; i++)
				if(B[i][1] < B[i - 1][N])
				{
					ansRow[i - 1] = '1';
					invRow(i);
				}
		}
		else
			for(int i = 2; i <= N; i++)
				if(!B[i][1])
				{
					ansRow[i - 1] = '1';
					invRow(i);
				}
		if(check())
		{
			cout << "YES" << endl;
			cout << ansRow << endl;
			cout << ansCol;
			return ;
		}
	}
	for(int row = 1; row <= N + 1; row++)
	{
		Refresh();
		for(int i = 1; i <= N; i++)
		{
			if(i < row && B[i][1])
			{
				ansRow[i - 1] = '1';
				invRow(i);
			}
			if(i >= row && !B[1][i])
			{
				ansRow[i - 1] = '1';
				invRow(i);
			}
		}
		if(row == N + 1)
		{
			for(int i = 2; i <= M; i++)
				if(B[2][i])
				{
					ansCol[i - 1] = '1';
					invCol(i);
				}
		}
		else
			for(int i = 2; i <= M; i++)
				if(B[1][i])
				{
					ansCol[i - 1] = '1';
					invCol(i);
				}
		if(check())
		{
			cout << "YES" << endl;
			cout << ansRow << endl;
			cout << ansCol;
			return ;
		}
	}
	cout << "NO";
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    // freopen(task".inp", "r", stdin);
    // freopen(task".out", "w", stdout);
    Input();
    Output();
    return 0;
}


#include <bits/stdc++.h>

using namespace std;
#define endl '\n'
#define task "ProA"
#define MASK(i) (1LL << (i))
#define c_bit(i) __builtin_popcountll(i) // đếm số bit đang bật
#define BIT(x, i) ((x) & MASK(i)) // trạng thái của bit thứ i trong x
#define SET_ON(x, i) ((x) | MASK(i)) // bật bit thứ i trong x
#define SET_OFF(x, i) ((x) & ~MASK(i)) //  tắt bit thứ i trong x
const int MAXN = 205;
const int INF = 1e9 + 7;
int N, M;
bool A[MAXN][MAXN];
void Input()
{
	cin >> N >> M;
	for(int i = 1; i <= N; i++)
		for(int j = 1; j <= M; j++)
			cin >> A[i][j];
}
bool B[MAXN][MAXN];
void invCol(const int &x)
{
	for(int i = 1; i <= N; i++)
		B[i][x] ^= 1;
}
void invRow(const int &x)
{
	for(int i = 1; i <= M; i++)
		B[x][i] ^= 1;
}
string ansRow, ansCol;
void Refresh()
{
	ansRow.clear();
	ansCol.clear();
	for(int i = 1; i <= N; i++)
		ansRow += '0';
	for(int i = 1; i <= M; i++)
		ansCol += '0';
	for(int i = 1; i <= N; i++)
		for(int j = 1; j <= M; j++)
			B[i][j] = A[i][j];
}
vector <bool> save;
bool check()
{
	save.clear();
	for(int i = 1; i <= N; i++)
		for(int j = 1; j <= M; j++)
			save.push_back(B[i][j]);
	for(int i = 1; i < (int) save.size(); i++)
		if(save[i] < save[i - 1])
			return false;
	return true;
}
void Output()
{
	Refresh();
	if(check())
	{
		cout << "YES" << endl;
		cout << ansRow << endl;
		cout << ansCol;
		return ;
	}
	for(int col = 1; col <= M + 1; col++)
	{
		Refresh();
		for(int i = 1; i <= M; i++)
		{
			if(i < col && B[1][i])
			{
				ansCol[i - 1] = '1';
				invCol(i);
			}
			if(i >= col && !B[1][i])
			{
				ansCol[i - 1] = '1';
				invCol(i);
			}
		}
		if(col == M + 1)
		{
			for(int i = 2; i <= N; i++)
				if(B[i][1] < B[i - 1][N])
				{
					ansRow[i - 1] = '1';
					invRow(i);
				}
		}
		else
			for(int i = 2; i <= N; i++)
				if(!B[i][1])
				{
					ansRow[i - 1] = '1';
					invRow(i);
				}
		if(check())
		{
			cout << "YES" << endl;
			cout << ansRow << endl;
			cout << ansCol;
			return ;
		}
	}
	for(int row = 1; row <= N + 1; row++)
	{
		Refresh();
		for(int i = 1; i <= N; i++)
		{
			if(i < row && B[i][1])
			{
				ansRow[i - 1] = '1';
				invRow(i);
			}
			if(i == row)
			{
				bool ok = false;
				for(int j = 1; j <= M; j++)
					if(B[i][j])
					{
						ok = true;
						break ;
					}
				if(ok == false)
				{
					ansRow[i - 1] = '1';
					invRow(i);
				}
			}
			if(i > row && !B[1][i])
			{
				ansRow[i - 1] = '1';
				invRow(i);
			}
		}
		for(int i = 2; i <= M; i++)
			if(!B[1][i])
			{
				ansCol[i - 1] = '1';
				invCol(i);
			}
		if(check())
		{
			cout << "YES" << endl;
			cout << ansRow << endl;
			cout << ansCol;
			return ;
		}
	}
	cout << "NO";
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    // freopen(task".inp", "r", stdin);
    // freopen(task".out", "w", stdout);
    Input();
    Output();
    return 0;
}


#include <bits/stdc++.h>

using namespace std;
#define endl '\n'
#define task "ProA"
#define MASK(i) (1LL << (i))
#define c_bit(i) __builtin_popcountll(i) // đếm số bit đang bật
#define BIT(x, i) ((x) & MASK(i)) // trạng thái của bit thứ i trong x
#define SET_ON(x, i) ((x) | MASK(i)) // bật bit thứ i trong x
#define SET_OFF(x, i) ((x) & ~MASK(i)) //  tắt bit thứ i trong x
const int MAXN = 205;
const int INF = 1e9 + 7;
int N, M;
bool A[MAXN][MAXN];
void Input()
{
	cin >> N >> M;
	for(int i = 1; i <= N; i++)
		for(int j = 1; j <= M; j++)
			cin >> A[i][j];
}
bool B[MAXN][MAXN];
void invCol(const int &x)
{
	for(int i = 1; i <= N; i++)
		B[i][x] ^= 1;
}
void invRow(const int &x)
{
	for(int i = 1; i <= M; i++)
		B[x][i] ^= 1;
}
string ansRow, ansCol;
void Refresh()
{
	ansRow.clear();
	ansCol.clear();
	for(int i = 1; i <= N; i++)
		ansRow += '0';
	for(int i = 1; i <= M; i++)
		ansCol += '0';
	for(int i = 1; i <= N; i++)
		for(int j = 1; j <= M; j++)
			B[i][j] = A[i][j];
}
vector <bool> save;
bool check()
{
	save.clear();
	for(int i = 1; i <= N; i++)
		for(int j = 1; j <= M; j++)
			save.push_back(B[i][j]);
	for(int i = 1; i < (int) save.size(); i++)
		if(save[i] < save[i - 1])
			return false;
	return true;
}
void Output()
{
	Refresh();
	if(check())
	{
		cout << "YES" << endl;
		cout << ansRow << endl;
		cout << ansCol;
		return ;
	}
	for(int h = 0; h <= M; h ++)
    {
    	Refresh();
        for(int i = 1; i <= M; i ++)
	        if(i > h)
	        {
	        	if(!B[1][i])
	        	{
	        		ansCol[i - 1] = '1';
	        		invCol(i);
	        	}
	        }
	        else
	        	if(B[1][i])
	        	{
	        		ansCol[i - 1] = '1';
	        		invCol(i);
	        	}
        for(int i = 2; i <= N; i ++)
	        if(!B[i][1])
	        {
	        	ansRow[i - 1] = '1';
	        	invRow(i);
	        }
        if(check())
        {
            cout << "YES" << endl;
            cout << ansRow << endl;
            cout << ansCol;
            return ;
        }
    }
    for(int h = 0; h <= N; h ++)
    {
    	Refresh();
        for(int i = 1; i <= M; i ++)
	        if(B[1][i])
	        {
	        	ansCol[i - 1] = '1';
	        	invCol(i);
	        }
        for(int i = 2; i <= N; i ++)
	        if(i > h)
	        {
	        	if(!B[i][1])
	        	{
	        		ansRow[i - 1] = '1';
	        		invRow(i);
	        	}
	        }
	        else
	        	if(B[i][1])
	        	{
	        		ansRow[i - 1] = '1';
	        		invRow(i);
	        	}
        if(check())
        {
            cout << "YES" << endl;
            cout << ansRow << endl;
            cout << ansCol;
            return ;
        }
    }
    cout << "NO" << endl;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    // freopen(task".inp", "r", stdin);
    // freopen(task".out", "w", stdout);
    Input();
    Output();
    return 0;
}


#include <bits/stdc++.h>

using namespace std;
#define endl '\n'
#define task "ProA"
#define MASK(i) (1LL << (i))
#define c_bit(i) __builtin_popcountll(i) // đếm số bit đang bật
#define BIT(x, i) ((x) & MASK(i)) // trạng thái của bit thứ i trong x
#define SET_ON(x, i) ((x) | MASK(i)) // bật bit thứ i trong x
#define SET_OFF(x, i) ((x) & ~MASK(i)) //  tắt bit thứ i trong x
const int MAXN = 205;
const int INF = 1e9 + 7;
int N, M;
bool A[MAXN][MAXN];
void Input()
{
	cin >> N >> M;
	for(int i = 1; i <= N; i++)
		for(int j = 1; j <= M; j++)
			cin >> A[i][j];
}
bool B[MAXN][MAXN];
void invCol(const int &x)
{
	for(int i = 1; i <= N; i++)
		B[i][x] ^= 1;
}
void invRow(const int &x)
{
	for(int i = 1; i <= M; i++)
		B[x][i] ^= 1;
}
string ansRow, ansCol;
void Refresh()
{
	ansRow.clear();
	ansCol.clear();
	for(int i = 1; i <= N; i++)
		ansRow += '0';
	for(int i = 1; i <= M; i++)
		ansCol += '0';
	for(int i = 1; i <= N; i++)
		for(int j = 1; j <= M; j++)
			B[i][j] = A[i][j];
}
vector <bool> save;
bool check()
{
	save.clear();
	for(int i = 1; i <= N; i++)
		for(int j = 1; j <= M; j++)
			save.push_back(B[i][j]);
	for(int i = 1; i < (int) save.size(); i++)
		if(save[i] < save[i - 1])
			return false;
	return true;
}
void Output()
{
	Refresh();
	if(check())
	{
		cout << "YES" << endl;
		cout << ansRow << endl;
		cout << ansCol;
		return ;
	}
	for(int col = 0; col <= M + 1; col++)
	{
		Refresh();
		for(int i = 1; i <= M; i++)
		{
			if(i < col && B[1][i])
			{
				ansCol[i - 1] = '1';
				invCol(i);
			}
			if(i >= col && !B[1][i])
			{
				ansCol[i - 1] = '1';
				invCol(i);
			}
		}
		if(col == M + 1)
		{
			for(int i = 2; i <= N; i++)
				if(B[i][1] < B[i - 1][N])
				{
					ansRow[i - 1] = '1';
					invRow(i);
				}
		}
		else
			for(int i = 2; i <= N; i++)
				if(!B[i][1])
				{
					ansRow[i - 1] = '1';
					invRow(i);
				}
		if(check())
		{
			cout << "YES" << endl;
			cout << ansRow << endl;
			cout << ansCol;
			return ;
		}
	}
	for(int row = 0; row <= N; row++)
	{
		Refresh();
		for(int i = 1; i <= M; i++)
			if(B[1][i])
			{
				ansCol[i - 1] = '1';
				invCol(i);
			}
		for(int i = 2; i <= N; i++)
		{
			if(i <= row && B[i][1])
			{
				ansRow[i - 1] = '1';
				invRow(i);
			}
			if(i > row && !B[1][i])
			{
				ansRow[i - 1] = '1';
				invRow(i);
			}
		}

		if(check())
		{
			cout << "YES" << endl;
			cout << ansRow << endl;
			cout << ansCol;
			return ;
		}
	}
	cout << "NO";
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    // freopen(task".inp", "r", stdin);
    // freopen(task".out", "w", stdout);
    Input();
    Output();
    return 0;
}


#include <bits/stdc++.h>

using namespace std;
#define endl '\n'
#define task "ProA"
#define MASK(i) (1LL << (i))
#define c_bit(i) __builtin_popcountll(i) // đếm số bit đang bật
#define BIT(x, i) ((x) & MASK(i)) // trạng thái của bit thứ i trong x
#define SET_ON(x, i) ((x) | MASK(i)) // bật bit thứ i trong x
#define SET_OFF(x, i) ((x) & ~MASK(i)) //  tắt bit thứ i trong x
const int MAXN = 205;
const int INF = 1e9 + 7;
int N, M;
bool A[MAXN][MAXN];
void Input()
{
	cin >> N >> M;
	for(int i = 1; i <= N; i++)
		for(int j = 1; j <= M; j++)
			cin >> A[i][j];
}
int row[MAXN], col[MAXN];
vector <int> save;
bool check()
{
	save.clear();
	for(int i = 1; i <= N; i++)
		for(int j = 1; j <= M; j++)
			save.push_back(A[i][j] ^ row[i] ^ col[j]);
	for(int i = 1; i < (int) save.size(); i++)
		if(save[i] < save[i - 1])
			return false;
	return true;
}
void Output()
{
	for(int i = 0; i <= M; i++)
	{
		for(int j = 1; j <= M; j++)
			col[j] = A[1][j] ^ (j > i);
		for(int j = 2; j <= N; j++)
			row[j] = A[j][1] ^ col[1] ^ 1;
		if(check())
		{
			cout << "YES" << endl;
			for(int j = 1; j <= N; j++)
				cout << row[j];
			cout << endl;
			for(int j = 1; j <= M; j++)
				cout << col[j];
			return ;
		}
	}
	for(int i = 0; i <= N; i++)
	{
		for(int j = 1; j <= M; j++)
			col[j] = A[1][j];
		for(int j = 1; j <= N; j++)
			row[j] = A[j][1] ^ col[1] ^ 1;
		if(check())
		{
			cout << "YES" << endl;
			for(int j = 1; j <= N; j++)
				cout << row[j];
			cout << endl;
			for(int j = 1; j <= M; j++)
				cout << col[j];
			return ;
		}
	}
	cout << "NO";
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    // freopen(task".inp", "r", stdin);
    // freopen(task".out", "w", stdout);
    Input();
    Output();
    return 0;
}


#include <bits/stdc++.h>

using namespace std;
#define endl '\n'
#define task "ProA"
#define MASK(i) (1LL << (i))
#define c_bit(i) __builtin_popcountll(i) // đếm số bit đang bật
#define BIT(x, i) ((x) & MASK(i)) // trạng thái của bit thứ i trong x
#define SET_ON(x, i) ((x) | MASK(i)) // bật bit thứ i trong x
#define SET_OFF(x, i) ((x) & ~MASK(i)) //  tắt bit thứ i trong x
const int MAXN = 205;
const int INF = 1e9 + 7;
int N, M;
bool A[MAXN][MAXN];
void Input()
{
	cin >> N >> M;
	for(int i = 1; i <= N; i++)
		for(int j = 1; j <= M; j++)
			cin >> A[i][j];
}
int row[MAXN], col[MAXN];
vector <int> save;
bool check()
{
	save.clear();
	for(int i = 1; i <= N; i++)
		for(int j = 1; j <= M; j++)
			save.push_back(A[i][j] ^ row[i] ^ col[j]);
	for(int i = 1; i < (int) save.size(); i++)
		if(save[i] < save[i - 1])
			return false;
	return true;
}
void Output()
{
	for(int i = 0; i <= M; i++)
	{
		for(int j = 1; j <= M; j++)
			col[j] = A[1][j] ^ (j > i) ^ row[1];
		for(int j = 2; j <= N; j++)
			row[j] = A[j][1] ^ col[1] ^ 1;
		if(check())
		{
			cout << "YES" << endl;
			for(int j = 1; j <= N; j++)
				cout << row[j];
			cout << endl;
			for(int j = 1; j <= M; j++)
				cout << col[j];
			return ;
		}
	}
	for(int j = 1; j <= M; j++)
			col[j] = A[1][j] ^ row[1];
	for(int i = 0; i <= N; i++)
	{

		for(int j = 2; j <= N; j++)
			row[j] = A[j][1] ^ col[1] ^ (j > i);
		if(check())
		{
			cout << "YES" << endl;
			for(int j = 1; j <= N; j++)
				cout << row[j];
			cout << endl;
			for(int j = 1; j <= M; j++)
				cout << col[j];
			return ;
		}
	}
	cout << "NO";
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    // freopen(task".inp", "r", stdin);
    // freopen(task".out", "w", stdout);
    Input();
    Output();
    return 0;
}


#include <bits/stdc++.h>

using namespace std;
#define endl '\n'
#define task "ProA"
#define MASK(i) (1LL << (i))
#define c_bit(i) __builtin_popcountll(i) // đếm số bit đang bật
#define BIT(x, i) ((x) & MASK(i)) // trạng thái của bit thứ i trong x
#define SET_ON(x, i) ((x) | MASK(i)) // bật bit thứ i trong x
#define SET_OFF(x, i) ((x) & ~MASK(i)) //  tắt bit thứ i trong x
const int MAXN = 205;
const int INF = 1e9 + 7;
int N, M;
bool A[MAXN][MAXN];
void Input()
{
	cin >> N >> M;
	for(int i = 1; i <= N; i++)
		for(int j = 1; j <= M; j++)
			cin >> A[i][j];
}
bool B[MAXN][MAXN];
void invCol(const int &x)
{
	for(int i = 1; i <= N; i++)
		B[i][x] ^= 1;
}
void invRow(const int &x)
{
	for(int i = 1; i <= M; i++)
		B[x][i] ^= 1;
}
string ansRow, ansCol;
void Refresh()
{
	ansRow.clear();
	ansCol.clear();
	for(int i = 1; i <= N; i++)
		ansRow += '0';
	for(int i = 1; i <= M; i++)
		ansCol += '0';
	for(int i = 1; i <= N; i++)
		for(int j = 1; j <= M; j++)
			B[i][j] = A[i][j];
}
vector <bool> save;
bool check()
{
	save.clear();
	for(int i = 1; i <= N; i++)
		for(int j = 1; j <= M; j++)
			save.push_back(B[i][j]);
	for(int i = 1; i < (int) save.size(); i++)
		if(save[i] < save[i - 1])
			return false;
	return true;
}
void Output()
{
	Refresh();
	if(check())
	{
		cout << "YES" << endl;
		cout << ansRow << endl;
		cout << ansCol;
		return ;
	}
	for(int col = 1; col <= M + 1; col++)
	{
		Refresh();
		for(int i = 1; i <= M; i++)
		{
			if(i < col && B[1][i])
			{
				ansCol[i - 1] = '1';
				invCol(i);
			}
			if(i >= col && !B[1][i])
			{
				ansCol[i - 1] = '1';
				invCol(i);
			}
		}
		if(col == M + 1)
		{
			for(int i = 2; i <= N; i++)
				if(B[i][1] < B[i - 1][N])
				{
					ansRow[i - 1] = '1';
					invRow(i);
				}
		}
		else
			for(int i = 2; i <= N; i++)
				if(!B[i][1])
				{
					ansRow[i - 1] = '1';
					invRow(i);
				}
		if(check())
		{
			cout << "YES" << endl;
			cout << ansRow << endl;
			cout << ansCol;
			return ;
		}
	}
	for(int row = 1; row <= N + 1; row++)
	{
		Refresh();
		for(int i = 1; i <= N; i++)
		{
			if(i < row && B[i][1])
			{
				ansRow[i - 1] = '1';
				invRow(i);
			}
			if(i == row)
			{
				bool ok = false;
				for(int j = 1; j <= M; j++)
					if(B[i][j])
					{
						ok = true;
						break ;
					}
				if(ok == false)
				{
					ansRow[i - 1] = '1';
					invRow(i);
				}
			}
			if(i > row && !B[i][1])
			{
				ansRow[i - 1] = '1';
				invRow(i);
			}
		}
		for(int i = 2; i <= M; i++)
			if(B[1][i])
			{
				ansCol[i - 1] = '1';
				invCol(i);
			}
		if(check())
		{
			cout << "YES" << endl;
			cout << ansRow << endl;
			cout << ansCol;
			return ;
		}
	}
	Refresh();
	for(int i = 1; i <= N; i++)
		if(B[i][1])
		{
			ansRow[i - 1] = '1';
			invRow(1);
		}
	for(int i = 1; i <= M; i++)
		if(B[1][i])
		{
			ansCol[i - 1] = '1';
			invCol(i);
		}
	if(check())
	{
		cout << "YES" << endl;
		cout << ansRow << endl;
		cout << ansCol;
		return ;
	}
	Refresh();
	for(int i = 1; i <= N; i++)
		if(!B[i][1])
		{
			ansRow[i - 1] = '1';
			invRow(1);
		}
	for(int i = 1; i <= M; i++)
		if(!B[1][i])
		{
			ansCol[i - 1] = '1';
			invCol(i);
		}
	if(check())
	{
		cout << "YES" << endl;
		cout << ansRow << endl;
		cout << ansCol;
		return ;
	}
	cout << "NO";
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    // freopen(task".inp", "r", stdin);
    // freopen(task".out", "w", stdout);
    Input();
    Output();
    return 0;
}


#include <bits/stdc++.h>

using namespace std;
#define endl '\n'
#define task "ProA"
#define MASK(i) (1LL << (i))
#define c_bit(i) __builtin_popcountll(i) // đếm số bit đang bật
#define BIT(x, i) ((x) & MASK(i)) // trạng thái của bit thứ i trong x
#define SET_ON(x, i) ((x) | MASK(i)) // bật bit thứ i trong x
#define SET_OFF(x, i) ((x) & ~MASK(i)) //  tắt bit thứ i trong x
const int MAXN = 205;
const int INF = 1e9 + 7;
int N, M;
bool A[MAXN][MAXN];
void Input()
{
	cin >> N >> M;
	for(int i = 1; i <= N; i++)
		for(int j = 1; j <= M; j++)
			cin >> A[i][j];
}
bool B[MAXN][MAXN];
void invCol(const int &x)
{
	for(int i = 1; i <= N; i++)
		B[i][x] ^= 1;
}
void invRow(const int &x)
{
	for(int i = 1; i <= M; i++)
		B[x][i] ^= 1;
}
string ansRow, ansCol;
void Refresh()
{
	ansRow.clear();
	ansCol.clear();
	for(int i = 1; i <= N; i++)
		ansRow += '0';
	for(int i = 1; i <= M; i++)
		ansCol += '0';
	for(int i = 1; i <= N; i++)
		for(int j = 1; j <= M; j++)
			B[i][j] = A[i][j];
}
vector <bool> save;
bool check()
{
	save.clear();
	for(int i = 1; i <= N; i++)
		for(int j = 1; j <= M; j++)
			save.push_back(B[i][j]);
	for(int i = 1; i < (int) save.size(); i++)
		if(save[i] < save[i - 1])
			return false;
	return true;
}
void Output()
{
	Refresh();
	if(check())
	{
		cout << "YES" << endl;
		cout << ansRow << endl;
		cout << ansCol;
		return ;
	}
	for(int col = 1; col <= M + 1; col++)
	{
		Refresh();
		for(int i = 1; i <= M; i++)
		{
			if(i < col && B[1][i])
			{
				ansCol[i - 1] = '1';
				invCol(i);
			}
			if(i >= col && !B[1][i])
			{
				ansCol[i - 1] = '1';
				invCol(i);
			}
		}
		if(col == M + 1)
		{
			for(int i = 2; i <= N; i++)
				if(B[i][1] < B[i - 1][N])
				{
					ansRow[i - 1] = '1';
					invRow(i);
				}
		}
		else
			for(int i = 2; i <= N; i++)
				if(!B[i][1])
				{
					ansRow[i - 1] = '1';
					invRow(i);
				}
		if(check())
		{
			cout << "YES" << endl;
			cout << ansRow << endl;
			cout << ansCol;
			return ;
		}
	}
	for(int row = 1; row <= N + 1; row++)
	{
		Refresh();
		for(int i = 1; i <= N; i++)
		{
			if(i < row && B[i][1])
			{
				ansRow[i - 1] = '1';
				invRow(i);
			}
			if(i >= row && !B[1][i])
			{
				ansRow[i - 1] = '1';
				invRow(i);
			}
		}
		for(int i = 2; i <= M; i++)
			if(!B[1][i])
			{
				ansCol[i - 1] = '1';
				invCol(i);
			}
		if(check())
		{
			cout << "YES" << endl;
			cout << ansRow << endl;
			cout << ansCol;
			return ;
		}
	}
	Refresh();
	for(int i = 1; i <= N; i++)
		if(B[i][1])
		{
			ansRow[i - 1] = '1';
			invRow(i);
		}
	for(int i = 1; i <= M; i++)
		if(B[1][i])
		{
			ansCol[i - 1] = '1';
			invCol(i);
		}
	if(check())
	{
		cout << "YES" << endl;
		cout << ansRow << endl;
		cout << ansCol;
		return ;
	}
	cout << "NO";
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    // freopen(task".inp", "r", stdin);
    // freopen(task".out", "w", stdout);
    Input();
    Output();
    return 0;
}


#include <bits/stdc++.h>

using namespace std;
#define endl '\n'
#define task "ProA"
#define MASK(i) (1LL << (i))
#define c_bit(i) __builtin_popcountll(i) // đếm số bit đang bật
#define BIT(x, i) ((x) & MASK(i)) // trạng thái của bit thứ i trong x
#define SET_ON(x, i) ((x) | MASK(i)) // bật bit thứ i trong x
#define SET_OFF(x, i) ((x) & ~MASK(i)) //  tắt bit thứ i trong x
const int MAXN = 205;
const int INF = 1e9 + 7;
int N, M;
bool A[MAXN][MAXN];
void Input()
{
	cin >> N >> M;
	for(int i = 1; i <= N; i++)
		for(int j = 1; j <= M; j++)
			cin >> A[i][j];
}
bool B[MAXN][MAXN];
void invCol(const int &x)
{
	for(int i = 1; i <= N; i++)
		B[i][x] ^= 1;
}
void invRow(const int &x)
{
	for(int i = 1; i <= M; i++)
		B[x][i] ^= 1;
}
string ansRow, ansCol;
void Refresh()
{
	ansRow.clear();
	ansCol.clear();
	for(int i = 1; i <= N; i++)
		ansRow += '0';
	for(int i = 1; i <= M; i++)
		ansCol += '0';
	for(int i = 1; i <= N; i++)
		for(int j = 1; j <= M; j++)
			B[i][j] = A[i][j];
}
vector <bool> save;
bool check()
{
	save.clear();
	for(int i = 1; i <= N; i++)
		for(int j = 1; j <= M; j++)
			save.push_back(B[i][j]);
	for(int i = 1; i < (int) save.size(); i++)
		if(save[i] < save[i - 1])
			return false;
	return true;
}
void Output()
{
	Refresh();
	if(check())
	{
		cout << "YES" << endl;
		cout << ansRow << endl;
		cout << ansCol;
		return ;
	}
	for(int col = 0; col <= M; col++)
	{
		Refresh();
		for(int i = 1; i <= M; i++)
		{
			if(i <= col && B[1][i])
			{
				ansCol[i - 1] = '1';
				invCol(i);
			}
			if(i > col && !B[1][i])
			{
				ansCol[i - 1] = '1';
				invCol(i);
			}
		}
		for(int i = 2; i <= N; i++)
			if(!B[i][1])
			{
				ansRow[i - 1] = '1';
				invRow(i);
			}
		if(check())
		{
			cout << "YES" << endl;
			cout << ansRow << endl;
			cout << ansCol;
			return ;
		}
	}
	for(int row = 0; row <= N; row++)
	{
		Refresh();
		for(int i = 2; i <= N; i++)
		{
			if(i <= row && B[i][1])
			{
				ansRow[i - 1] = '1';
				invRow(i);
			}
			if(i > row && !B[i][1])
			{
				ansRow[i - 1] = '1';
				invRow(i);
			}
		}
		for(int i = 1; i <= M; i++)
			if(B[1][i])
			{
				ansCol[i - 1] = '1';
				invCol(i);
			}
		if(check())
		{
			cout << "YES" << endl;
			cout << ansRow << endl;
			cout << ansCol;
			return ;
		}
	}
	cout << "NO";
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    // freopen(task".inp", "r", stdin);
    // freopen(task".out", "w", stdout);
    Input();
    Output();
    return 0;
}


#include <bits/stdc++.h>

using namespace std;
#define endl '\n'
#define task "ProA"
#define MASK(i) (1LL << (i))
#define c_bit(i) __builtin_popcountll(i) // đếm số bit đang bật
#define BIT(x, i) ((x) & MASK(i)) // trạng thái của bit thứ i trong x
#define SET_ON(x, i) ((x) | MASK(i)) // bật bit thứ i trong x
#define SET_OFF(x, i) ((x) & ~MASK(i)) //  tắt bit thứ i trong x
const int MAXN = 205;
const int INF = 1e9 + 7;
int N, M;
bool A[MAXN][MAXN];
void Input()
{
	cin >> N >> M;
	for(int i = 1; i <= N; i++)
		for(int j = 1; j <= M; j++)
			cin >> A[i][j];
}
bool B[MAXN][MAXN];
void invCol(const int &x)
{
	for(int i = 1; i <= N; i++)
		B[i][x] ^= 1;
}
void invRow(const int &x)
{
	for(int i = 1; i <= M; i++)
		B[x][i] ^= 1;
}
string ansRow, ansCol;
void Refresh()
{
	ansRow.clear();
	ansCol.clear();
	for(int i = 1; i <= N; i++)
		ansRow += '0';
	for(int i = 1; i <= M; i++)
		ansCol += '0';
	for(int i = 1; i <= N; i++)
		for(int j = 1; j <= M; j++)
			B[i][j] = A[i][j];
}
vector <bool> save;
bool check()
{
	save.clear();
	for(int i = 1; i <= N; i++)
		for(int j = 1; j <= M; j++)
			save.push_back(B[i][j]);
	for(int i = 1; i < (int) save.size(); i++)
		if(save[i] < save[i - 1])
			return false;
	return true;
}
void Output()
{
	Refresh();
	if(check())
	{
		cout << "YES" << endl;
		cout << ansRow << endl;
		cout << ansCol;
		return ;
	}
	for(int col = 0; col <= M; col++)
	{
		Refresh();
		for(int i = 1; i <= M; i++)
		{
			if(i <= col && B[1][i])
			{
				ansCol[i - 1] = '1';
				invCol(i);
			}
			if(i > col && !B[1][i])
			{
				ansCol[i - 1] = '1';
				invCol(i);
			}
		}
		for(int i = 2; i <= N; i++)
			if(!B[i][1])
			{
				ansRow[i - 1] = '1';
				invRow(i);
			}
		if(check())
		{
			cout << "YES" << endl;
			cout << ansRow << endl;
			cout << ansCol;
			return ;
		}
	}
	for(int row = 0; row <= N; row++)
	{
		Refresh();
		for(int i = 1; i <= M; i++)
			if(B[1][i])
			{
				ansCol[i - 1] = '1';
				invCol(i);
			}
		for(int i = 2; i <= N; i++)
		{
			if(i <= row && B[i][1])
			{
				ansRow[i - 1] = '1';
				invRow(i);
			}
			if(i > row && !B[1][i])
			{
				ansRow[i - 1] = '1';
				invRow(i);
			}
		}
		if(check())
		{
			cout << "YES" << endl;
			cout << ansRow << endl;
			cout << ansCol;
			return ;
		}
	}
	cout << "NO";
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    // freopen(task".inp", "r", stdin);
    // freopen(task".out", "w", stdout);
    Input();
    Output();
    return 0;
}


#include <bits/stdc++.h>

using namespace std;
#define endl '\n'
#define task "ProA"
#define MASK(i) (1LL << (i))
#define c_bit(i) __builtin_popcountll(i) // đếm số bit đang bật
#define BIT(x, i) ((x) & MASK(i)) // trạng thái của bit thứ i trong x
#define SET_ON(x, i) ((x) | MASK(i)) // bật bit thứ i trong x
#define SET_OFF(x, i) ((x) & ~MASK(i)) //  tắt bit thứ i trong x
const int MAXN = 205;
const int INF = 1e9 + 7;
int N, M;
bool A[MAXN][MAXN];
void Input()
{
	cin >> N >> M;
	for(int i = 1; i <= N; i++)
		for(int j = 1; j <= M; j++)
			cin >> A[i][j];
}
bool B[MAXN][MAXN];
void invCol(const int &x)
{
	for(int i = 1; i <= N; i++)
		B[i][x] ^= 1;
}
void invRow(const int &x)
{
	for(int i = 1; i <= M; i++)
		B[x][i] ^= 1;
}
string ansRow, ansCol;
void Refresh()
{
	ansRow.clear();
	ansCol.clear();
	for(int i = 1; i <= N; i++)
		ansRow += '0';
	for(int i = 1; i <= M; i++)
		ansCol += '0';
	for(int i = 1; i <= N; i++)
		for(int j = 1; j <= M; j++)
			B[i][j] = A[i][j];
}
vector <bool> save;
bool check()
{
	save.clear();
	for(int i = 1; i <= N; i++)
		for(int j = 1; j <= M; j++)
			save.push_back(B[i][j]);
	for(int i = 1; i < (int) save.size(); i++)
		if(save[i] < save[i - 1])
			return false;
	return true;
}
void Output()
{
	Refresh();
	if(check())
	{
		cout << "YES" << endl;
		cout << ansRow << endl;
		cout << ansCol;
		return ;
	}
	for(int col = 1; col <= M + 1; col++)
	{
		Refresh();
		for(int i = 1; i <= M; i++)
		{
			if(i < col && B[1][i])
			{
				ansCol[i - 1] = '1';
				invCol(i);
			}
			if(i >= col && !B[1][i])
			{
				ansCol[i - 1] = '1';
				invCol(i);
			}
		}
		if(col == M + 1)
		{
			for(int i = 2; i <= N; i++)
				if(B[i][1] < B[i - 1][N])
				{
					ansRow[i - 1] = '1';
					invRow(i);
				}
		}
		else
			for(int i = 2; i <= N; i++)
				if(!B[i][1])
				{
					ansRow[i - 1] = '1';
					invRow(i);
				}
		if(check())
		{
			cout << "YES" << endl;
			cout << ansRow << endl;
			cout << ansCol;
			return ;
		}
	}
	for(int row = 1; row <= N + 1; row++)
	{
		Refresh();
		for(int i = 1; i <= N; i++)
		{
			if(i < row && B[i][1])
			{
				ansRow[i - 1] = '1';
				invRow(i);
			}
			if(i == row)
			{
				bool ok = false;
				for(int j = 1; j <= M; j++)
					if(B[i][j])
					{
						ok = true;
						break ;
					}
				if(ok == false)
				{
					ansRow[i - 1] = '1';
					invRow(i);
				}
			}
			if(i > row && !B[1][i])
			{
				ansRow[i - 1] = '1';
				invRow(i);
			}
		}
		for(int i = 2; i <= M; i++)
			if(!B[1][i])
			{
				ansCol[i - 1] = '1';
				invCol(i);
			}
		if(check())
		{
			cout << "YES" << endl;
			cout << ansRow << endl;
			cout << ansCol;
			return ;
		}
	}
	Refresh();
	for(int i = 1; i <= N; i++)
		if(B[i][1])
		{
			ansRow[i - 1] = '1';
			invRow(1);
		}
	for(int i = 1; i <= M; i++)
		if(B[1][i])
		{
			ansCol[i - 1] = '1';
			invCol(i);
		}
	if(check())
	{
		cout << "YES" << endl;
		cout << ansRow << endl;
		cout << ansCol;
		return ;
	}
	Refresh();
	for(int i = 1; i <= N; i++)
		if(!B[i][1])
		{
			ansRow[i - 1] = '1';
			invRow(1);
		}
	for(int i = 1; i <= M; i++)
		if(!B[1][i])
		{
			ansCol[i - 1] = '1';
			invCol(i);
		}
	if(check())
	{
		cout << "YES" << endl;
		cout << ansRow << endl;
		cout << ansCol;
		return ;
	}
	cout << "NO";
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    // freopen(task".inp", "r", stdin);
    // freopen(task".out", "w", stdout);
    Input();
    Output();
    return 0;
}


#include <bits/stdc++.h>

using namespace std;
#define endl '\n'
#define task "ProA"
#define MASK(i) (1LL << (i))
#define c_bit(i) __builtin_popcountll(i) // đếm số bit đang bật
#define BIT(x, i) ((x) & MASK(i)) // trạng thái của bit thứ i trong x
#define SET_ON(x, i) ((x) | MASK(i)) // bật bit thứ i trong x
#define SET_OFF(x, i) ((x) & ~MASK(i)) //  tắt bit thứ i trong x
const int MAXN = 205;
const int INF = 1e9 + 7;
int N, M;
bool A[MAXN][MAXN];
void Input()
{
	cin >> N >> M;
	for(int i = 1; i <= N; i++)
		for(int j = 1; j <= M; j++)
			cin >> A[i][j];
}
bool B[MAXN][MAXN];
void invCol(const int &x)
{
	for(int i = 1; i <= N; i++)
		B[i][x] ^= 1;
}
void invRow(const int &x)
{
	for(int i = 1; i <= M; i++)
		B[x][i] ^= 1;
}
string ansRow, ansCol;
void Refresh()
{
	ansRow.clear();
	ansCol.clear();
	for(int i = 1; i <= N; i++)
		ansRow += '0';
	for(int i = 1; i <= M; i++)
		ansCol += '0';
	for(int i = 1; i <= N; i++)
		for(int j = 1; j <= M; j++)
			B[i][j] = A[i][j];
}
vector <bool> save;
bool check()
{
	save.clear();
	for(int i = 1; i <= N; i++)
		for(int j = 1; j <= M; j++)
			save.push_back(B[i][j]);
	for(int i = 1; i < (int) save.size(); i++)
		if(save[i] < save[i - 1])
			return false;
	return true;
}
void Output()
{
	Refresh();
	if(check())
	{
		cout << "YES" << endl;
		cout << ansRow << endl;
		cout << ansCol;
		return ;
	}
	for(int col = 0; col <= M; col++)
	{
		Refresh();
		for(int i = 1; i <= M; i++)
		{
			if(i < col && B[1][i])
			{
				ansCol[i - 1] = '1';
				invCol(i);
			}
			if(i >= col && !B[1][i])
			{
				ansCol[i - 1] = '1';
				invCol(i);
			}
		}
		for(int i = 2; i <= N; i++)
			if(!B[i][1])
			{
				ansRow[i - 1] = '1';
				invRow(i);
			}
		if(check())
		{
			cout << "YES" << endl;
			cout << ansRow << endl;
			cout << ansCol;
			return ;
		}
	}
	for(int row = 0; row <= N; row++)
	{
		Refresh();
		for(int i = 2; i <= N; i++)
		{
			if(i < row && B[i][1])
			{
				ansRow[i - 1] = '1';
				invRow(i);
			}
			if(i >= row && !B[i][1])
			{
				ansRow[i - 1] = '1';
				invRow(i);
			}
		}
		for(int i = 2; i <= M; i++)
			if(B[1][i])
			{
				ansCol[i - 1] = '1';
				invCol(i);
			}
		if(check())
		{
			cout << "YES" << endl;
			cout << ansRow << endl;
			cout << ansCol;
			return ;
		}
	}
	cout << "NO";
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    // freopen(task".inp", "r", stdin);
    // freopen(task".out", "w", stdout);
    Input();
    Output();
    return 0;
}


#include <bits/stdc++.h>

using namespace std;
#define endl '\n'
#define task "ProA"
#define MASK(i) (1LL << (i))
#define c_bit(i) __builtin_popcountll(i) // đếm số bit đang bật
#define BIT(x, i) ((x) & MASK(i)) // trạng thái của bit thứ i trong x
#define SET_ON(x, i) ((x) | MASK(i)) // bật bit thứ i trong x
#define SET_OFF(x, i) ((x) & ~MASK(i)) //  tắt bit thứ i trong x
const int MAXN = 205;
const int INF = 1e9 + 7;
int N, M;
bool A[MAXN][MAXN];
void Input()
{
	cin >> N >> M;
	for(int i = 1; i <= N; i++)
		for(int j = 1; j <= M; j++)
			cin >> A[i][j];
}
int row[MAXN], col[MAXN];
vector <int> save;
bool check()
{
	save.clear();
	for(int i = 1; i <= N; i++)
		for(int j = 1; j <= M; j++)
			save.push_back(A[i][j] ^ row[i] ^ col[j]);
	for(int i = 1; i < (int) save.size(); i++)
		if(save[i] < save[i - 1])
			return false;
	return true;
}
void Output()
{
	for(int i = 0; i <= M; i++)
	{
		for(int j = 1; j <= M; j++)
			col[j] = A[1][j] ^ (j > i);
		for(int j = 2; j <= N; j++)
			row[j] = A[j][1] ^ col[1] ^ 1;
		if(check())
		{
			cout << "YES" << endl;
			for(int j = 1; j <= N; j++)
				cout << row[j];
			cout << endl;
			for(int j = 1; j <= M; j++)
				cout << col[j];
			return ;
		}
	}
	for(int i = 0; i <= N; i++)
	{
		for(int j = 1; j <= M; j++)
			col[j] = A[1][j];
		for(int j = 2; j <= N; j++)
			row[j] = A[j][1] ^ col[1] ^ 1;
		if(check())
		{
			cout << "YES" << endl;
			for(int j = 1; j <= N; j++)
				cout << row[j];
			cout << endl;
			for(int j = 1; j <= M; j++)
				cout << col[j];
			return ;
		}
	}
	cout << "NO";
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    // freopen(task".inp", "r", stdin);
    // freopen(task".out", "w", stdout);
    Input();
    Output();
    return 0;
}


#include <bits/stdc++.h>

using namespace std;
#define endl '\n'
#define task "ProA"
#define MASK(i) (1LL << (i))
#define c_bit(i) __builtin_popcountll(i) // đếm số bit đang bật
#define BIT(x, i) ((x) & MASK(i)) // trạng thái của bit thứ i trong x
#define SET_ON(x, i) ((x) | MASK(i)) // bật bit thứ i trong x
#define SET_OFF(x, i) ((x) & ~MASK(i)) //  tắt bit thứ i trong x
const int MAXN = 205;
const int INF = 1e9 + 7;
int N, M;
bool A[MAXN][MAXN];
void Input()
{
	cin >> N >> M;
	for(int i = 1; i <= N; i++)
		for(int j = 1; j <= M; j++)
			cin >> A[i][j];
}
int row[MAXN], col[MAXN];
vector <int> save;
bool check()
{
	save.clear();
	for(int i = 1; i <= N; i++)
		for(int j = 1; j <= M; j++)
			save.push_back(A[i][j] ^ row[i] ^ col[j]);
	for(int i = 1; i < (int) save.size(); i++)
		if(save[i] < save[i - 1])
			return false;
	return true;
}
void Output()
{
	for(int i = 0; i <= M; i++)
	{
		for(int j = 1; j <= M; j++)
			col[j] = A[1][j] ^ (j > i) ^ row[1];
		for(int j = 2; j <= N; j++)
			row[j] = A[j][1] ^ col[1] ^ 1;
		if(check())
		{
			cout << "YES" << endl;
			for(int j = 1; j <= N; j++)
				cout << row[j];
			cout << endl;
			for(int j = 1; j <= M; j++)
				cout << col[j];
			return ;
		}
	}
	for(int i = 0; i <= N; i++)
	{
		for(int j = 1; j <= M; j++)
			col[j] = A[1][j] ^ row[1];
		for(int j = 2; j <= N; j++)
			row[j] = A[j][1] ^ col[1] ^ (j > i);
		if(check())
		{
			cout << "YES" << endl;
			for(int j = 1; j <= N; j++)
				cout << row[j];
			cout << endl;
			for(int j = 1; j <= M; j++)
				cout << col[j];
			return ;
		}
	}
	cout << "NO";
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    // freopen(task".inp", "r", stdin);
    // freopen(task".out", "w", stdout);
    Input();
    Output();
    return 0;
}


#include <bits/stdc++.h>

using namespace std;
#define endl '\n'
#define task "ProA"
#define MASK(i) (1LL << (i))
#define c_bit(i) __builtin_popcountll(i) // đếm số bit đang bật
#define BIT(x, i) ((x) & MASK(i)) // trạng thái của bit thứ i trong x
#define SET_ON(x, i) ((x) | MASK(i)) // bật bit thứ i trong x
#define SET_OFF(x, i) ((x) & ~MASK(i)) //  tắt bit thứ i trong x
const int MAXN = 205;
const int INF = 1e9 + 7;
int N, M;
bool A[MAXN][MAXN];
void Input()
{
	cin >> N >> M;
	for(int i = 1; i <= N; i++)
		for(int j = 1; j <= M; j++)
			cin >> A[i][j];
}
bool B[MAXN][MAXN];
void invCol(const int &x)
{
	for(int i = 1; i <= N; i++)
		B[i][x] ^= 1;
}
void invRow(const int &x)
{
	for(int i = 1; i <= M; i++)
		B[x][i] ^= 1;
}
string ansRow, ansCol;
void Refresh()
{
	ansRow.clear();
	ansCol.clear();
	for(int i = 1; i <= N; i++)
		ansRow += '0';
	for(int i = 1; i <= M; i++)
		ansCol += '0';
	for(int i = 1; i <= N; i++)
		for(int j = 1; j <= M; j++)
			B[i][j] = A[i][j];
}
vector <bool> save;
bool check()
{
	save.clear();
	for(int i = 1; i <= N; i++)
		for(int j = 1; j <= M; j++)
			save.push_back(B[i][j]);
	for(int i = 1; i < (int) save.size(); i++)
		if(save[i] < save[i - 1])
			return false;
	return true;
}
void Output()
{
	Refresh();
	if(check())
	{
		cout << "YES" << endl;
		cout << ansRow << endl;
		cout << ansCol;
		return ;
	}
	for(int col = 1; col <= M + 1; col++)
	{
		Refresh();
		for(int i = 1; i <= M; i++)
		{
			if(i < col && B[1][i])
			{
				ansCol[i - 1] = '1';
				invCol(i);
			}
			if(i >= col && !B[1][i])
			{
				ansCol[i - 1] = '1';
				invCol(i);
			}
		}
		if(col == M + 1)
		{
			for(int i = 2; i <= N; i++)
				if(B[i][1] < B[i - 1][N])
				{
					ansRow[i - 1] = '1';
					invRow(i);
				}
		}
		else
			for(int i = 2; i <= N; i++)
				if(!B[i][1])
				{
					ansRow[i - 1] = '1';
					invRow(i);
				}
		if(check())
		{
			cout << "YES" << endl;
			cout << ansRow << endl;
			cout << ansCol;
			return ;
		}
	}
	for(int row = 1; row <= N; row++)
	{
		Refresh();
		for(int i = 1; i <= N; i++)
		{
			if(i < row && B[i][1])
			{
				ansRow[i - 1] = '1';
				invRow(i);
			}
			if(i >= row && !B[1][i])
			{
				ansRow[i - 1] = '1';
				invRow(i);
			}
		}
		for(int i = 2; i <= M; i++)
			if(B[1][i])
			{
				ansCol[i - 1] = '1';
				invCol(i);
			}
		if(check())
		{
			cout << "YES" << endl;
			cout << ansRow << endl;
			cout << ansCol;
			return ;
		}
	}
	cout << "NO";
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    // freopen(task".inp", "r", stdin);
    // freopen(task".out", "w", stdout);
    Input();
    Output();
    return 0;
}


#include <bits/stdc++.h>
using namespace std;

#define mp make_pair
#define pb push_back

#define int int64_t
#define ld long double

const int MOD = 1e9+7;
const int N = 1e6+5;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

// template <int MOD=MOD>
struct Modular {
  int value;
  static const int MOD_value = MOD;

  Modular(long long v = 0) { value = v % MOD; if (value < 0) value += MOD;}
  Modular(long long a, long long b) : value(0){ *this += a; *this /= b;}

  Modular& operator+=(Modular const& b) {value += b.value; if (value >= MOD) value -= MOD; return *this;}
  Modular& operator-=(Modular const& b) {value -= b.value; if (value < 0) value += MOD;return *this;}
  Modular& operator*=(Modular const& b) {value = (long long)value * b.value % MOD;return *this;}

  friend Modular mexp(Modular a, long long e) {
    Modular res = 1; while (e) { if (e&1) res *= a; a *= a; e >>= 1; }
    return res;
  }
  friend Modular inverse(Modular a) { return mexp(a, MOD - 2); }

  Modular& operator/=(Modular const& b) { return *this *= inverse(b); }
  friend Modular operator+(Modular a, Modular const b) { return a += b; }
  friend Modular operator-(Modular a, Modular const b) { return a -= b; }
  friend Modular operator-(Modular const a) { return 0 - a; }
  friend Modular operator*(Modular a, Modular const b) { return a *= b; }
  friend Modular operator/(Modular a, Modular const b) { return a /= b; }
  friend std::ostream& operator<<(std::ostream& os, Modular const& a) {return os << a.value;}
  friend bool operator==(Modular const& a, Modular const& b) {return a.value == b.value;}
  friend bool operator!=(Modular const& a, Modular const& b) {return a.value != b.value;}
};

Modular mpow(Modular x, int y) {
    if(y==0) {
        return Modular(1);
    }
    Modular temp = mpow(x, y/2);
    temp*=temp;
    if(y&1) {
        temp*=x;
    }
    return temp;
}
    Modular fact[N];
    Modular ifact[N];

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n;
    cin>>n;
    int arr[n];
    for(int i=0;i<n;i++) {
        cin>>arr[i];
    }
    sort(arr,arr+n);
    int maxe = arr[n-1];
    fact[0]=Modular(1);
    ifact[0]=Modular(1);
    for(int i=1;i<N;i++) {
        fact[i]=i*fact[i-1];
        ifact[i]=mpow(fact[i], MOD-2);
    }
    Modular ans = 0;
    int p = 0;
    int less[n];
    less[0]=0;
    for(int i=1;i<n;i++) {
        if(arr[i]==arr[i-1]) {
            less[i]=less[i-1];
        }
        else {
            less[i]=i;
        }
    }
    for(int i=0;i<n-1;i++) {
        if(arr[i]==arr[n-1])
            continue;
        ans+=fact[n]*arr[i]*mpow(Modular(n-less[i]), MOD-2);
    }
    cout<<ans<<"\n";

    return 0;
}


#include <bits/stdc++.h>
using namespace std;

#define mp make_pair
#define pb push_back

#define int int64_t
#define ld long double

const int MOD = 1e9+7;
const int N = 1e6+5;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

// template <int MOD=MOD>
struct Modular {
  int value;
  static const int MOD_value = MOD;

  Modular(long long v = 0) { value = v % MOD; if (value < 0) value += MOD;}
  Modular(long long a, long long b) : value(0){ *this += a; *this /= b;}

  Modular& operator+=(Modular const& b) {value += b.value; if (value >= MOD) value -= MOD; return *this;}
  Modular& operator-=(Modular const& b) {value -= b.value; if (value < 0) value += MOD;return *this;}
  Modular& operator*=(Modular const& b) {value = (long long)value * b.value % MOD;return *this;}

  friend Modular mexp(Modular a, long long e) {
    Modular res = 1; while (e) { if (e&1) res *= a; a *= a; e >>= 1; }
    return res;
  }
  friend Modular inverse(Modular a) { return mexp(a, MOD - 2); }

  Modular& operator/=(Modular const& b) { return *this *= inverse(b); }
  friend Modular operator+(Modular a, Modular const b) { return a += b; }
  friend Modular operator-(Modular a, Modular const b) { return a -= b; }
  friend Modular operator-(Modular const a) { return 0 - a; }
  friend Modular operator*(Modular a, Modular const b) { return a *= b; }
  friend Modular operator/(Modular a, Modular const b) { return a /= b; }
  friend std::ostream& operator<<(std::ostream& os, Modular const& a) {return os << a.value;}
  friend bool operator==(Modular const& a, Modular const& b) {return a.value == b.value;}
  friend bool operator!=(Modular const& a, Modular const& b) {return a.value != b.value;}
};

Modular mpow(Modular x, int y) {
    if(y==0) {
        return Modular(1);
    }
    Modular temp = mpow(x, y/2);
    temp*=temp;
    if(y&1) {
        temp*=x;
    }
    return temp;
}
    Modular fact[N];
    Modular ifact[N];

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n;
    cin>>n;
    int arr[n];
    for(int i=0;i<n;i++) {
        cin>>arr[i];
    }
    sort(arr,arr+n);
    int maxe = arr[n-1];
    fact[0]=Modular(1);
    ifact[0]=Modular(1);
    for(int i=1;i<100;i++) {
        fact[i]=i*fact[i-1];
        ifact[i]=mpow(fact[i], MOD-2);
    }
    Modular ans = 0;
    int p = 0;
    int less[n];
    less[0]=0;
    for(int i=1;i<n;i++) {
        if(arr[i]==arr[i-1]) {
            less[i]=less[i-1];
        }
        else {
            less[i]=i;
        }
    }
    for(int i=0;i<n-1;i++) {
        ans+=fact[n]*arr[i]*mpow(Modular(n-less[i]), MOD-2);
    }
    cout<<ans<<"\n";

    return 0;
}


#include <bits/stdc++.h>
using namespace std;

#define mp make_pair
#define pb push_back

#define int int64_t
#define ld long double

const int MOD = 1e9+7;
const int N = 1e6+5;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

// template <int MOD=MOD>
struct Modular {
  int value;
  static const int MOD_value = MOD;

  Modular(long long v = 0) { value = v % MOD; if (value < 0) value += MOD;}
  Modular(long long a, long long b) : value(0){ *this += a; *this /= b;}

  Modular& operator+=(Modular const& b) {value += b.value; if (value >= MOD) value -= MOD; return *this;}
  Modular& operator-=(Modular const& b) {value -= b.value; if (value < 0) value += MOD;return *this;}
  Modular& operator*=(Modular const& b) {value = (long long)value * b.value % MOD;return *this;}

  friend Modular mexp(Modular a, long long e) {
    Modular res = 1; while (e) { if (e&1) res *= a; a *= a; e >>= 1; }
    return res;
  }
  friend Modular inverse(Modular a) { return mexp(a, MOD - 2); }

  Modular& operator/=(Modular const& b) { return *this *= inverse(b); }
  friend Modular operator+(Modular a, Modular const b) { return a += b; }
  friend Modular operator-(Modular a, Modular const b) { return a -= b; }
  friend Modular operator-(Modular const a) { return 0 - a; }
  friend Modular operator*(Modular a, Modular const b) { return a *= b; }
  friend Modular operator/(Modular a, Modular const b) { return a /= b; }
  friend std::ostream& operator<<(std::ostream& os, Modular const& a) {return os << a.value;}
  friend bool operator==(Modular const& a, Modular const& b) {return a.value == b.value;}
  friend bool operator!=(Modular const& a, Modular const& b) {return a.value != b.value;}
};

Modular fact[N];
Modular ifact[N];

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n;
    cin>>n;
    int arr[n];
    for(int i=0;i<n;i++) {
        cin>>arr[i];
    }
    sort(arr,arr+n);
    int maxe = arr[n-1];
    fact[0]=Modular(1);
    ifact[n]=Modular(n);
    ifact[n+1]=Modular(1);
    for(int i=1;i<N;i++) {
        fact[i]=i*fact[i-1];
        if(n-i>=0)
        ifact[n-i]=ifact[n-i+1]*(n-i);
    }
    Modular ans = 0;
    int p = 0;
    int less[n];
    less[0]=0;
    for(int i=1;i<n;i++) {
        if(arr[i]==arr[i-1]) {
            less[i]=less[i-1];
        }
        else {
            less[i]=i;
        }
    }
    for(int i=0;i<n-1;i++) {
        if(arr[i]==arr[n-1])
            continue;
        ans+=fact[n-less[i]-1]*arr[i]*ifact[n-less[i]+1];
    }
    cout<<ans<<"\n";

    return 0;
}