#include <bits/stdc++.h>
#define mod 998244353
#define eps 1e-9
#define inf (ll)1e18

using namespace std;

typedef long long ll;
typedef long double ld;

ll n, m, M[205][205], ok, r[205], c[205];

void solve()
{
    for (int k=1; k<=m+1; k++) // coloana pe care incepe sa fie 1
    {
        int no=0;
        memset(c, 0, sizeof(c));
        memset(r, 0, sizeof(r));
        for (int j=1; j<=m; j++)
        {
            if (j<k)
            {
                if (M[1][j]==0) continue;
                c[j]=1;
            } else
            {
                if (M[1][j]==1) continue;
                c[j]=1;
            }
        }
        if (k==0)
            ok=0;
        else
            ok=1;
        for (int i=2; i<=n; i++)
        {
            int x = 0, ok1 = 1, ok2 = 1;
            for (int j = 1; j <= m; j++) {
                if ((M[i][j] + c[j] + x) % 2 == 0 && ok == 0) continue;
                if ((M[i][j] + c[j] + x) % 2 == 1 && ok == 1) continue;
                ok1 = 0;
            }
            x = 1;
            for (int j = 1; j <= m; j++) {
                if ((M[i][j] + c[j] + x) % 2 == 0 && ok == 0) continue;
                if ((M[i][j] + c[j] + x) % 2 == 1 && ok == 1) continue;
                ok2 = 0;
            }
            if (ok1)
                continue;
            if (ok2) {
                r[i] = 1;
                continue;
            }

            no = 1;
            break;
        }
        if (no==0)
        {
            cout<<"YES\n";
            for (int i=1; i<=n; i++)
                cout<<r[i];
            cout<<endl;
            for (int j=1; j<=m; j++)
                cout<<c[j];
            exit(0);
        }
    }
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin>>n>>m;
    for (int i=1; i<=n; i++)
        for (int j=1; j<=m; j++)
            cin>>M[i][j];

    solve();
    for (int j=1; j<=m; j++)
        M[1][j] = M[1][j]^1;
    solve();
    cout<<"NO";

    return 0;
}


#include <bits/stdc++.h>
#define mod 998244353
#define eps 1e-9
#define inf (ll)1e18

using namespace std;

typedef long long ll;
typedef long double ld;

ll n, m, M[205][205], ok, r[205], c[205];

void solve()
{
    for (int k=1; k<=m+1; k++) // coloana pe care incepe sa fie 1
    {
        int no=0;
        memset(c, 0, sizeof(c));
        memset(r, 0, sizeof(r));
        for (int j=1; j<=m; j++)
        {
            if (j<k)
            {
                if (M[1][j]==0) continue;
                c[j]=1;
            } else
            {
                if (M[1][j]==1) continue;
                c[j]=1;
            }
        }
        if (k==m+1)
            ok=0;
        else
            ok=1;
        for (int i=2; i<=n; i++)
        {
            int x = 0, ok1 = 1, ok2 = 1;
            for (int j = 1; j <= m; j++) {
                if ((M[i][j] + c[j] + x) % 2 == 0 && ok == 0) continue;
                if ((M[i][j] + c[j] + x) % 2 == 1 && ok == 1) continue;
                ok1 = 0;
            }
            x = 1;
            for (int j = 1; j <= m; j++) {
                if ((M[i][j] + c[j] + x) % 2 == 0 && ok == 0) continue;
                if ((M[i][j] + c[j] + x) % 2 == 1 && ok == 1) continue;
                ok2 = 0;
            }
            if (ok1)
                continue;
            if (ok2) {
                r[i] = 1;
                continue;
            }

            no = 1;
            break;
        }
        if (no==0)
        {
            cout<<"YES\n";
            for (int i=1; i<=n; i++)
                cout<<r[i];
            cout<<endl;
            for (int j=1; j<=m; j++)
                cout<<c[j];
            exit(0);
        }
    }
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin>>n>>m;
    for (int i=1; i<=n; i++)
        for (int j=1; j<=m; j++)
            cin>>M[i][j];

    solve();
    for (int j=1; j<=m; j++)
        M[1][j] = M[1][j]^1;
    solve();
    cout<<"NO";

    return 0;
}


#include <bits/stdc++.h>
#define mod 998244353
#define eps 1e-9
#define inf (ll)1e18

using namespace std;

typedef long long ll;
typedef long double ld;

ll n, m, M[205][205], ok, r[205], c[205];

void solve()
{
    for (int k=0; k<=m; k++) // coloana pe care incepe sa fie 1
    {
        int no=0;
        memset(c, 0, sizeof(c));
        memset(r, 0, sizeof(r));
        for (int j=1; j<=m; j++)
        {
            if (j<k)
            {
                if (M[1][j]==0) continue;
                c[j]=1;
            } else
            {
                if (M[1][j]==1) continue;
                c[j]=1;
            }
        }
        if (k==0)
            ok=0;
        else
            ok=1;
        for (int i=2; i<=n; i++)
        {
            int x = 0, ok1 = 1, ok2 = 1;
            for (int j = 1; j <= m; j++) {
                if ((M[i][j] + c[j] + x) % 2 == 0 && ok == 0) continue;
                if ((M[i][j] + c[j] + x) % 2 == 1 && ok == 1) continue;
                ok1 = 0;
            }
            x = 1;
            for (int j = 1; j <= m; j++) {
                if ((M[i][j] + c[j] + x) % 2 == 0 && ok == 0) continue;
                if ((M[i][j] + c[j] + x) % 2 == 1 && ok == 1) continue;
                ok2 = 0;
            }
            if (ok1) continue;
            if (ok2) {
                r[i] = 1;
                continue;
            }
            no = 1;
            break;
        }
        if (no==0)
        {
            cout<<"YES\n";
            for (int i=1; i<=n; i++)
                cout<<r[i];
            cout<<endl;
            for (int j=1; j<=m; j++)
                cout<<c[j];
            exit(0);
        }
    }
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin>>n>>m;
    for (int i=1; i<=n; i++)
        for (int j=1; j<=m; j++)
            cin>>M[i][j];

    solve();
    for (int j=1; j<=m; j++)
        M[1][j] = M[1][j]^1;
    solve();
    cout<<"NO";

    return 0;
}


#include<bits/stdc++.h>

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()
#define foru(i, n) for(int i = 1; i <= n; i++)
#define foru0(i, n) for(int i = 0; i < n; i++)
#define ford(i, n) for(int i = n; i >= 1; i--)
#define ford0(i, n) for(int i = n - 1; i >= 0; i--)
#define fors(i, a, b) for(int i = a; i <= b; i++)

using namespace std;

typedef long long ll;
typedef double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pii> vii;
typedef vector<pll> v2l;
typedef pair<char, int> pci;
typedef vector<pci> vci;

const int N = 1e6 + 1;
const int NN = 1e3 + 1;
const ll MOD = 1e9 + 7;
const ll oo = 1e18 + 7;

void checkfirst(vector<vi> a, int n, int m)
{
    vector<vi> b = a;
    string row(n, '0');
    string col(m, '0');
    foru(i, m)
        if(b[1][i])
        {
            foru(j, n) b[j][i] = 1 - b[j][i];
            col[i-1] = '1';
        }
    vector<vi> pre(n + 1, vi(m + 1));
    int cur = 1;
    ford(i, n)
        ford(j, m)
        {
            pre[i][j] = cur;
            cur = b[i][j];
        }
    int check = false;
    ford(i, n)
        if(check)
        {
            if(b[i][1])
            {
                foru(j, m) b[i][j] = 1 - b[i][j];
                row[i-1] = '1';
            }
        } else
            {
                fors(j, 1, m - 1)
                    if(b[i][j] != pre[i][j]) check = true;
                if(!b[i][1] && !check)
                {
                    foru(j, m) b[i][j] = 1 - b[i][j];
                    row[i-1] = '1';
                }
                if(b[i][1] && check)
                {
                    foru(j, m) b[i][j] = 1 - b[i][j];
                    row[i-1] = '1';
                }
            }
//    foru(i, n)
//    {
//        foru(j, m) cout << b[i][j] << " ";
//        cout << endl;
//    }
    cur = 0;
    foru(i, n)
        foru(j, m)
            if(b[i][j] < cur) return;
                else cur = b[i][j];
    cout << "YES" << endl;
    cout << row << endl << col;
    exit(0);
}

void checklast(vector<vi> a, int n, int m)
{
    vector<vi> b = a;
    string row(n, '0');
    string col(m, '0');
    foru(i, m)
        if(!b[n][i])
        {
            foru(j, n) b[j][i] = 1 - b[j][i];
            col[i-1] = '1';
        }
    vector<vi> pre(n + 1, vi(m + 1));
    int cur = 0;
    foru(i, n)
        foru(j, m)
        {
            pre[i][j] = cur;
            cur = b[i][j];
        }
    int check = false;
    foru(i, n)
        if(check)
        {
            if(!b[i][1])
            {
                foru(j, m) b[i][j] = 1 - b[i][j];
                row[i-1] = '1';
            }
        } else
            {
                fors(j, 2, m)
                    if(b[i][j] != pre[i][j]) check = true;
                if(b[i][1] && !check)
                {
                    foru(j, m) b[i][j] = 1 - b[i][j];
                    row[i-1] = '1';
                }
                if(b[i][1] && check)
                {
                    foru(j, m) b[i][j] = 1 - b[i][j];
                    row[i-1] = '1';
                }
            }
//    foru(i, n)
//    {
//        foru(j, m) cout << b[i][j] << " ";
//        cout << endl;
//    }
    cur = 0;
    foru(i, n)
        foru(j, m)
            if(b[i][j] < cur) return;
                else cur = b[i][j];
    cout << "YES" << endl;
    cout << row << endl << col;
    exit(0);
}

void solve()
{
    int n, m;
    cin >> n >> m;
    vector<vi> a(n + 1, vi(m + 1));
    foru(i, n)
        foru(j, m) cin >> a[i][j];
    checkfirst(a, n, m);
    checklast(a, n, m);
    cout << "NO";
}

int main()
{
    //freopen("solve.inp", "r", stdin);
    //freopen("solve.out", "w", stdout);
    ios_base::sync_with_stdio(0);
    cin.tie(nullptr);
    cout.tie(nullptr);
    cout.precision(10);
    solve();
}


#include<bits/stdc++.h>

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()
#define foru(i, n) for(int i = 1; i <= n; i++)
#define foru0(i, n) for(int i = 0; i < n; i++)
#define ford(i, n) for(int i = n; i >= 1; i--)
#define ford0(i, n) for(int i = n - 1; i >= 0; i--)
#define fors(i, a, b) for(int i = a; i <= b; i++)

using namespace std;

typedef long long ll;
typedef double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pii> vii;
typedef vector<pll> v2l;
typedef pair<char, int> pci;
typedef vector<pci> vci;

const int N = 1e6 + 1;
const int NN = 1e3 + 1;
const ll MOD = 1e9 + 7;
const ll oo = 1e18 + 7;

void checkfirst(vector<vi> a, int n, int m)
{
    vector<vi> b = a;
    string row(n, '0');
    string col(m, '0');
    foru(i, m)
        if(b[1][i])
        {
            foru(j, n) b[j][i] = 1 - b[j][i];
            col[i-1] = '1';
        }
    int check = false;
    ford(i, n)
        if(check)
        {
            if(!b[i][1])
            {
                foru(j, m) b[i][j] = 1 - b[i][j];
                row[i-1] = '1';
            }
        } else
            {
                foru(j, m)
                    if(!b[i][j]) check = true;
                if(b[i][1] && check)
                {
                    foru(j, m) b[i][j] = 1 - b[i][j];
                    row[i-1] = '1';
                }
            }
    int cur = 0;
    foru(i, n)
        foru(j, m)
            if(b[i][j] < cur) return;
                else cur = b[i][j];
    cout << "YES" << endl;
    cout << row << endl << col;
    exit(0);
}

void checklast(vector<vi> a, int n, int m)
{
    vector<vi> b = a;
    string row(n, '0');
    string col(m, '0');
    foru(i, m)
        if(!b[n][i])
        {
            foru(j, n) b[j][i] = 1 - b[j][i];
            col[i-1] = '1';
        }
    int check = false;
    foru(i, n)
        if(check)
        {
            if(!b[i][1])
            {
                foru(j, m) b[i][j] = 1 - b[i][j];
                row[i-1] = '1';
            }
        } else
            {
                foru(j, m) if(b[i][j]) check = true;
                if(b[i][1] && check)
                {
                    foru(j, m) b[i][j] = 1 - b[i][j];
                    row[i-1] = '1';
                }
            }
//    foru(i, n)
//    {
//        foru(j, m) cout << b[i][j] << " ";
//        cout << endl;
//    }
    int cur = 0;
    foru(i, n)
        foru(j, m)
            if(b[i][j] < cur) return;
                else cur = b[i][j];
    cout << "YES" << endl;
    cout << row << endl << col;
    exit(0);
}

void solve()
{
    int n, m;
    cin >> n >> m;
    vector<vi> a(n + 1, vi(m + 1));
    foru(i, n)
        foru(j, m) cin >> a[i][j];
    checkfirst(a, n, m);
    checklast(a, n, m);
    cout << "NO";
}

int main()
{
    //freopen("solve.inp", "r", stdin);
    //freopen("solve.out", "w", stdout);
    ios_base::sync_with_stdio(0);
    cin.tie(nullptr);
    cout.tie(nullptr);
    cout.precision(10);
    solve();
}


#include<bits/stdc++.h>

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()
#define foru(i, n) for(int i = 1; i <= n; i++)
#define foru0(i, n) for(int i = 0; i < n; i++)
#define ford(i, n) for(int i = n; i >= 1; i--)
#define ford0(i, n) for(int i = n - 1; i >= 0; i--)
#define fors(i, a, b) for(int i = a; i <= b; i++)

using namespace std;

typedef long long ll;
typedef double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pii> vii;
typedef vector<pll> v2l;
typedef pair<char, int> pci;
typedef vector<pci> vci;

const int N = 1e6 + 1;
const int NN = 1e3 + 1;
const ll MOD = 1e9 + 7;
const ll oo = 1e18 + 7;

void checkfirst(vector<vi> a, int n, int m)
{
    vector<vi> b = a;
    string row(n, '0');
    string col(m, '0');
    foru(i, m)
        if(b[1][i])
        {
            foru(j, n) b[j][i] = 1 - b[j][i];
            col[i-1] = '1';
        }
    int check = false;
    ford(i, n)
        if(check)
        {
            if(!b[i][1])
            {
                foru(j, m) b[i][j] = 1 - b[i][j];
                row[i-1] = '1';
            }
        } else
            {
                foru(j, m)
                    if(!b[i][j]) check = true;
                if(b[i][1] && check)
                {
                    foru(j, m) b[i][j] = 1 - b[i][j];
                    row[i-1] = '1';
                }
            }
    int cur = 0;
    foru(i, n)
        foru(j, m)
            if(b[i][j] < cur) return;
                else cur = b[i][j];
    cout << "YES" << endl;
    cout << row << endl << col;
    cout << endl << 1;
    exit(0);
}

void checklast(vector<vi> a, int n, int m)
{
    vector<vi> b = a;
    string row(n, '0');
    string col(m, '0');
    foru(i, m)
        if(!b[n][i])
        {
            foru(j, n) b[j][i] = 1 - b[j][i];
            col[i-1] = '1';
        }
    int check = false;
    foru(i, n)
        if(check)
        {
            if(!b[i][1])
            {
                foru(j, m) b[i][j] = 1 - b[i][j];
                row[i-1] = '1';
            }
        } else
            {
                foru(j, m) if(b[i][j]) check = true;
                if(b[i][1] && check)
                {
                    foru(j, m) b[i][j] = 1 - b[i][j];
                    row[i-1] = '1';
                }
            }
//    foru(i, n)
//    {
//        foru(j, m) cout << b[i][j] << " ";
//        cout << endl;
//    }
    int cur = 0;
    foru(i, n)
        foru(j, m)
            if(b[i][j] < cur) return;
                else cur = b[i][j];
    cout << "YES" << endl;
    cout << row << endl << col;
    cout << endl << 2;
    exit(0);
}

void solve()
{
    int n, m;
    cin >> n >> m;
    vector<vi> a(n + 1, vi(m + 1));
    foru(i, n)
        foru(j, m) cin >> a[i][j];
    checkfirst(a, n, m);
    checklast(a, n, m);
    cout << "NO";
}

int main()
{
    //freopen("solve.inp", "r", stdin);
    //freopen("solve.out", "w", stdout);
    ios_base::sync_with_stdio(0);
    cin.tie(nullptr);
    cout.tie(nullptr);
    cout.precision(10);
    solve();
}


#include<bits/stdc++.h>

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()
#define foru(i, n) for(int i = 1; i <= n; i++)
#define foru0(i, n) for(int i = 0; i < n; i++)
#define ford(i, n) for(int i = n; i >= 1; i--)
#define ford0(i, n) for(int i = n - 1; i >= 0; i--)
#define fors(i, a, b) for(int i = a; i <= b; i++)

using namespace std;

typedef long long ll;
typedef double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pii> vii;
typedef vector<pll> v2l;
typedef pair<char, int> pci;
typedef vector<pci> vci;

const int N = 1e6 + 1;
const int NN = 1e3 + 1;
const ll MOD = 1e9 + 7;
const ll oo = 1e18 + 7;

void checkfirst(vector<vi> a, int n, int m)
{
    vector<vi> b = a;
    string row(n, '0');
    string col(m, '0');
    foru(i, m)
        if(b[1][i])
        {
            foru(j, n) b[j][i] = 1 - b[j][i];
            col[i-1] = '1';
        }
    int check = false;
    ford(i, n)
        if(check)
        {
            if(b[i][1])
            {
                foru(j, m) b[i][j] = 1 - b[i][j];
                row[i-1] = '1';
            }
        } else
            {
                foru(j, m)
                    if(!b[i][j]) check = true;
                if(b[i][1] && check)
                {
                    foru(j, m) b[i][j] = 1 - b[i][j];
                    row[i-1] = '1';
                }
            }
//    foru(i, n)
//    {
//        foru(j, m) cout << b[i][j] << " ";
//        cout << endl;
//    }
    int cur = 0;
    foru(i, n)
        foru(j, m)
            if(b[i][j] < cur) return;
                else cur = b[i][j];
    cout << "YES" << endl;
    cout << row << endl << col;
    exit(0);
}

void checklast(vector<vi> a, int n, int m)
{
    vector<vi> b = a;
    string row(n, '0');
    string col(m, '0');
    foru(i, m)
        if(!b[n][i])
        {
            foru(j, n) b[j][i] = 1 - b[j][i];
            col[i-1] = '1';
        }
    int check = false;
    foru(i, n)
        if(check)
        {
            if(!b[i][1])
            {
                foru(j, m) b[i][j] = 1 - b[i][j];
                row[i-1] = '1';
            }
        } else
            {
                foru(j, m) if(b[i][j]) check = true;
                if(b[i][1] && check)
                {
                    foru(j, m) b[i][j] = 1 - b[i][j];
                    row[i-1] = '1';
                }
            }
//    foru(i, n)
//    {
//        foru(j, m) cout << b[i][j] << " ";
//        cout << endl;
//    }
    int cur = 0;
    foru(i, n)
        foru(j, m)
            if(b[i][j] < cur) return;
                else cur = b[i][j];
    cout << "YES" << endl;
    cout << row << endl << col;
    exit(0);
}

void solve()
{
    int n, m;
    cin >> n >> m;
    vector<vi> a(n + 1, vi(m + 1));
    foru(i, n)
        foru(j, m) cin >> a[i][j];
    checkfirst(a, n, m);
    checklast(a, n, m);
    cout << "NO";
}

int main()
{
    //freopen("solve.inp", "r", stdin);
    //freopen("solve.out", "w", stdout);
    ios_base::sync_with_stdio(0);
    cin.tie(nullptr);
    cout.tie(nullptr);
    cout.precision(10);
    solve();
}


# include <iostream>
# include <cmath>
# include <algorithm>
# include <stdio.h>
# include <cstdint>
# include <cstring>
# include <string>
# include <cstdlib>
# include <vector>
# include <bitset>
# include <map>
# include <queue>
# include <ctime>
# include <stack>
# include <set>
# include <list>
# include <random>
# include <deque>
# include <functional>
# include <iomanip>
# include <sstream>
# include <fstream>
# include <complex>
# include <numeric>
# include <immintrin.h>
# include <cassert>
# include <array>
# include <tuple>
# include <unordered_set>
# include <unordered_map>
using namespace std;

int n, m;
int a[205][205];
int b[205][205];
int c[205][205];
bool used1[205], used2[205];

void solve(int tp) {
    for (int i = 1; i <= n; ++i) {
        for (int j = 1; j <= m; ++j) {
            b[i][j] = a[i][j];
            if (tp == 1 && i == 1) b[i][j] = 1 - b[i][j];
        }
    }
    for (int l = 0; l <= m; ++l) {
        for (int i = 1; i <= n; ++i)
            used1[i] = false;
        for (int i = 1; i <= m; ++i)
            used2[i] = false;
        for (int i = 1; i <= m; ++i)
            if (i <= l && b[1][i] == 1) used2[i] = true;
            else if (i > l && b[1][i] == 0) used2[i] = true;
        bool cc = false;
        if (l < m) cc = true;
        for (int i = 1; i <= n; ++i) {
            for (int j = 1; j <= m; ++j) {
                c[i][j] = b[i][j];
                if (used2[j]) c[i][j] = 1 - c[i][j];
            }
            if (i == 1) continue;
            if (cc && c[i][1] == 0) {
                for (int j = 1; j <= m; ++j)
                    c[i][j] = 1 - c[i][j];
                used1[i] = true;
                continue;
            }
            for (int j = 2; j <= m; ++j)
                if (c[i][j] < c[i][j - 1]) {
                    used1[i] = true;
                    for (int k = 1; k <= m; ++k)
                        c[i][k] = 1 - c[i][k];
                    break;
                }
            for (int j = 1; j <= m; ++j)
                if (c[i][j] == 1) cc = true;
        }
        if (tp == 1) used1[1] = true;
        bool t = false;
        for (int i = 1; i <= n; ++i) {
            for (int j = 1; j <= m; ++j) {
                if (j > 1 && c[i][j] < c[i][j - 1]) t = true;
                if (i > 1 && j == 1 && c[i][j] < c[i - 1][m]) {
                    t = true;
                }
            }
        }
        if (t == false) {
            cout << "YES\n";
            for (int i = 1; i <= n; ++i)
                if (used1[i]) cout << "1"; else cout << "0";
            cout << '\n';
            for (int i = 1; i <= m; ++i)
                if (used2[i]) cout << "1"; else cout << "0";
            cout << '\n';
            exit(0);
        }
    }
}

int main(int argc, const char * argv[]) {
#ifdef __APPLE__
    freopen("/Users/danya.smelskiy/Documents/Danya/Resources/input.txt","r",stdin);
#endif
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    cin >> n >> m;
    for (int i = 1; i <= n; ++i) {
        for (int j = 1; j <= m; ++j) {
            cin >> a[i][j];
        }
    }
    for (int i = 0; i < 2; ++i)
        solve(i);
    cout << "NO\n";
    return 0;
}


# include <iostream>
# include <cmath>
# include <algorithm>
# include <stdio.h>
# include <cstdint>
# include <cstring>
# include <string>
# include <cstdlib>
# include <vector>
# include <bitset>
# include <map>
# include <queue>
# include <ctime>
# include <stack>
# include <set>
# include <list>
# include <random>
# include <deque>
# include <functional>
# include <iomanip>
# include <sstream>
# include <fstream>
# include <complex>
# include <numeric>
# include <immintrin.h>
# include <cassert>
# include <array>
# include <tuple>
# include <unordered_set>
# include <unordered_map>
using namespace std;

int n, m;
int a[205][205];
int b[205][205];
int c[205][205];
bool used1[205], used2[205];

void solve(int tp) {
    for (int i = 1; i <= n; ++i) {
        for (int j = 1; j <= m; ++j) {
            b[i][j] = a[i][j];
            if (tp == 1 && i == 1) b[i][j] = 1 - b[i][j];
        }
    }
    for (int l = 0; l <= m; ++l) {
        for (int i = 1; i <= n; ++i)
            used1[i] = false;
        for (int i = 1; i <= m; ++i)
            used2[i] = false;
        for (int i = 1; i <= m; ++i)
            if (i <= l && b[1][i] == 1) used2[i] = true;
            else if (i > l && b[1][i] == 0) used2[i] = true;
        bool cc = false;
        for (int i = 1; i <= n; ++i) {
            for (int j = 1; j <= m; ++j) {
                c[i][j] = b[i][j];
                if (used2[j]) c[i][j] = 1 - c[i][j];
            }
            if (i == 1) {
                for (int j = 1; j <= m; ++j)
                    if (c[i][j]) cc = true;
                continue;
            }
            if (cc && c[i][1] == 0) {
                for (int j = 1; j <= m; ++j)
                    c[i][j] = 1 - c[i][j];
                used1[i] = true;
                continue;
            }
            for (int j = 2; j <= m; ++j)
                if (c[i][j] < c[i][j - 1]) {
                    used1[i] = true;
                    for (int k = 1; k <= m; ++k)
                        c[i][k] = 1 - c[i][k];
                    break;
                }
            for (int j = 1; j <= m; ++j)
                if (c[i][j] == 1) cc = true;
        }
        if (tp == 1) used1[1] = true;
        bool t = false;
        for (int i = 1; i <= n; ++i) {
            for (int j = 1; j <= m; ++j) {
                if (j > 1 && c[i][j] < c[i][j - 1]) t = true;
                if (i > 1 && j == 1 && c[i][j] < c[i - 1][m]) {
                    t = true;
                }
            }
        }
        if (t == false) {
            cout << "YES\n";
            for (int i = 1; i <= n; ++i)
                if (used1[i]) cout << "1"; else cout << "0";
            cout << '\n';
            for (int i = 1; i <= m; ++i)
                if (used2[i]) cout << "1"; else cout << "0";
            cout << '\n';
            for (int i = 1; i <= n; ++i) if (used1[i]) {
                for (int j = 1; j <= m; ++j)
                    a[i][j] = 1 - a[i][j];
            }
            for (int j = 1; j <= m; ++j) if (used2[j]) {
                for (int i = 1; i <= n; ++i)
                    a[i][j] = 1 - a[i][j];
            }
            for (int i = 1; i <= n; ++i) {
                for (int j = 1; j <= m; ++j) {
                    if (j > 1 && a[i][j] < a[i][j - 1]) assert(false);
                    if (i > 1 && a[i][j] < a[i - 1][m]) assert(false);
                }
            }
            exit(0);
        }
    }
}

int main(int argc, const char * argv[]) {
#ifdef __APPLE__
    freopen("/Users/danya.smelskiy/Documents/Danya/Resources/input.txt","r",stdin);
#endif
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    cin >> n >> m;
    for (int i = 1; i <= n; ++i) {
        for (int j = 1; j <= m; ++j) {
            cin >> a[i][j];
        }
    }
    for (int i = 0; i < 2; ++i)
        solve(i);
    cout << "NO\n";
    return 0;
}


# include <iostream>
# include <cmath>
# include <algorithm>
# include <stdio.h>
# include <cstdint>
# include <cstring>
# include <string>
# include <cstdlib>
# include <vector>
# include <bitset>
# include <map>
# include <queue>
# include <ctime>
# include <stack>
# include <set>
# include <list>
# include <random>
# include <deque>
# include <functional>
# include <iomanip>
# include <sstream>
# include <fstream>
# include <complex>
# include <numeric>
# include <immintrin.h>
# include <cassert>
# include <array>
# include <tuple>
# include <unordered_set>
# include <unordered_map>
using namespace std;

int n, m;
int a[205][205];
int b[205][205];
int c[205][205];
bool used1[205], used2[205];

void solve(int tp) {
    for (int i = 1; i <= n; ++i) {
        for (int j = 1; j <= m; ++j) {
            b[i][j] = a[i][j];
            if (tp == 1 && i == 1) b[i][j] = 1 - b[i][j];
        }
    }
    for (int l = 0; l <= m; ++l) {
        for (int i = 1; i <= n; ++i)
            used1[i] = false;
        for (int i = 1; i <= m; ++i)
            used2[i] = false;
        for (int i = 1; i <= m; ++i)
            if (i <= l && b[1][i] == 1) used2[i] = true;
            else if (i > l && b[1][i] == 0) used2[i] = true;
        for (int i = 1; i <= n; ++i) {
            for (int j = 1; j <= m; ++j) {
                c[i][j] = b[i][j];
                if (used2[j]) c[i][j] = 1 - c[i][j];
            }
        }
        vector<int> v;
        for (int i = 1; i <= n; ++i) {
            int c1 = 0, c2 = 0;
            for (int j = 1; j <= m; ++j) {
                if (c[i][j]) ++c1;
                else ++c2;
            }
            if (c1 && c2) v.push_back(i);
        }
        if ((int)v.size() > 1) continue;
        if ((int)v.size() == 0) {
            for (int i = 2; i <= n; ++i) {
                if (c[i][1] != c[1][1]) used1[i] = true;
            }
            cout << "YES\n";
            for (int i = 1; i <= n; ++i)
                if (used1[i]) cout << "1";
                else cout << "0";
            cout << '\n';
            for (int i = 1; i <= m; ++i)
                if (used2[i]) cout << "1";
                else cout << "0";
            cout << '\n';
            exit(0);
        }
        bool t1 = false;
        int pos = v[0];
        for (int j = 2; j <= m; ++j)
            if (c[pos][j] < c[pos][j - 1]) t1 = true;
        if (t1) {
            if (pos == 1) continue;
            for (int j = 1; j <= m; ++j)
                c[pos][j] = 1 - c[pos][j];
            used1[pos] = true;
        }
        if (tp == 1) used1[1] = true;

        for (int i = 2; i < pos; ++i) if (c[i][1]) {
            for (int j = 1; j <= m; ++j)
                c[i][j] = 1 - c[i][j];
            used1[i] = true;
        }
        for (int i = pos + 1; i <= n; ++i) if (!c[i][1]) {
            for (int j = 1; j <= m; ++j)
                c[i][j] = 1 - c[i][j];
            used1[i] = true;
        }

        t1 = false;
        for (int i = 1; i <= n; ++i) {
            for (int j = 1; j <= m; ++j) {
                if (j > 1 && c[i][j] < c[i][j - 1]) t1 = true;
                if (i > 1 && j == 1 && c[i][j] < c[i - 1][m]) t1 = true;
            }
        }
        if (t1) continue;
        cout << "YES\n";
        for (int i = 1; i <= n; ++i)
            if (used1[i]) cout << "1";
            else cout << "0";
        cout << '\n';
        for (int i = 1; i <= m; ++i)
            if (used2[i]) cout << "1";
            else cout << "0";
        cout << '\n';
        exit(0);
    }
    return;
}

int main(int argc, const char * argv[]) {
#ifdef __APPLE__
    freopen("/Users/danya.smelskiy/Documents/Danya/Resources/input.txt","r",stdin);
#endif
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    cin >> n >> m;
    for (int i = 1; i <= n; ++i) {
        for (int j = 1; j <= m; ++j) {
            cin >> a[i][j];
        }
    }
    for (int i = 0; i < 2; ++i)
        solve(i);
    cout << "NO\n";
    return 0;
}


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

int N, M;
int arr[MAX][MAX];
int invCol[MAX];
int invRow[MAX];

int isPossible()
{
	int lastLoc = -1;
	for (int i = 0; i < N; i++)
	{
		int loc = -1;
		for (int j = 0; j < M; j++)
		{
			if (j && arr[i][j] != arr[i][j - 1])
			{
				if (loc >= 0) return 0;
				loc = i;
				invRow[i] = !arr[i][j];
			}
		}
		if (i && loc >= 0 && lastLoc < loc) return 0;
		if (loc == -1)
		{
			if (lastLoc == M)
			{
				loc = M;
				invRow[i] = arr[i][0];
			}
			else
			{
				loc = 0;
				invRow[i] = !arr[i][0];
			}
		}
		lastLoc = loc;
	}
	lastLoc = -1;
	for (int i = 0; i < M; i++)
	{
		int loc = -1;
		for (int j = 0; j < N; j++)
		{
			if (j && (arr[j][i] ^ invRow[j]) != (arr[j - 1][i] ^ invRow[j - 1]))
			{
				if (loc >= 0) return 0;
				loc = j;
			}
		}
		if (i && loc >= 0 && lastLoc < loc) return 0;
		if (loc == -1)
		{
			if (lastLoc == N) loc = N;
			else loc = 0;
		}
		lastLoc = loc;
	}
	return 1;
}

void print()
{
	cout << "YES\n";
	for (int i = 0; i < N; i++) cout << invRow[i];
	cout << "\n";
	for (int i = 0; i < M; i++) cout << invCol[i];
	cout << "\n";
}

int main(void)
{
	cin >> N >> M;
	for (int i = 0; i < N; i++)
	{
		for (int j = 0; j < M; j++) cin >> arr[i][j];
	}
	for (int j = 0; j < M; j++) invCol[j] = arr[0][j];
	for (int i = 0; i < N; i++)
	{
		for (int j = 0; j < M; j++) arr[i][j] ^= invCol[j];
	}
	if (isPossible())
	{
		print();
		return 0;
	}
	for (int i = M - 1; i >= 0; i--)
	{
		invCol[i] = 1 - invCol[i];
		for (int j = 0; j < N; j++) arr[j][i] = 1 - arr[j][i];
		if (isPossible())
		{
			print();
			return 0;
		}
	}
	cout << "NO\n";
	return 0;
}


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

int N, M;
int arr[MAX][MAX];
int invCol[MAX];
int invRow[MAX];

int isPossible()
{
	int appeared = 0;
	for (int i = 0; i < N; i++)
	{
		for (int j = 0; j < M; j++)
		{
			if (arr[i][j] ^ invRow[i])
			{
				if (j) appeared = 1;
				else invRow[i] ^= 1;
			}
			else if (appeared) return 0;
		}
	}
	return 1;
}

void print()
{
	cout << "YES\n";
	for (int i = 0; i < N; i++) cout << invRow[i];
	cout << "\n";
	for (int i = 0; i < M; i++) cout << invCol[i];
	cout << "\n";
}

int main(void)
{
	cin >> N >> M;
	for (int i = 0; i < N; i++)
	{
		for (int j = 0; j < M; j++) cin >> arr[i][j];
	}
	for (int j = 0; j < M; j++) invCol[j] = arr[0][j];
	for (int i = 0; i < N; i++)
	{
		for (int j = 0; j < M; j++) arr[i][j] ^= invCol[j];
	}
	if (isPossible())
	{
		print();
		return 0;
	}
	for (int j = 0; j < M; j++)
	{
		if (arr[N - 1][j])
		{
			invCol[j] ^= 1;
			for (int i = 0; i < N; i++) arr[i][j] ^= 1;
		}
	}
	if (isPossible())
	{
		print();
		return 0;
	}
	cout << "NO\n";
	return 0;
}


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

int N, M;
int arr[MAX][MAX];
int invCol[MAX];
int invRow[MAX];

int isPossible()
{
	int lastLoc = M;
	for (int i = 0; i < N; i++)
	{
		int loc = -1;
		for (int j = 0; j < M; j++)
		{
			if (j && arr[i][j] != arr[i][j - 1])
			{
				if (loc >= 0) return 0;
				loc = i;
				invRow[i] = !arr[i][j];
			}
		}
		if (lastLoc < loc) return 0;
		if (loc == -1)
		{
			if (lastLoc == M)
			{
				loc = M;
				invRow[i] = arr[i][0];
			}
			else
			{
				loc = 0;
				invRow[i] = !arr[i][0];
			}
		}
		lastLoc = loc;
	}
	lastLoc = N;
	for (int i = 0; i < M; i++)
	{
		int loc = -1;
		for (int j = 0; j < N; j++)
		{
			if (j && (arr[j][i] ^ invRow[j]) != (arr[j - 1][i] ^ invRow[j - 1]))
			{
				if (loc >= 0) return 0;
				loc = j;
			}
		}
		if (lastLoc < loc) return 0;
		if (loc == -1)
		{
			if (lastLoc == N) loc = N;
			else loc = 0;
		}
		lastLoc = loc;
	}
	return 1;
}

void print()
{
	cout << "YES\n";
	for (int i = 0; i < N; i++) cout << invRow[i];
	cout << "\n";
	for (int i = 0; i < M; i++) cout << invCol[i];
	cout << "\n";
}

int main(void)
{
	cin >> N >> M;
	for (int i = 0; i < N; i++)
	{
		for (int j = 0; j < M; j++) cin >> arr[i][j];
	}
	for (int j = 0; j < M; j++) invCol[j] = arr[0][j];
	for (int i = 0; i < N; i++)
	{
		for (int j = 0; j < M; j++) arr[i][j] ^= invCol[j];
	}
	if (isPossible())
	{
		print();
		return 0;
	}
	for (int i = M - 1; i >= 0; i--)
	{
		invCol[i] = 1 - invCol[i];
		for (int j = 0; j < N; j++) arr[j][i] = 1 - arr[j][i];
		if (isPossible())
		{
			print();
			return 0;
		}
	}
	cout << "NO\n";
	return 0;
}


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

int N, M;
int arr[MAX][MAX];
int invCol[MAX];
int invRow[MAX];

int isPossible()
{
	int lastLoc = -1;
	for (int i = 0; i < N; i++)
	{
		int loc = -1;
		for (int j = 0; j < M; j++)
		{
			if (j && arr[i][j] != arr[i][j - 1])
			{
				if (loc >= 0) return 0;
				loc = i;
				invRow[i] = !arr[i][j];
			}
		}
		if (i && loc >= 0 && lastLoc < loc) return 0;
		if (loc == -1)
		{
			if (lastLoc == M || lastLoc == -1)
			{
				loc = M;
				invRow[i] = arr[i][0];
			}
			else
			{
				loc = 0;
				invRow[i] = !arr[i][0];
			}
		}
		lastLoc = loc;
	}
	lastLoc = -1;
	for (int i = 0; i < M; i++)
	{
		int loc = -1;
		for (int j = 0; j < N; j++)
		{
			if (j && (arr[j][i] ^ invRow[j]) != (arr[j - 1][i] ^ invRow[j - 1]))
			{
				if (loc >= 0) return 0;
				loc = j;
			}
		}
		if (i && loc >= 0 && lastLoc < loc) return 0;
		if (loc == -1)
		{
			if (lastLoc == N) loc = N;
			else loc = 0;
		}
		lastLoc = loc;
	}
	return 1;
}

void print()
{
	cout << "YES\n";
	for (int i = 0; i < N; i++) cout << invRow[i];
	cout << "\n";
	for (int i = 0; i < M; i++) cout << invCol[i];
	cout << "\n";
}

int main(void)
{
	cin >> N >> M;
	for (int i = 0; i < N; i++)
	{
		for (int j = 0; j < M; j++) cin >> arr[i][j];
	}
	for (int j = 0; j < M; j++) invCol[j] = arr[0][j];
	for (int i = 0; i < N; i++)
	{
		for (int j = 0; j < M; j++) arr[i][j] ^= invCol[j];
	}
	if (isPossible())
	{
		print();
		return 0;
	}
	for (int i = M - 1; i >= 0; i--)
	{
		invCol[i] = 1 - invCol[i];
		for (int j = 0; j < N; j++) arr[j][i] = 1 - arr[j][i];
		if (isPossible())
		{
			print();
			return 0;
		}
	}
	for (int i = M - 1; i >= 0; i--)
	{
		invCol[i] = 1 - invCol[i];
		for (int j = 0; j < N; j++) arr[j][i] = 1 - arr[j][i];
		if (isPossible())
		{
			print();
			return 0;
		}
	}
	for (int i = 0; i < M; i++)
	{
		invCol[i] = 1 - invCol[i];
		for (int j = 0; j < N; j++) arr[j][i] = 1 - arr[j][i];
		if (isPossible())
		{
			print();
			return 0;
		}
	}
	for (int i = 0; i < M; i++)
	{
		invCol[i] = 1 - invCol[i];
		for (int j = 0; j < N; j++) arr[j][i] = 1 - arr[j][i];
		if (isPossible())
		{
			print();
			return 0;
		}
	}
	cout << "NO\n";
	return 0;
}


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

int N, M;
int arr[MAX][MAX];
int invCol[MAX];
int invRow[MAX];

int isPossible()
{
	int lastLoc = -1;
	for (int i = 0; i < N; i++)
	{
		int loc = -1;
		for (int j = 0; j < M; j++)
		{
			if (j && arr[i][j] != arr[i][j - 1])
			{
				if (loc >= 0) return 0;
				loc = i;
				invRow[i] = !arr[i][j];
			}
		}
		if (i && loc >= 0 && lastLoc < loc) return 0;
		if (loc == -1)
		{
			if (lastLoc == M)
			{
				loc = M;
				invRow[i] = arr[i][0];
			}
			else
			{
				loc = 0;
				invRow[i] = !arr[i][0];
			}
		}
		lastLoc = loc;
	}
	lastLoc = -1;
	for (int i = 0; i < M; i++)
	{
		int loc = -1;
		for (int j = 0; j < N; j++)
		{
			if (j && (arr[j][i] ^ invRow[j]) != (arr[j - 1][i] ^ invRow[j - 1]))
			{
				if (loc >= 0) return 0;
				loc = j;
			}
		}
		if (i && loc >= 0 && lastLoc < loc) return 0;
		if (loc == -1)
		{
			if (lastLoc == N) loc = N;
			else loc = 0;
		}
		lastLoc = loc;
	}
	return 1;
}

void print()
{
	cout << "YES\n";
	for (int i = 0; i < N; i++) cout << invRow[i];
	cout << "\n";
	for (int i = 0; i < M; i++) cout << invCol[i];
	cout << "\n";
}

int main(void)
{
	cin >> N >> M;
	for (int i = 0; i < N; i++)
	{
		for (int j = 0; j < M; j++) cin >> arr[i][j];
	}
	for (int j = 0; j < M; j++) invCol[j] = arr[0][j];
	for (int i = 0; i < N; i++)
	{
		for (int j = 0; j < M; j++) arr[i][j] ^= invCol[j];
	}
	if (isPossible())
	{
		print();
		return 0;
	}
	for (int i = M - 1; i >= 0; i--)
	{
		invCol[i] = 1 - invCol[i];
		for (int j = 0; j < N; j++) arr[j][i] = 1 - arr[j][i];
		if (isPossible())
		{
			print();
			return 0;
		}
	}
	for (int i = M - 1; i >= 0; i--)
	{
		invCol[i] = 1 - invCol[i];
		for (int j = 0; j < N; j++) arr[j][i] = 1 - arr[j][i];
		if (isPossible())
		{
			print();
			return 0;
		}
	}
	for (int i = 0; i < M; i++)
	{
		invCol[i] = 1 - invCol[i];
		for (int j = 0; j < N; j++) arr[j][i] = 1 - arr[j][i];
		if (isPossible())
		{
			print();
			return 0;
		}
	}
	for (int i = 0; i < M; i++)
	{
		invCol[i] = 1 - invCol[i];
		for (int j = 0; j < N; j++) arr[j][i] = 1 - arr[j][i];
		if (isPossible())
		{
			print();
			return 0;
		}
	}
	cout << "NO\n";
	return 0;
}


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

int N, M;
int arr[MAX][MAX];
int invCol[MAX];
int invRow[MAX];

int isPossible()
{
	int lastLoc = -1;
	for (int i = 0; i < N; i++)
	{
		int loc = -1;
		for (int j = 0; j < M; j++)
		{
			if (j && arr[i][j] != arr[i][j - 1])
			{
				if (loc >= 0) return 0;
				loc = i;
				invRow[i] = !arr[i][j];
			}
		}
		if (i && loc >= 0 && lastLoc < loc) return 0;
		if (loc == -1)
		{
			if (lastLoc == M || lastLoc == -1)
			{
				loc = M;
				invRow[i] = arr[i][0];
			}
			else
			{
				loc = 0;
				invRow[i] = !arr[i][0];
			}
		}
		lastLoc = loc;
	}
	lastLoc = -1;
	for (int i = 0; i < M; i++)
	{
		int loc = -1;
		for (int j = 0; j < N; j++)
		{
			if (j && (arr[j][i] ^ invRow[j]) != (arr[j - 1][i] ^ invRow[j - 1]))
			{
				if (loc >= 0) return 0;
				loc = j;
			}
		}
		if (i && loc >= 0 && lastLoc < loc) return 0;
		if (loc == -1)
		{
			if (lastLoc == N || lastLoc == -1) loc = N;
			else loc = 0;
		}
		lastLoc = loc;
	}
	return 1;
}

void print()
{
	cout << "YES\n";
	for (int i = 0; i < N; i++) cout << invRow[i];
	cout << "\n";
	for (int i = 0; i < M; i++) cout << invCol[i];
	cout << "\n";
}

int main(void)
{
	cin >> N >> M;
	for (int i = 0; i < N; i++)
	{
		for (int j = 0; j < M; j++) cin >> arr[i][j];
	}
	for (int j = 0; j < M; j++) invCol[j] = arr[0][j];
	for (int i = 0; i < N; i++)
	{
		for (int j = 0; j < M; j++) arr[i][j] ^= invCol[j];
	}
	if (isPossible())
	{
		print();
		return 0;
	}
	for (int i = M - 1; i >= 0; i--)
	{
		invCol[i] = 1 - invCol[i];
		for (int j = 0; j < N; j++) arr[j][i] = 1 - arr[j][i];
		if (isPossible())
		{
			print();
			return 0;
		}
	}
	for (int i = M - 1; i >= 0; i--)
	{
		invCol[i] = 1 - invCol[i];
		for (int j = 0; j < N; j++) arr[j][i] = 1 - arr[j][i];
		if (isPossible())
		{
			print();
			return 0;
		}
	}
	for (int i = 0; i < M; i++)
	{
		invCol[i] = 1 - invCol[i];
		for (int j = 0; j < N; j++) arr[j][i] = 1 - arr[j][i];
		if (isPossible())
		{
			print();
			return 0;
		}
	}
	for (int i = 0; i < M; i++)
	{
		invCol[i] = 1 - invCol[i];
		for (int j = 0; j < N; j++) arr[j][i] = 1 - arr[j][i];
		if (isPossible())
		{
			print();
			return 0;
		}
	}
	cout << "NO\n";
	return 0;
}


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

int N, M;
int arr[MAX][MAX];
int invCol[MAX];
int invRow[MAX];

int isPossible()
{
	int lastLoc = M;
	for (int i = 0; i < N; i++)
	{
		int loc = -1;
		for (int j = 0; j < M; j++)
		{
			if (j && arr[i][j] != arr[i][j - 1])
			{
				if (loc >= 0) return 0;
				loc = j;
				invRow[i] = !arr[i][j];
			}
		}
		if (lastLoc < loc) return 0;
		if (loc == -1)
		{
			if (lastLoc == M)
			{
				loc = M;
				invRow[i] = arr[i][0];
			}
			else
			{
				loc = 0;
				invRow[i] = !arr[i][0];
			}
		}
		lastLoc = loc;
	}
	lastLoc = N;
	for (int i = 0; i < M; i++)
	{
		int loc = -1;
		for (int j = 0; j < N; j++)
		{
			if (j && (arr[j][i] ^ invRow[j]) != (arr[j - 1][i] ^ invRow[j - 1]))
			{
				if (loc >= 0) return 0;
				loc = j;
			}
		}
		if (lastLoc < loc) return 0;
		if (loc == -1)
		{
			if (lastLoc == N) loc = N;
			else loc = 0;
		}
		lastLoc = loc;
	}
	return 1;
}

void print()
{
	cout << "YES\n";
	for (int i = 0; i < N; i++) cout << invRow[i];
	cout << "\n";
	for (int i = 0; i < M; i++) cout << invCol[i];
	cout << "\n";
}

int main(void)
{
	cin >> N >> M;
	for (int i = 0; i < N; i++)
	{
		for (int j = 0; j < M; j++) cin >> arr[i][j];
	}
	for (int j = 0; j < M; j++) invCol[j] = arr[0][j];
	for (int i = 0; i < N; i++)
	{
		for (int j = 0; j < M; j++) arr[i][j] ^= invCol[j];
	}
	if (isPossible())
	{
		print();
		return 0;
	}
	for (int i = M - 1; i >= 0; i--)
	{
		invCol[i] = 1 - invCol[i];
		for (int j = 0; j < N; j++) arr[j][i] = 1 - arr[j][i];
		if (isPossible())
		{
			print();
			return 0;
		}
	}
	cout << "NO\n";
	return 0;
}


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

int N, M;
int arr[MAX][MAX];
int invCol[MAX];
int invRow[MAX];

int isPossible()
{
	int lastLoc = -1;
	for (int i = 0; i < N; i++)
	{
		int loc = -1;
		for (int j = 0; j < M; j++)
		{
			if (j && arr[i][j] != arr[i][j - 1])
			{
				if (loc >= 0) return 0;
				loc = i;
				invRow[i] = !arr[i][j];
			}
		}
		if (i && loc >= 0 && lastLoc < loc) return 0;
		if (loc == -1)
		{
			if (lastLoc == M)
			{
				loc = M;
				invRow[i] = arr[i][0];
			}
			else
			{
				loc = 0;
				invRow[i] = !arr[i][0];
			}
		}
		lastLoc = loc;
	}
	lastLoc = -1;
	for (int i = 0; i < M; i++)
	{
		int loc = -1;
		for (int j = 0; j < N; j++)
		{
			if (j && (arr[j][i] ^ invRow[j]) != (arr[j - 1][i] ^ invRow[j - 1]))
			{
				if (loc >= 0) return 0;
				loc = j;
			}
		}
		if (i && loc >= 0 && lastLoc < loc) return 0;
		if (loc == -1)
		{
			if (lastLoc == N) loc = N;
			else loc = 0;
		}
		lastLoc = loc;
	}
	return 1;
}

void print()
{
	cout << "YES\n";
	for (int i = 0; i < N; i++) cout << invRow[i];
	cout << "\n";
	for (int i = 0; i < M; i++) cout << invCol[i];
	cout << "\n";
}

int main(void)
{
	cin >> N >> M;
	for (int i = 0; i < N; i++)
	{
		for (int j = 0; j < M; j++) cin >> arr[i][j];
	}
	for (int j = 0; j < M; j++) invCol[j] = arr[0][j];
	for (int i = 0; i < N; i++)
	{
		for (int j = 0; j < M; j++) arr[i][j] ^= invCol[j];
	}
	if (isPossible())
	{
		print();
		return 0;
	}
	for (int i = M - 1; i >= 0; i--)
	{
		invCol[i] = 1 - invCol[i];
		for (int j = 0; j < N; j++) arr[j][i] = 1 - arr[j][i];
		if (isPossible())
		{
			print();
			return 0;
		}
	}
	for (int i = M - 1; i >= 0; i--)
	{
		invCol[i] = 1 - invCol[i];
		for (int j = 0; j < N; j++) arr[j][i] = 1 - arr[j][i];
		if (isPossible())
		{
			print();
			return 0;
		}
	}
	cout << "NO\n";
	return 0;
}


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

int N, M;
int arr[MAX][MAX];
int invCol[MAX];
int invRow[MAX];

int isPossible()
{
	int lastLoc = -1;
	for (int i = 0; i < N; i++)
	{
		int loc = -1;
		for (int j = 0; j < M; j++)
		{
			if (j && arr[i][j] != arr[i][j - 1])
			{
				if (loc >= 0) return 0;
				loc = i;
				invRow[i] = !arr[i][j];
			}
		}
		if (i && loc >= 0 && lastLoc < loc) return 0;
		if (loc == -1)
		{
			if (lastLoc == M || lastLoc == -1)
			{
				loc = M;
				invRow[i] = arr[i][0];
			}
			else
			{
				loc = 0;
				invRow[i] = !arr[i][0];
			}
		}
		lastLoc = loc;
	}
	lastLoc = -1;
	for (int i = 0; i < M; i++)
	{
		int loc = -1;
		for (int j = 0; j < N; j++)
		{
			if (j && (arr[j][i] ^ invRow[j]) != (arr[j - 1][i] ^ invRow[j - 1]))
			{
				if (loc >= 0) return 0;
				loc = j;
			}
		}
		if (i && loc >= 0 && lastLoc < loc) return 0;
		if (loc == -1)
		{
			if (lastLoc == N || lastLoc == -1) loc = N;
			else loc = 0;
		}
		lastLoc = loc;
	}
	return 1;
}

void print()
{
	cout << "YES\n";
	for (int i = 0; i < N; i++) cout << invRow[i];
	cout << "\n";
	for (int i = 0; i < M; i++) cout << invCol[i];
	cout << "\n";
}

int main(void)
{
	cin >> N >> M;
	for (int i = 0; i < N; i++)
	{
		for (int j = 0; j < M; j++) cin >> arr[i][j];
	}
	for (int j = 0; j < M; j++) invCol[j] = arr[0][j];
	for (int i = 0; i < N; i++)
	{
		for (int j = 0; j < M; j++) arr[i][j] ^= invCol[j];
	}
	if (isPossible())
	{
		print();
		return 0;
	}
	for (int i = M - 1; i >= 0; i--)
	{
		invCol[i] = 1 - invCol[i];
		for (int j = 0; j < N; j++) arr[j][i] = 1 - arr[j][i];
		if (isPossible())
		{
			print();
			return 0;
		}
	}
	cout << "NO\n";
	return 0;
}


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

int N, M;
int arr[MAX][MAX];
int invCol[MAX];
int invRow[MAX];

int isPossible()
{
	int lastLoc = -1;
	for (int i = 0; i < N; i++)
	{
		int loc = -1;
		for (int j = 0; j < M; j++)
		{
			if (j && arr[i][j] != arr[i][j - 1])
			{
				if (loc >= 0) return 0;
				loc = i;
				invRow[i] = !arr[i][j];
			}
		}
		if (i && loc >= 0 && lastLoc < loc) return 0;
		if (loc == -1)
		{
			if (lastLoc == M)
			{
				loc = M;
				invRow[i] = arr[i][0];
			}
			else
			{
				loc = 0;
				invRow[i] = !arr[i][0];
			}
		}
		lastLoc = loc;
	}
	lastLoc = -1;
	for (int i = 0; i < M; i++)
	{
		int loc = -1;
		for (int j = 0; j < N; j++)
		{
			if (j && (arr[j][i] ^ invRow[j]) != (arr[j - 1][i] ^ invRow[j - 1]))
			{
				if (loc >= 0) return 0;
				loc = j;
			}
		}
		if (i && loc >= 0 && lastLoc < loc) return 0;
		if (loc == -1)
		{
			if (lastLoc == N) loc = N;
			else loc = 0;
		}
		lastLoc = loc;
	}
	return 1;
}

void print()
{
	cout << "YES\n";
	for (int i = 0; i < N; i++) cout << invRow[i];
	cout << "\n";
	for (int i = 0; i < M; i++) cout << invCol[i];
	cout << "\n";
}

int main(void)
{
	cin >> N >> M;
	for (int i = 0; i < N; i++)
	{
		for (int j = 0; j < M; j++) cin >> arr[i][j];
	}
	for (int j = 0; j < M; j++) invCol[j] = arr[0][j];
	for (int i = 0; i < N; i++)
	{
		for (int j = 0; j < M; j++) arr[i][j] ^= invCol[j];
	}
	if (isPossible())
	{
		print();
		return 0;
	}
	for (int i = M - 1; i >= 0; i--)
	{
		invCol[i] = 1 - invCol[i];
		for (int j = 0; j < N; j++) arr[j][i] = 1 - arr[j][i];
		if (isPossible())
		{
			print();
			return 0;
		}
	}
	for (int i = 0; i < M; i++)
	{
		invCol[i] = 1 - invCol[i];
		for (int j = 0; j < N; j++) arr[j][i] = 1 - arr[j][i];
		if (isPossible())
		{
			print();
			return 0;
		}
	}
	cout << "NO\n";
	return 0;
}


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

int N, M;
int arr[MAX][MAX];
int invCol[MAX];
int invRow[MAX];

int isPossible()
{
	int appeared = 0;
	for (int i = 0; i < N; i++) invRow[i] = 0;
	for (int i = 0; i < N; i++)
	{
		for (int j = 0; j < M; j++)
		{
			if (arr[i][j] ^ invRow[i])
			{
				if (j) appeared = 1;
				else if (!appeared) invRow[i] = 1;
			}
			else if (appeared)
			{
				if (j) return 0;
				else invRow[i] = 1;
			}
		}
	}
	return 1;
}

void print()
{
	cout << "YES\n";
	for (int i = 0; i < N; i++) cout << invRow[i];
	cout << "\n";
	for (int i = 0; i < M; i++) cout << invCol[i];
	cout << "\n";
}

int main(void)
{
	cin >> N >> M;
	for (int i = 0; i < N; i++)
	{
		for (int j = 0; j < M; j++) cin >> arr[i][j];
	}
	for (int j = 0; j < M; j++) invCol[j] = arr[0][j];
	for (int i = 0; i < N; i++)
	{
		for (int j = 0; j < M; j++) arr[i][j] ^= invCol[j];
	}
	if (isPossible())
	{
		print();
		return 0;
	}
	for (int j = 0; j < M; j++)
	{
		if (!arr[N - 1][j])
		{
			invCol[j] ^= 1;
			for (int i = 0; i < N; i++) arr[i][j] ^= 1;
		}
	}
	if (isPossible())
	{
		print();
		return 0;
	}
	cout << "NO\n";
	return 0;
}


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

const int maxn = 200 + 5;
int a[maxn][maxn], b[maxn][maxn];
int c[maxn], r[maxn];

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

    for (int cnt = 0; cnt <= n * m; ++cnt) {
        for (int p = 0; p < 2; ++p) {
            r[0] = p;
            for (int i = 0; i < m; ++i) {
                int s = (i >= cnt);
                c[i] = (s ^ r[0] ^ a[0][i]);
            }
            for (int i = 1; i < n; ++i) {
                int s = (i * m >= cnt);
                r[i] = (s ^ c[0] ^ a[i][0]);
            }
            bool valid = true;
            for (int i = 0; i < n; ++i) {
                for (int j = 0; j < m; ++j) {
                    valid &= (a[i][j] ^ r[i] ^ c[j]) == (i * m + j >= cnt);
                }
            }

            if (valid) {
                puts("YES");
                for (int i = 0; i < n; ++i) printf("%d", r[i]);
                puts("");
                for (int i = 0; i < m; ++i) printf("%d", c[i]);
                puts("");
                return 0;
            }
        }
    }

    puts("NO");
    return 0;
}


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

const int maxn = 200 + 5;
int a[maxn][maxn], b[maxn][maxn];
int c[maxn], r[maxn];

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

    for (int cnt = 0; cnt <= n * m; ++cnt) {
        for (int p = 0; p < 2; ++p) {
            r[0] = p;
            for (int i = 0; i < m; ++i) {
                int s = (i >= cnt);
                c[i] = (s ^ r[0] ^ a[0][i]);
            }
            for (int i = 1; i < n; ++i) {
                int s = (i * m >= cnt);
                r[i] = (s ^ c[0] ^ a[i][0]);
            }
            bool valid = true;
            for (int i = 0; i < n && valid; ++i) {
                for (int j = 0; j < m && valid; ++j) {
                    valid &= (a[i][j] ^ r[i] ^ c[j]) == (i * m + j >= cnt);
                }
            }

            if (valid) {
                puts("YES");
                for (int i = 0; i < n; ++i) printf("%d", r[i]);
                puts("");
                for (int i = 0; i < m; ++i) printf("%d", c[i]);
                puts("");
                return 0;
            }
        }
    }

    puts("NO");
    return 0;
}


#include <iostream>
#include <algorithm>
using namespace std;
typedef unsigned long long ull;

ull n, ans = 0;

int main()
{
    cin>>n;
    if (!(n%10)){
        ans = 10;
        n += 10;
        n /= 10;
    }
    while (n>10){
        if (n%10){
            ans += (10 - (n%10));
            n += (10 - (n%10));
        }
        else{
            n /= 10;
        }
    }
    ans += 9;
    cout<<ans<<"\n";
    return 0;
}


#include<bits/stdc++.h>
#include<iostream>
#include<fstream>
#define ll long long
using namespace std;

void inverseRow(vector<vector<int>> &b, int row){
    int M = b[row].size();
    for(int i=0; i<M; i++){
        b[row][i] = (b[row][i]==0 ? 1:0);
    }
}

void inverseColumn(vector<vector<int>> &b, int column){
    int N = b.size();
    for(int i=0; i<N; i++){
        b[i][column] = (b[i][column]==0 ? 1:0);
    }
}

bool valid(vector<vector<int>> b, int N, int M){
    int prev = 0;
    for(int n=0; n<N; n++) for(int m=0; m<M; m++){
        // cout << n << " " << m << " " << prev << " " << b[n][n] << endl;
        if(b[n][m]<prev){
            return false;
        }
        prev = b[n][m];
    }
    return true;
}

int main(){
    int N, M;  cin >> N >> M;
    vector<vector<int>> a(N, vector<int>(M));
    for(int n=0; n<N; n++) for(int m=0; m<M; m++)
        cin >> a[n][m];

    for(int c=0; c<=M; c++){
        string C = "";
        vector<vector<int>> b = a;
        for(int m=0; m<M; m++){
            if(m < c){
                // b[0][m] = 0
                if(b[0][m]==0) C += "0";
                else{
                    C += "1";
                    inverseColumn(b,m);
                }
            }else{
                // a[0][m] = 1
                if(b[0][m]==1) C += "0";
                else{
                    C += "1";
                    inverseColumn(b,m);
                }
            }
        }

        string R = "0";
        for(int n=1; n<N; n++){
            if(b[n-1][M-1] > b[n][0]){
                R += "1";
                inverseRow(b, n);
            }else{
                R += "0";
            }
        }

        // cout << "---------------" << endl;
        // for(int n=0; n<N; n++){
        //     for(int m=0; m<M; m++){
        //         cout << b[n][m] << " ";
        //     }cout << endl;
        // }
        // cout << "---------------" << endl;

        if(valid(b, N, M)){
            cout << "YES" << endl << R << endl << C << endl;
            return 0;
        }
    }
    cout << "NO" << endl;
}


#include<bits/stdc++.h>
#include<iostream>
#include<fstream>
#define ll long long
using namespace std;

void inverseRow(vector<vector<int>> &b, int row){
    int M = b[row].size();
    for(int i=0; i<M; i++){
        b[row][i] = (b[row][i]==0 ? 1:0);
    }
}

void inverseColumn(vector<vector<int>> &b, int column){
    int N = b.size();
    for(int i=0; i<N; i++){
        b[i][column] = (b[i][column]==0 ? 1:0);
    }
}

bool valid(vector<vector<int>> b, int N, int M){
    int prev = 0;
    for(int n=0; n<N; n++) for(int m=0; m<M; m++){
        // cout << n << " " << m << " " << prev << " " << b[n][n] << endl;
        if(b[n][m]<prev){
            return false;
        }
        prev = b[n][m];
    }
    return true;
}

int main(){
    int N, M;  cin >> N >> M;
    vector<vector<int>> a(N, vector<int>(M));
    for(int n=0; n<N; n++) for(int m=0; m<M; m++)
        cin >> a[n][m];

    for(int c=0; c<=M; c++){
        string C = "";
        vector<vector<int>> b = a;
        for(int m=0; m<M; m++){
            if(m < c){
                // b[0][m] = 0
                if(b[0][m]==0) C += "0";
                else{
                    C += "1";
                    inverseColumn(b,m);
                }
            }else{
                // b[0][m] = 1
                if(b[0][m]==1) C += "0";
                else{
                    C += "1";
                    inverseColumn(b,m);
                }
            }
        }

        string R = "0";
        for(int n=1; n<N; n++){
            if(b[n-1][M-1] > b[n][0] || b[n][0] > b[n][M-1]){
                R += "1";
                inverseRow(b, n);
            }else{
                R += "0";
            }
        }

        // cout << "---------------" << endl;
        // for(int n=0; n<N; n++){
        //     for(int m=0; m<M; m++){
        //         cout << b[n][m] << " ";
        //     }cout << endl;
        // }
        // cout << "---------------" << endl;

        if(valid(b, N, M)){
            cout << "YES" << endl << R << endl << C << endl;
            return 0;
        }
    }
    cout << "NO" << endl;
}


#include<bits/stdc++.h>
#include<iostream>
#include<fstream>
#define ll long long
using namespace std;

void inverseRow(vector<vector<int>> &b, int row){
    int M = b[row].size();
    for(int i=0; i<M; i++){
        b[row][i] = (b[row][i]==0 ? 1:0);
    }
}

void inverseColumn(vector<vector<int>> &b, int column){
    int N = b.size();
    for(int i=0; i<N; i++){
        b[i][column] = (b[i][column]==0 ? 1:0);
    }
}

bool valid(vector<vector<int>> b, int N, int M){
    int prev = 0;
    for(int n=0; n<N; n++) for(int m=0; m<M; m++){
        // cout << n << " " << m << " " << prev << " " << b[n][n] << endl;
        if(b[n][m]<prev){
            return false;
        }
        prev = b[n][m];
    }
    return true;
}

int main(){
    int N, M;  cin >> N >> M;
    vector<vector<int>> a(N, vector<int>(M));
    for(int n=0; n<N; n++) for(int m=0; m<M; m++)
        cin >> a[n][m];

    for(int c=0; c<=M; c++){
        string C = "";
        vector<vector<int>> b = a;
        for(int m=0; m<M; m++){
            if(m < c){
                // b[0][m] = 0
                if(b[0][m]==0) C += "0";
                else{
                    C += "1";
                    inverseColumn(b,m);
                }
            }else{
                // b[0][m] = 1
                if(b[0][m]==1) C += "0";
                else{
                    C += "1";
                    inverseColumn(b,m);
                }
            }
        }

        string R = "0";
        for(int n=1; n<N; n++){
            if(b[n-1][M-1] > b[n][0] || b[n][0] > b[n][M-1] || (b[n-1][M-1]==0 && b[n][0]==1)){
                R += "1";
                inverseRow(b, n);
            }else{
                R += "0";
            }
        }

        // cout << "---------------" << endl;
        // for(int n=0; n<N; n++){
        //     for(int m=0; m<M; m++){
        //         cout << b[n][m] << " ";
        //     }cout << endl;
        // }
        // cout << "---------------" << endl;

        if(valid(b, N, M)){
            cout << "YES" << endl << R << endl << C << endl;
            return 0;
        }
    }
    cout << "NO" << endl;
}


#include <bits/stdc++.h>

using namespace std;

#define MAXN 210
#define MAXM 210

int n, m;
int a[MAXN][MAXM];
int cont[3];
int found;
int pos;
int cn[MAXN];
int cm[MAXM];

int main() {
    scanf("%d %d", &n, &m);
    int i, j, k, pos;
    for (i=1; i<=n; i++) {
        for (j=1; j<=m; j++) {
            scanf("%d", &a[i][j]);
        }
    }

    found = 0;
    int t=1;
    for (k=1; k<=2; k++) {

        // inverte a primeira linha
        for (j=1; j<=m; j++) {
            a[1][j]=1-a[1][j];
        }
        cn[1]=1-cn[1];

        // deixa tudo 1
        for (j=1; j<=m; j++) {
            if (a[1][j]==0) {
                for (i=1; i<=n; i++) {
                    a[i][j]=1-a[i][j];
                }
                cm[j]=1-cm[j];
            }
        }

        // testa tudo pra primeira linha e verifica as outras linhas
        pos = 1;
        do {

          /*  printf("Teste %d\n", t++);
            for (i=1; i<=n; i++) {
                for (j=1; j<=m; j++) {
                    printf("%d ", a[i][j]);
                }
                printf("\n");
            }
            printf("\n");

             for (i=1; i<=n; i++) {
                printf("%d", cn[i]);
            }
            printf("\n");
            for (j=1; j<=m; j++) {
                printf("%d", cm[j]);
            }
            printf("\n\n");*/

             // verifica se é solucao
            int dif[MAXN];
            memset(cont, 0, sizeof(cont));
            for (i=2; i<=n; i++) {
                dif[i] = 0;
                for (j=1; j<=m-1; j++) {
                    if (a[i][j]!=a[i][j+1]) {
                        dif[i]++;
                    }
                }
                cont[min(dif[i], 2)]++;
            }
            if (pos!=n+1) { // tem algum 1
                if (cont[1]==0 && cont[2]==0) { // o resto das linhas tem que ser 1
                    found = 1;
                    for (i=2; i<=n; i++) {
                        if (a[i][1]==0) {
                            cn[i]=1-cn[i];
                        }
                    }
                    break;
                }
            }
            else { // so 0

                if (cont[1]<=1 && cont[2]==0) { //comeco 0 e se achar um ponto flag ai foca so 1
                    int achou = 0;
                    for (i=2; i<=n; i++) {
                        if (achou==1) { // tem que ser 1
                            if (a[i][1]==0) {
                                cn[i]=1-cn[i];
                            }
                        }
                        else { // tem que ser 0
                            if (a[i][1]==1) {
                                cn[i]=1-cn[i];
                            }
                            if (dif[i]==1) {
                                achou = 1;
                            }
                        }
                    }
                    found = 1;
                    break;
                }
            }

            // colocar 0 no coluna pos
            if (pos<=n) {
                for (i=1; i<=n; i++) {
                    a[i][pos]=1-a[i][pos];
                }
                cm[pos]=1-cm[pos];
            }

            pos++;

        } while (pos<=n+1);

        if (found==1) {
            break;
        }

    }

    if (found==1) {
        printf("YES\n");
        for (i=1; i<=n; i++) {
            printf("%d", cn[i]);
        }
        printf("\n");
        for (j=1; j<=m; j++) {
            printf("%d", cm[j]);
        }
        printf("\n");
    }
    else {
        printf("NO\n");
    }

    return 0;
}


#include <bits/stdc++.h>

using namespace std;

#define MAXN 210
#define MAXM 210

int n, m;
int a[MAXN][MAXM];
int cont[3];
int found;
int pos;
int cn[MAXN];
int cm[MAXM];

int main() {
    scanf("%d %d", &n, &m);
    int i, j, k, pos;
    for (i=1; i<=n; i++) {
        for (j=1; j<=m; j++) {
            scanf("%d", &a[i][j]);
        }
    }

    //printf("\n\n");
    found = 0;
    int t=1;
    for (k=1; k<=2; k++) {

        // inverte a primeira linha
        for (j=1; j<=m; j++) {
            a[1][j]=1-a[1][j];
        }
        cn[1]=1-cn[1];

        // deixa tudo 1
        for (j=1; j<=m; j++) {
            if (a[1][j]==0) {
                for (i=1; i<=n; i++) {
                    a[i][j]=1-a[i][j];
                }
                cm[j]=1-cm[j];
            }
        }

        // testa tudo pra primeira linha e verifica as outras linhas
        pos = 1;
        do {

           /* printf("Teste %d\n", t++);
            for (i=1; i<=n; i++) {
                for (j=1; j<=m; j++) {
                    printf("%d ", a[i][j]);
                }
                printf("\n");
            }
            printf("\n");

             for (i=1; i<=n; i++) {
                printf("%d", cn[i]);
            }
            printf("\n");
            for (j=1; j<=m; j++) {
                printf("%d", cm[j]);
            }
            printf("\n\n");*/

             // verifica se é solucao
            int dif[MAXN];
            memset(cont, 0, sizeof(cont));
            for (i=2; i<=n; i++) {
                dif[i] = 0;
                for (j=1; j<=m-1; j++) {
                    if (a[i][j]!=a[i][j+1]) {
                        dif[i]++;
                    }
                }
                cont[min(dif[i], 2)]++;
            }
            if (pos!=m+1) { // tem algum 1
                if (cont[1]==0 && cont[2]==0) { // o resto das linhas tem que ser 1
                    found = 1;
                    for (i=2; i<=n; i++) {
                        if (a[i][1]==0) {
                            cn[i]=1-cn[i];
                        }
                    }
                    break;
                }
            }
            else { // so 0

                if (cont[1]<=1 && cont[2]==0) { //comeco 0 e se achar um ponto flag ai foca so 1
                    int achou = 0;
                    for (i=2; i<=n; i++) {
                        if (achou==1) { // tem que ser 1
                            if (a[i][1]==0) {
                                cn[i]=1-cn[i];
                            }
                        }
                        else { // tem que ser 0
                            if (a[i][1]==1) {
                                cn[i]=1-cn[i];
                            }
                            if (dif[i]==1) {
                                achou = 1;
                            }
                        }
                    }
                    found = 1;
                    break;
                }
            }

            // colocar 0 no coluna pos
            if (pos<=m) {
                for (i=1; i<=n; i++) {
                    a[i][pos]=1-a[i][pos];
                }
                cm[pos]=1-cm[pos];
            }

            pos++;

        } while (pos<=m+1);

        if (found==1) {
            break;
        }

    }

    if (found==1) {
        printf("YES\n");
        for (i=1; i<=n; i++) {
            printf("%d", cn[i]);
        }
        printf("\n");
        for (j=1; j<=m; j++) {
            printf("%d", cm[j]);
        }
        printf("\n");
    }
    else {
        printf("NO\n");
    }

    return 0;
}


#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <ctime>
#include <limits.h>
#include <chrono>

#define fast                          \
    ios_base::sync_with_stdio(false); \
    cin.tie(0);                       \
    cout.tie(0);

#define ll long long
#define ld long double

#define pb push_back
#define ins insert
#define er erase

#define f(i, a, b) for (int i = a; i < b; ++i)
#define rf(i, a, b) for (int i = a; i >= b; --i)
#define cmax(a, b) a = max(a, b)
#define cmin(a, b) a = min(a, b)
#define cadd(a, b) a = add(a, b)
#define csub(a, b) a = sub(a, b)
#define cmul(a, b) a = mult(a, b)
#define mem(a, b) memset(a, b, sizeof(a))

#define vi vector<int>
#define vst vector<string>
#define vpii vector<pii>

#define all(v) v.begin(), v.end()
#define lb lower_bound
#define ub upper_bound
#define mxe max_element
#define mne min_element

#define srt(v) sort(all(v))
#define rsrt(v) sort(v.rbegin(), v.rend())

#define pii pair<int, int>
#define ff first
#define ss second

#define bs bitset
#define bpc(a) __builtin_popcount(a)

#define mii map<int, int>
#define umii unordered_map<int, int>

#define si set<int>
#define usi unordered_set<int>
#define spii set<pii>

#define pqi priority_queue<int>
#define pqpii priority_queue<pii>

#define dbg(a, st, end)                   \
    f(i, st, end + 1) cerr << a[i] << sp; \
    cerr << nl;
#define pnt(a, st, end)                   \
    f(i, st, end + 1) cout << a[i] << sp; \
    cout << nl;
#define dbgc(a)          \
    for (auto y : a)     \
        cerr << y << sp; \
    cerr << nl;
#define dbgm(a)                            \
    for (auto y : a)                       \
        cerr << y.ff << "," << y.ss << sp; \
    cerr << nl;

#define trace(a) cerr << a << nl;
#define trace2(a, b) cerr << a << sp << b << nl;
#define trace3(a, b, c) cerr << a << sp << b << sp << c << nl;
#define trace4(a, b, c, d) cerr << a << sp << b << sp << c << sp << d << nl;

#define gcd(a, b) __gcd(a, b)
#define lcm(a, b) ((a)*1ll * (b)) / gcd(a, b)

#define nl "\n"
#define sp " "

using namespace std;
using namespace std::chrono;

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

#define ordered_set tree<pii, null_type, less<pii>, rb_tree_tag, tree_order_statistics_node_update>
#define ok order_of_key
#define fo find_by_order

ll md = 1000000007;
ld pi = 3.141592653;
//ll md = 998244353;

ll pw(ll a, ll b)
{
    ll c = 1, m = a;
    while (b)
    {
        if (b & 1)
            c = (c * m);
        m = (m * m);
        b /= 2;
    }
    return c;
}

ll pwmd(ll a, ll b)
{
    ll c = 1, m = a;
    while (b)
    {
        if (b & 1)
            c = (c * m) % md;
        m = (m * m) % md;
        b /= 2;
    }
    return c;
}

ll modinv(ll n)
{
    return pwmd(n, md - 2);
}

ll my_ceil(ll a, ll b)
{
    if (a % b == 0)
        return a / b;
    return a / b + 1;
}

ll nc2(ll n)
{
    return (1ll * n * (n - 1)) / 2;
}

ll nsum(ll n)
{
    return (1ll * n * (n + 1)) / 2;
}

int my_log(ll n, int b)
{
    ll i = 1;
    int ans = 0;
    while (1)
    {
        if (i > n / b)
            break;
        i *= b;
        ans++;
    }
    return ans;
}

inline int nc()
{
    static char buf[100000], *p1 = buf, *p2 = buf;
    return p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 100000, stdin), p1 == p2) ? EOF : *p1++;
}
inline int read()
{
    int ret = 0;
    bool f = 0;
    char ch = nc();
    while (ch > '9' || ch < '0')
        f ^= ch == '-', ch = nc();
    while (ch <= '9' && ch >= '0')
        ret = ret * 10 + ch - '0', ch = nc();
    return f ? -ret : ret;
}

int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};

inline ll add(ll a, ll b) { return (((a >= md) ? a % md : a) + ((b >= md) ? b % md : b) + md) % md; }
inline ll subt(ll a, ll b) { return (a - b + md) % md; }
inline ll mult(ll a, ll b) { return (1ll * ((a >= md) ? a % md : a) * ((b >= md) ? b % md : b)) % md; }

inline int manhatten(pii p1, pii p2) { return abs(p1.ff - p2.ff) + abs(p1.ss - p2.ss); }

inline bool kthbit(ll n, int k) { return (n >> k) & 1; }
inline ll setkthbit(ll n, int k) { return n | (1ll << k); }
inline ll unsetkthbit(ll n, int k) { return n & ~(1ll << k); }
inline ll flipkthbit(ll n, int k) { return n ^ (1ll << k); }

//LET'S PLAY THE GAME!!

/*

CHECK FOR N=1, N=2, etc;
REMOVE DEBUG STATEMENTS
CHECK FOR DUPLICATES (SET -> MULTISET)
CHECK FOR OVERFLOW
CLEAR EVERYTHING BEFORE EVERY TESTCASE
DON'T MISTAKE ROOT FOR LEAF
DON'T ALWAYS IGNORE THE BRUTE FORCE SOLUTION!
IF NOTHING WORKS, READ THE PROBLEM STATEMENT AGAIN!

*/

//#define int long long //UNCOMMENT IF NEEDED

const int N = 205;

bool a[N][N];

int n, m;

string solve(vector<bool> opt)
{
    string s = "";
    f(i, 0, n + m) s.pb('0');
    bool b[n][m];
    f(i, 0, n) f(j, 0, m) b[i][j] = a[i][j];
    f(i, 0, m) if (b[0][i] ^ opt[i])
    {
        f(j, 0, n) b[j][i] ^= 1;
        s[n + i] = '1';
    }
    bool yep = 1;
    f(j, 1, n)
    {
        bool one = 0, zero = 0;
        f(i, 0, m) if (b[j][i]) one = 1;
        else zero = 1;
        if (one & zero)
        {
            yep = 0;
            break;
        }
        if (zero)
            s[j] = '1';
    }
    if (yep)
        return s;
    s = "";
    f(i, 0, n + m) s.pb('0');
    f(i, 0, n) f(j, 0, m) b[i][j] = a[i][j];
    f(i, 0, m) b[0][i] ^= 1;
    s[0] = '1';
    f(i, 0, m) if (b[0][i] ^ opt[i])
    {
        f(j, 0, n) b[j][i] ^= 1;
        s[n + i] = '1';
    }
    yep = 1;
    f(j, 1, n)
    {
        bool one = 0, zero = 0;
        f(i, 0, m) if (b[j][i]) one = 1;
        else zero = 1;
        if (one & zero)
        {
            yep = 0;
            break;
        }
        if (zero)
            s[j] = '1';
    }
    if (yep)
        return s;
    return "-1";
}

int32_t main()
{
    fast;

    int k, h, e;
    int x, q, l, r, y;

    string s, t, u;

    auto start = high_resolution_clock::now();

    int tcnt = 0;

    int tests = 1;
    //pre();
    //cin >> tests;

    while (tests--)
    {
        //cout << "Case #" << ++tcnt << ": ";
        cin >> n >> m;
        f(i, 0, n) f(j, 0, m) cin >> a[i][j];
        vector<bool> tmp(m, 1);
        f(i, 0, m)
        {
            s = solve(tmp);
            if (s != "-1")
            {
                cout << "YES\n"
                     << s.substr(0, n) << nl << s.substr(n, m);
                return 0;
            }
            tmp[i] = tmp[i] ^ 1;
        }
        s = "";
        f(i, 0, n + m) s.pb('0');
        bool b[n][m];
        f(i, 0, n) f(j, 0, m) b[i][j] = a[i][j];
        f(i, 0, m) if (b[0][i])
        {
            f(j, 0, n) b[j][i] ^= 1;
            s[n + i] = '1';
        }
        bool yep = 1, enc = 0;
        f(j, 1, n)
        {
            bool one = 0, zero = 0;
            f(i, 0, m) if (b[j][i]) one = 1;
            else zero = 1;
            if (one & zero)
            {
                if (enc)
                {
                    yep = 0;
                    break;
                }
                enc = 1;
                vi tt;
                tt.pb(b[j][0]);
                f(i, 1, m) if (b[j][i] ^ b[j][i - 1]) tt.pb(b[j][i]);
                if (tt.size() > 2)
                {
                    yep = 0;
                    break;
                }
                if (b[j][0])
                    s[j] = '1';
            }
            else if (zero && enc)
                s[j] = '1';
            else if (one && !enc)
                s[j] = '1';
        }
        if (yep)
        {
            cout << "YES\n"
                 << s.substr(0, n) << nl << s.substr(n, m);
            return 0;
        }
        s = "";
        f(i, 0, n + m) s.pb('0');
        f(i, 0, n) f(j, 0, m) b[i][j] = a[i][j];
        f(i, 0, m) b[0][i] ^= 1;
        s[0] = '1';
        f(i, 0, m) if (b[0][i])
        {
            f(j, 0, n) b[j][i] ^= 1;
            s[n + i] = '1';
        }
        yep = 1, enc = 0;
        f(j, 1, n)
        {
            bool one = 0, zero = 0;
            f(i, 0, m) if (b[j][i]) one = 1;
            else zero = 1;
            if (one & zero)
            {
                if (enc)
                {
                    yep = 0;
                    break;
                }
                enc = 1;
                vi tt;
                tt.pb(b[j][0]);
                f(i, 1, m) if (b[j][i] ^ b[j][i - 1]) tt.pb(b[j][i]);
                if (tt.size() > 2)
                {
                    yep = 0;
                    break;
                }
                if (b[j][0])
                    s[j] = '1';
            }
            else if (zero && enc)
                s[j] = '1';
            else if (one && !enc)
                s[j] = '1';
        }

        if (!yep)
            cout << "NO";
        else
            cout << "YES\n"
                 << s.substr(0, n) << nl << s.substr(n, m);

        // RESTORE SEGTREE SIZE
    }
    auto stop = high_resolution_clock::now();
    auto duration = duration_cast<microseconds>(stop - start);
    cerr << "Time taken: "
         << duration.count() / 1000000.0 << "seconds" << nl;
    return 0;
}

// AND THE GAME IS OVER !!


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

int a0[200][200], a[200][200];
int inv_col[200], inv_row[200];
int h, w;

void check(int zeros) {
  copy_n((int*)a0, 200*200, (int*)a);
  for (int i = 0; i < h; i++)
    for (int j = 0; j < w; j++)
      if (zeros > 0)
	zeros--;
      else
	a[i][j] ^= 1;
  /*for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++)
      cout << a[i][j] << ' ';
    cout << endl;
    }*/
  for (int j = 0; j < w; j++) {
    inv_col[j] = a[0][j];
    for (int i = 0; i < h; i++)
      a[i][j] ^= inv_col[j];
  }
  for (int i = 0; i < h; i++) {
    inv_row[i] = a[i][0];
    for (int j = 0; j < w; j++)
      a[i][j] ^= inv_row[i];
  }
  /*for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++)
      cout << a[i][j] << ' ';
    cout << endl;
    }*/
  for (int i = 0; i < h; i++)
    for (int j = 0; j < w; j++)
      if (a[i][j])
	return;
  cout << "YES" << endl;
  for (int i = 0; i < h; i++)
    cout << inv_row[i];
  cout << endl;
  for (int i = 0; i < w; i++)
    cout << inv_col[i];
  cout << endl;
  exit(0);
}

int main() {
  ios::sync_with_stdio(0); cin.tie(0);
  cin >> h >> w;
  for (int i = 0; i < h; i++)
    for (int j = 0; j < w; j++)
      cin >> a0[i][j];
  for (int i = 0; i <= w*h; i++)
    check(i);
  cout << "NO" << endl;
}


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

bitset<200> a0[200], a[200];
int inv_col[200], inv_row[200];
int h, w;

void check(int zeros) {
  bitset<200> maskw;
  for (int j = 0; j < w; j++)
    maskw.set(j);
  bitset<200> maskh;

  copy_n(a0, 200, a);
  for (int i = 0; i < h; i++) {
    if (zeros >= w) {
      zeros -= w;
    } else if (!zeros) {
      a[i] ^= maskw;
    } else {
      for (int j = 0; j < w; j++)
	if (zeros > 0)
	  zeros--;
	else
	  a[i].flip(j);
    }
  }
  /*for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++)
      cout << a[i][j] << ' ';
    cout << endl;
    }*/
  for (int j = 0; j < w; j++) {
    inv_col[j] = a[0][j];
    maskh.set(j,inv_col[j]);
  }

  for (int i = 0; i < h; i++)
    a[i] ^= maskh;
  for (int i = 0; i < h; i++) {
    inv_row[i] = a[i][0];
    if (inv_row[i])
      a[i] ^= maskw;
  }
  /*for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++)
      cout << a[i][j] << ' ';
    cout << endl;
    }*/
  for (int i = 0; i < h; i++)
    if (a[i].any())
      return;
  cout << "YES" << endl;
  for (int i = 0; i < h; i++)
    cout << inv_row[i];
  cout << endl;
  for (int i = 0; i < w; i++)
    cout << inv_col[i];
  cout << endl;
  exit(0);
}

int main() {
  ios::sync_with_stdio(0); cin.tie(0);
  cin >> h >> w;
  for (int i = 0; i < h; i++)
    for (int j = 0; j < w; j++) {
      int v;
      cin >> v;
      a0[i][j] = v;
    }
  for (int i = 0; i <= w*h; i++)
    check(i);
  cout << "NO" << endl;
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef complex<double> point;
#define F first
#define S second

struct two_satisfability // 0-based
{
	int V, dt, k;
	vector<bool> del, usd;
	vector<int> dfsnum, low, scc, ord, S;
	vector<vector<int>> G, iG;

	two_satisfability(int n) :
		V(2 * n), dt(0), k(0), del(V, 0), usd(V, 0), dfsnum(V, 0), low(V, 0), scc(V), ord(0), S(0), G(V), iG(V) {}

	void add_or(int u, int v)
	{
		G[u ^ 1].push_back(v), G[v ^ 1].push_back(u);
		iG[u].push_back(v ^ 1), iG[v].push_back(u ^ 1);
	}

	void top_sort(int u)
	{
		usd[u] = true;
		for (int i = 0, sz = G[u].size(); i < sz; i++)
			if (!usd[G[u][i]]) top_sort(G[u][i]);
		ord.push_back(u);
	}

	void dfs(int u)
	{
		S.push_back(u), dfsnum[u] = low[u] = ++dt;

		for (int v : iG[u])
			low[u] = min(low[u], !dfsnum[v] ? dfs(v), low[v] : !del[v] ? dfsnum[v] : low[u]);

		if (low[u] == dfsnum[u] && ++k)
			while (!del[u]) scc[S.back()] = k, del[S.back()] = true, S.pop_back();
	}

	bool solve(vector<bool> &out)
	{
		for (int i = 0; i < V; ++i)
			if (!usd[i]) top_sort(i);

		for (int i = V - 1; i >= 0; --i)
			if (!dfsnum[ord[i]]) dfs(ord[i]);

		for (int i = 0; i < V; i += 2)
		{
			if (scc[i] == scc[i ^ 1]) return false;
			out.push_back(scc[i] > scc[i ^ 1]);
		}

		return true;
	}
};

int main()
{
	#ifdef DGC
		//freopen("a.txt", "r", stdin);
		//freopen("b.txt", "w", stdout);
	#endif

	ios_base::sync_with_stdio(0), cin.tie(0);

	int n, m;
	cin >> n >> m;
	vector<vector<int>> a(n, vector<int>(m));

	for (auto &i : a)
		for (auto &j : i)
			cin >> j;

	for (int z = 0; z <= n+m; ++z)
	{
		two_satisfability sat2(n+m);

		int temp = z;
		for (int i = 0; i < n; ++i)
			for (int j = 0; j < m; ++j)
			{
				int sh = temp < 1;
				sh ^= a[i][j];

				if (sh)
				{
					sat2.add_or(2*i, 2*(n+j));
					sat2.add_or(2*i+1, 2*(n+j)+1);
				}
				else
				{
					sat2.add_or(2*i+1, 2*(n+j));
					sat2.add_or(2*(n+j)+1, 2*i);
				}

				--temp;
			}

		vector<bool> out;
		if (sat2.solve(out))
		{
			cout << "YES\n";
			for (int i = 0; i < n; ++i)
				cout << out[i];
			cout << "\n";
			for (int i = 0; i < m; ++i)
				cout << out[n+i];
			cout << "\n";
			return 0;
		}
	}

	cout << "NO\n";

	return 0;
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef complex<double> point;
#define F first
#define S second

struct sat2
{
	int n;
	vector<vector<int>> adj, radj;

	sat2(int n) : n(n), adj(2*n), radj(2*n) {}

	void add_edge(int u, int v)
	{
		adj[u].push_back(v);
		radj[v].push_back(u);
	}

	int neg(int u)
	{
		return 2*n-u-1;
	}

	void implication(int u, int v)
	{
		add_edge(u, v);
		add_edge(neg(v), neg(u));
	}

	vector<bool> value;

	bool solve()
	{
		vector<int> seen(2 * n);
		value.assign(2 * n, false);

		function<void(int, vector<vector<int>>&, vector<int>&)> visit =
				[&](int u, vector<vector<int>> &adj, vector<int> &vec)
		{
			seen[u] = true;
			for (int v : adj[u])
				if (!seen[v])
					visit(v, adj, vec);
			vec.push_back(u);
		};

		vector<int> order;

		for (int u = 0; u < n; ++u)
		{
			if (!seen[u]) visit(u, adj, order);
			if (!seen[neg(u)]) visit(neg(u), adj, order);
		}

		seen.assign(2 * n, false);
		reverse(order.begin(), order.end());

		vector<int> comp, id(2 * n);
		int cc = 0;

		for (int u : order)
			if (!seen[u])
			{
				comp.clear(); ++cc;
				visit(u, radj, comp);
				for (int v : comp)
					id[v] = cc;
			}

		for (int u = 0; u < n; ++u)
			if (id[u] == id[neg(u)]) return false;
			else value[u] = id[u] > id[neg(u)];

		return true;
	}
};

int main()
{
	#ifdef DGC
		//freopen("a.txt", "r", stdin);
		//freopen("b.txt", "w", stdout);
	#endif

	ios_base::sync_with_stdio(0), cin.tie(0);

	int n, m;
	cin >> n >> m;
	vector<vector<int>> a(n, vector<int>(m));

	for (auto &i : a)
		for (auto &j : i)
			cin >> j;

	for (int z = 0; z <= n+m; ++z)
	{
		sat2 sat(n+m);

		int temp = z;
		for (int i = 0; i < n; ++i)
			for (int j = 0; j < m; ++j)
			{
				int sh = temp < 1;
				sh ^= a[i][j];

				if (sh)
				{
					sat.implication(sat.neg(i), n+j);
					sat.implication(i, sat.neg(n+j));
				}
				else
				{
					sat.implication(i, n+j);
					sat.implication(n+j, i);
				}

				--temp;
			}

		if (sat.solve())
		{
			cout << "YES\n";
			for (int i = 0; i < n; ++i)
				cout << sat.value[i];
			cout << "\n";
			for (int i = 0; i < m; ++i)
				cout << sat.value[n+i];
			cout << "\n";
			return 0;
		}
	}

	cout << "NO\n";

	return 0;
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef complex<double> point;
#define F first
#define S second

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

struct sat2
{
	int n;
	vector<vector<int>> adj, radj;

	sat2(int n) : n(n), adj(2*n), radj(2*n) {}

	void add_edge(int u, int v)
	{
		adj[u].push_back(v);
		radj[v].push_back(u);
	}

	int neg(int u)
	{
		return 2*n-u-1;
	}

	void implication(int u, int v)
	{
		add_edge(u, v);
		add_edge(neg(v), neg(u));
	}

	vector<bool> value;

	bool solve()
	{
		vector<int> seen(2 * n);
		value.assign(2 * n, false);

		function<void(int, vector<vector<int>>&, vector<int>&)> visit =
				[&](int u, vector<vector<int>> &adj, vector<int> &vec)
		{
			seen[u] = true;
			for (int v : adj[u])
				if (!seen[v])
					visit(v, adj, vec);
			vec.push_back(u);
		};

		vector<int> order;

		for (int u = 0; u < n; ++u)
		{
			if (!seen[u]) visit(u, adj, order);
			if (!seen[neg(u)]) visit(neg(u), adj, order);
		}

		seen.assign(2 * n, false);
		reverse(order.begin(), order.end());

		vector<int> comp, id(2 * n);
		int cc = 0;

		for (int u : order)
			if (!seen[u])
			{
				comp.clear(); ++cc;
				visit(u, radj, comp);
				for (int v : comp)
					id[v] = cc;
			}

		for (int u = 0; u < n; ++u)
			if (id[u] == id[neg(u)]) return false;
			else value[u] = id[u] > id[neg(u)];

		return true;
	}
};

int main()
{
	#ifdef DGC
		//freopen("a.txt", "r", stdin);
		//freopen("b.txt", "w", stdout);
	#endif

	ios_base::sync_with_stdio(0), cin.tie(0);

	int n, m;
	cin >> n >> m;
	vector<vector<int>> a(n, vector<int>(m));

	for (auto &i : a)
		for (auto &j : i)
			cin >> j;

	for (int z = 0; z <= 2*(n+m); ++z)
	{
		sat2 sat(n+m);

		int temp = z;
		if (z > n+m)
		    z = uniform_int_distribution<int>(n+m+1, 2*(n+m))(rng);

		for (int i = 0; i < n; ++i)
			for (int j = 0; j < m; ++j)
			{
				int sh = temp < 1;
				sh ^= a[i][j];

				if (sh)
				{
					sat.implication(sat.neg(i), n+j);
					sat.implication(i, sat.neg(n+j));
				}
				else
				{
					sat.implication(i, n+j);
					sat.implication(n+j, i);
				}

				--temp;
			}

		if (sat.solve())
		{
			cout << "YES\n";
			for (int i = 0; i < n; ++i)
				cout << sat.value[i];
			cout << "\n";
			for (int i = 0; i < m; ++i)
				cout << sat.value[n+i];
			cout << "\n";
			return 0;
		}
	}

	cout << "NO\n";

	return 0;
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef complex<double> point;
#define F first
#define S second

struct sat2
{
	int n;
	vector<vector<int>> adj, radj;

	sat2(int n) : n(n), adj(2*n), radj(2*n) {}

	void add_edge(int u, int v)
	{
		adj[u].push_back(v);
		radj[v].push_back(u);
	}

	int neg(int u)
	{
		return 2*n-u-1;
	}

	void implication(int u, int v)
	{
		add_edge(u, v);
		add_edge(neg(v), neg(u));
	}

	vector<bool> value;

	bool solve()
	{
		vector<int> seen(2 * n);
		value.assign(2 * n, false);

		function<void(int, vector<vector<int>>&, vector<int>&)> visit =
				[&](int u, vector<vector<int>> &adj, vector<int> &vec)
		{
			seen[u] = true;
			for (int v : adj[u])
				if (!seen[v])
					visit(v, adj, vec);
			vec.push_back(u);
		};

		vector<int> order;

		for (int u = 0; u < n; ++u)
		{
			if (!seen[u]) visit(u, adj, order);
			if (!seen[neg(u)]) visit(neg(u), adj, order);
		}

		seen.assign(2 * n, false);
		reverse(order.begin(), order.end());

		vector<int> comp, id(2 * n);
		int cc = 0;

		for (int u : order)
			if (!seen[u])
			{
				comp.clear(); ++cc;
				visit(u, radj, comp);
				for (int v : comp)
					id[v] = cc;
			}

		for (int u = 0; u < n; ++u)
			if (id[u] == id[neg(u)]) return false;
			else value[u] = id[u] > id[neg(u)];

		return true;
	}
};

int main()
{
	#ifdef DGC
		//freopen("a.txt", "r", stdin);
		//freopen("b.txt", "w", stdout);
	#endif

	ios_base::sync_with_stdio(0), cin.tie(0);

	int n, m;
	cin >> n >> m;
	vector<vector<int>> a(n, vector<int>(m));

	for (auto &i : a)
		for (auto &j : i)
			cin >> j;

	for (int z = 0; z <= n*m; ++z)
	{
		sat2 sat(n+m);

		int temp = z;
		for (int i = 0; i < n; ++i)
			for (int j = 0; j < m; ++j)
			{
				int sh = temp < 1;
				sh ^= a[i][j];

				if (sh)
				{
					sat.implication(sat.neg(i), n+j);
					sat.implication(i, sat.neg(n+j));
				}
				else
				{
					sat.implication(i, n+j);
					sat.implication(n+j, i);
				}

				--temp;
			}

		if (sat.solve())
		{
			cout << "YES\n";
			for (int i = 0; i < n; ++i)
				cout << sat.value[i];
			cout << "\n";
			for (int i = 0; i < m; ++i)
				cout << sat.value[n+i];
			cout << "\n";
			return 0;
		}
	}

	cout << "NO\n";

	return 0;
}


#include <bits/stdc++.h>

using namespace std;

#ifdef NeverBeRed
#include "debug.h"
#else
#define debug(...) 9715
#endif
typedef long long ll;
typedef long double ld;
typedef complex<ld> point;
#define F first
#define S second

void solve(vector<vector<int>> a, int z, bool t)
{
	int n = a.size(), m = a[0].size();

	vector<int> row(n), col(m);
	row[0] ^= t;
	for (int j = 0; j < m; ++j)
		if ((j >= z) != a[0][j])
		{
			col[j] = 1;
			for (int i = 0; i < n; ++i)
				a[i][j] ^= 1;
		}
	bool ok = true;
	if (z < m)
	{
		for (int i = 1; i < n; ++i)
		{
			int x = !a[i][0];
			row[i] ^= x;
			for (int j = 0; j < m; ++j)
			{
				a[i][j] ^= x;
				ok &= a[i][j];
			}
		}
	}
	else
	{
		int i = 1;
		while (i < n && count(a[i].begin(), a[i].end(), 0) % m == 0)
			row[i] ^= a[i][0], ++i;
		if (i < n)
		{
			int x = a[i][0];
			row[i] ^= x;
			for (int j = 0; j < m; ++j)
			{
				a[i][j] ^= x;
				ok &= !j || a[i][j] >= a[i][j-1];
			}
			++i;
		}
		while (i < n)
		{
			ok &= count(a[i].begin(), a[i].end(), 0) % m == 0;
			row[i] ^= !a[i][0];
			++i;
		}
	}
	if (ok)
	{
		cout << "YES\n";
		for (auto i : row) cout << i;
		cout << "\n";
		for (auto i : col) cout << i;
		cout << "\n";
		exit(0);
	}
}

int main()
{
	#ifdef TurnRed
		//freopen("a.in", "r", stdin);
		//freopen("a.out", "w", stdout);
	#endif

	ios_base::sync_with_stdio(0), cin.tie(0);

	int n, m;
	cin >> n >> m;
	vector<vector<int>> a(n, vector<int>(m));
	for (auto &i : a)
		for (auto &j : i)
			cin >> j;

	for (int z = 0; z <= m; ++z)
		solve(a, z, false);
	for (int j = 0; j < m; ++j)
		a[0][j] ^= 1;
	for (int z = 0; z <= m; ++z)
		solve(a, z, true);

	cout << "NO\n";

	return 0;
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef complex<double> point;
#define F first
#define S second

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

struct sat2
{
	int n;
	vector<vector<int>> adj, radj;

	sat2(int n) : n(n), adj(2*n), radj(2*n) {}

	void add_edge(int u, int v)
	{
		adj[u].push_back(v);
		radj[v].push_back(u);
	}

	int neg(int u)
	{
		return 2*n-u-1;
	}

	void implication(int u, int v)
	{
		add_edge(u, v);
		add_edge(neg(v), neg(u));
	}

	vector<bool> value;

	bool solve()
	{
		vector<int> seen(2 * n);
		value.assign(2 * n, false);

		function<void(int, vector<vector<int>>&, vector<int>&)> visit =
				[&](int u, vector<vector<int>> &adj, vector<int> &vec)
		{
			seen[u] = true;
			for (int v : adj[u])
				if (!seen[v])
					visit(v, adj, vec);
			vec.push_back(u);
		};

		vector<int> order;

		for (int u = 0; u < n; ++u)
		{
			if (!seen[u]) visit(u, adj, order);
			if (!seen[neg(u)]) visit(neg(u), adj, order);
		}

		seen.assign(2 * n, false);
		reverse(order.begin(), order.end());

		vector<int> comp, id(2 * n);
		int cc = 0;

		for (int u : order)
			if (!seen[u])
			{
				comp.clear(); ++cc;
				visit(u, radj, comp);
				for (int v : comp)
					id[v] = cc;
			}

		for (int u = 0; u < n; ++u)
			if (id[u] == id[neg(u)]) return false;
			else value[u] = id[u] > id[neg(u)];

		return true;
	}
};

int main()
{
	#ifdef DGC
		//freopen("a.txt", "r", stdin);
		//freopen("b.txt", "w", stdout);
	#endif

	ios_base::sync_with_stdio(0), cin.tie(0);

	int n, m;
	cin >> n >> m;
	vector<vector<int>> a(n, vector<int>(m));

	for (auto &i : a)
		for (auto &j : i)
			cin >> j;

	for (int z = 0; z <= 2*(n+m); ++z)
	{
		sat2 sat(n+m);

		int temp = z;
		if (z > n+m)
		    z = uniform_int_distribution<int>(n+1+m, 2*(n+m))(rng);

		for (int i = 0; i < n; ++i)
			for (int j = 0; j < m; ++j)
			{
				int sh = temp < 1;
				sh ^= a[i][j];

				if (sh)
				{
					sat.implication(sat.neg(i), n+j);
					sat.implication(i, sat.neg(n+j));
				}
				else
				{
					sat.implication(i, n+j);
					sat.implication(n+j, i);
				}

				--temp;
			}

		if (sat.solve())
		{
			cout << "YES\n";
			for (int i = 0; i < n; ++i)
				cout << sat.value[i];
			cout << "\n";
			for (int i = 0; i < m; ++i)
				cout << sat.value[n+i];
			cout << "\n";
			return 0;
		}
	}

	cout << "NO\n";

	return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef vector<string> vs;
const double pi = acos(-1.0);
const int mod = 1000000007;
const int inf = 1000000000;
const double eps = 0.0000001;
#define rep(i,a,b) for(ll i=(a);i<(b);++i)

#define N 250
ll n,m;
ll a[N][N];
vl row, col;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>n>>m;
  row.resize(n);
  col.resize(m);
  rep(i,0,n)rep(j,0,m)cin>>a[i][j];
	rep(i,0,n){
    ll state = 0;
    ll init = -1;
    row.clear();
    rep(b,0,i){
      ll off = 0;
      rep(j,0,m){
        off += a[b][j] != a[1][j];
      }
      if (off == m) row[b]=1;
      if (off != 0 && off != m) goto loop;
    }
    rep(c,i+1,n){
      ll off = 0;
      rep(j,0,m){
        off += a[c][j] != (i > 0 ? !a[1][j] : a[n-1][j]);
      }
      if (off == m) row[c]=1;
      if (off != 0 && off != m) goto loop;
    }
    rep(j,0,n){
      ll bit = a[i][j]^(i > 0 ? a[1][j] : !a[n-1][j]);
      if (init == -1) init = bit;
      if (bit == init) {
        if (state == 1) {
          goto loop;
        }
      }
      else {
        if (state == 0) {
          state++;
        }
      }
    }
    row[i] = init;
    cout << "YES\n";
    rep(i,0,n)
    cout<<row[i];
    cout << "\n";
    rep(j,0,m)
    cout<<(i > 0 ? a[1][j] : !a[n-1][j]);
    return 0;
    loop:;
  }
  cout << "NO\n";

	return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef vector<string> vs;
const double pi = acos(-1.0);
const int mod = 1000000007;
const int inf = 1000000000;
const double eps = 0.0000001;
#define rep(i,a,b) for(ll i=(a);i<(b);++i)

#define N 250
ll n,m;
ll a[N][N];
vl row, col;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>n>>m;
  row.resize(n);
  col.resize(m);
  rep(i,0,n)rep(j,0,m)cin>>a[i][j];
	rep(i,0,n){
    ll state = 0;
    ll init = -1;
    row.clear();
    rep(b,0,i){
      ll off = 0;
      rep(j,0,m){
        off += a[b][j] != a[0][j];
      }
      if (off == m) row[b]=1;
      if (off != 0 && off != m) goto loop;
    }
    rep(c,i+1,n){
      ll off = 0;
      rep(j,0,m){
        off += a[c][j] != (i > 0 ? !a[0][j] : a[n-1][j]);
      }
      if (off == m) row[c]=1;
      if (off != 0 && off != m) goto loop;
    }
    rep(j,0,n){
      ll bit = a[i][j]^(i > 0 ? a[0][j] : !a[n-1][j]);
      if (init == -1) init = bit;
      if (bit == init) {
        if (state == 1) {
          goto loop;
        }
      }
      else {
        if (state == 0) {
          state++;
        }
      }
    }
    row[i] = init;
    cout << "YES\n";
    rep(i,0,n)
    cout<<row[i];
    cout << "\n";
    rep(j,0,m)
    cout<<(i > 0 ? a[0][j] : !a[n-1][j]);
    return 0;
    loop:;
  }
  cout << "NO\n";

	return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef vector<string> vs;
const double pi = acos(-1.0);
const int mod = 1000000007;
const int inf = 1000000000;
const double eps = 0.0000001;
#define rep(i,a,b) for(ll i=(a);i<(b);++i)

#define N 210
ll a[N][N];
ll n,m;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>n>>m;
  rep(i,0,n)rep(j,0,m)cin>>a[i][j];
  rep(i,0,n){
    ll state = 0;
    ll init = -1;
    rep(b,0,i){
      ll off = 0;
      rep(j,0,m){
        off += a[b][j] != a[0][j];
      }
      if (off != 0 && off != m) {
        goto loop;
      }
    }
    rep(c,i+1,n){
      ll off = 0;
      rep(j,0,m){
        off += a[c][j] != (i > 0 ? !a[0][j] : a[n-1][j]);
      }
      if (off != 0 && off != m) {
        goto loop;
      }
    }
    rep(j,0,m){
      ll bit = a[i][j] ^ (i > 0 ? a[0][j] : !a[n-1][j]);
      if (init == -1) {
        init = bit;
      }
      if (state == 0 && bit != init) {
        state++;
      }
      else if (state == 1 && bit == init) {
        goto loop;
      }
    }
    cout << "YES\n";
    rep(u,0,i) cout << (a[u][0] != a[0][0]);
    cout << init;
    rep(v,i+1,n) cout << (a[v][0] != (i > 0 ? !a[0][0] : a[n-1][0]));
    cout << "\n";
    rep(j,0,m) cout << (i > 0 ? a[0][j] != 0 : a[n-1][j]!= 1);
    cout << endl;
    return 0;
    loop:;
  }

  cout << "NO\n";

	return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef vector<string> vs;
const double pi = acos(-1.0);
const int mod = 1000000007;
const int inf = 1000000000;
const double eps = 0.0000001;
#define rep(i,a,b) for(ll i=(a);i<(b);++i)

#define N 200100
#define M 255
ll n,q,rel;
ll a[N];
string s;
ll nx[N][26];
ll last[26];
ll dp[M][M][M];
vi rline[3];

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>n>>q;
  cin>>s;
  rep(i,0,n){
    a[i]=s[i]-'a';
  }
  fill(begin(last),end(last),inf);
  rep(i,0,N)rep(j,0,26)nx[i][j]=inf;
  rep(i,0,n){
    last[a[n-1-i]]=n-1-i;
    rep(j,0,26){
      nx[n-1-i][j]=last[j]+1;
    }
  }
  rep(_q,0,q){
    cin>>s>>rel;
    if(s[0]=='+'){
      cin>>s;
      rline[rel-1].push_back(s[0]-'a');
    }
    else {
      rline[rel-1].pop_back();
    }
    rep(i,0,M)rep(j,0,M)rep(k,0,M)dp[i][j][k]=inf;
    dp[0][0][0]=0;
    rep(i,0,rline[0].size()+1)
    rep(j,0,rline[1].size()+1)
    rep(k,0,rline[2].size()+1){
      ll prev=dp[i][j][k];
      // cout << " i " << i << " j " << j << " k " << k << " is " << dp[i][j][k] << "\n";
      if(prev==inf)continue;
      if(i+1<=rline[0].size()) dp[i+1][j][k] = min(dp[i+1][j][k],nx[prev][rline[0][i]]);
      if(j+1<=rline[1].size()) dp[i][j+1][k] = min(dp[i][j+1][k],nx[prev][rline[1][j]]);
      if(k+1<=rline[2].size()) dp[i][j][k+1] = min(dp[i][j][k+1],nx[prev][rline[2][k]]);
    }
    outer:;
    cout<<(dp[rline[0].size()][rline[1].size()][rline[2].size()]<inf?"YES\n":"NO\n");
  }
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef vector<string> vs;
const double pi = acos(-1.0);
const int mod = 1000000007;
const int inf = 1000000000;
const double eps = 0.0000001;
#define rep(i,a,b) for(ll i=(a);i<(b);++i)

#define N 250
ll n,m;
ll a[N][N];
ll row[N];

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>n>>m;
  rep(i,0,n)rep(j,0,m)cin>>a[i][j];
	rep(i,0,n){
    ll state = 0;
    ll init = -1;
    memset(row, 0, sizeof(row));
    rep(b,0,i){
      ll off = 0;
      rep(j,0,m){
        off += a[b][j] != a[0][j];
      }
      if (off != 0 && off != m) goto loop;
      if (off == m) row[b]=1;
      //else row[b] = 0;
    }
    rep(c,i+1,n){
      ll off = 0;
      rep(j,0,m){
        off += a[c][j]^(i > 0 ? !a[0][j] : a[n-1][j]);
      }
      if (off != 0 && off != m) goto loop;
      if (off == m) row[c]=1;
      //else row[c] = 0;
    }
    rep(j,0,n){
      ll bit = a[i][j]^(i > 0 ? a[0][j] : !a[n-1][j]);
      if (init == -1) init = bit;
      else if (bit == init) {
        if (state == 1) {
          goto loop;
        }
      }
      else {
        if (state == 0) {
          state++;
        }
      }
    }
    row[i] = init;
    cout << "YES\n";
    rep(i_,0,n)
    cout<<row[i_];
    cout << "\n";
    rep(j_,0,m)
    cout<<(i > 0 ? a[0][j_] : !a[n-1][j_]);
    // cout << "\n\n";
    // rep(i_,0,n){rep(j_,0,m){
    //   cout << (row[i_]^(i > 0 ? a[0][j_] : !a[n-1][j_])^a[i_][j_]);
    // }cout<<endl;}
    return 0;
    loop:;
  }
  cout << "NO\n";

	return 0;
}