/// IN THE NAME OF METAL
#include <bits/stdc++.h>

using namespace std;

typedef long long int ll;
typedef pair<ll, ll> pll;

#define sz(x)                       (ll) x.size()
#define all(x)                      (x).begin(),(x).end()
#define F                           first
#define S                           second

ll Pow(ll a, ll b, ll md, ll ans = 1) {
    for (; b; b >>= 1, a = a * a % md)
        if (b & 1)
            ans = ans * a % md;
    return ans % md;
}

const ll MAXN = 2e3 + 10;
const ll INF = 8e18;
const ll MOD = 1e9 + 7;
ll n, m, ans[MAXN], par[MAXN], Sz[MAXN], mark[MAXN], deg[MAXN];
vector<ll> adj[MAXN];
char A[MAXN][MAXN];

ll Find(ll v) {
    return par[v] == -1 ? v : par[v] = Find(par[v]);
}

ll Union(ll u,ll v) {
    u = Find(u), v = Find(v);
    if (u == v) return 0;
    if (Sz[v] < Sz[u]) swap(u, v);
    par[u] = v;
    Sz[v] += Sz[u];
    return 1;
}

void DFS(ll v, ll id) {
    mark[v] = 1;
    ans[v] = id;
    for (ll u : adj[v]) {
        if (mark[u]) continue;
        DFS(u, id + 1);
    }
}

ll Topo() {
    queue<ll> Q;
    vector<ll> ts;
    for (ll i = 1; i <= n + m; i++) {
        if (deg[i] == 0) Q.push(i), ans[i] = 1;
    }
    while (sz(Q)) {
        ll v = Q.front();
        Q.pop();
        ts.push_back(v);
        for (ll u : adj[v]) {
            deg[u]--;
            if (deg[u] == 0) Q.push(u), ans[u] = ans[v] + 1;
        }
    }
    return sz(ts) != n + m;
}

int main() {
    fill(par, par + MAXN, -1);
    fill(Sz, Sz + MAXN, 1);
    scanf("%lld%lld", &n, &m);
    for (ll i = 1; i <= n; i++) {
        for (ll j = 1; j <= m; j++) {
            cin >> A[i][j];
        }
    }
    for (ll i = 1; i <= n; i++) {
        for (ll j = 1; j <= m; j++) {
            if (A[i][j] == '=') Union(i, n + j);
        }
    }
    for (ll i = 1; i <= n; i++) {
        for (ll j = 1; j <= m; j++) {
            if (A[i][j] == '=') continue;
            //if (Find(i) == Find(n + j)) return !printf("No\n");
            if (A[i][j] == '<') adj[Find(i)].push_back(Find(j + n)), deg[j + n]++;
            if (A[i][j] == '>') adj[Find(j + n)].push_back(Find(i)), deg[i]++;
        }
    }
    if (Topo()) return !printf("No\n");
    printf("Yes\n");
    for (ll i = 1; i <= n + m; i++) {
        printf("%lld ", ans[Find(i)]);
        if (i == n) printf("\n");
    }
    return 0;
}


/// IN THE NAME OF METAL
#include <bits/stdc++.h>

using namespace std;

typedef long long int ll;
typedef pair<ll, ll> pll;

#define sz(x)                       (ll) x.size()
#define all(x)                      (x).begin(),(x).end()
#define F                           first
#define S                           second

ll Pow(ll a, ll b, ll md, ll ans = 1) {
    for (; b; b >>= 1, a = a * a % md)
        if (b & 1)
            ans = ans * a % md;
    return ans % md;
}

const ll MAXN = 5e3 + 10;
const ll INF = 8e18;
const ll MOD = 1e9 + 7;
ll n, m, ans[MAXN], par[MAXN], Sz[MAXN], mark[MAXN], deg[MAXN];
vector<ll> adj[MAXN];
char A[MAXN][MAXN];

ll Find(ll v) {
    return par[v] == -1 ? v : par[v] = Find(par[v]);
}

ll Union(ll u,ll v) {
    u = Find(u), v = Find(v);
    if (u == v) return 0;
    if (Sz[v] < Sz[u]) swap(u, v);
    par[u] = v;
    Sz[v] += Sz[u];
    return 1;
}

void DFS(ll v, ll id) {
    mark[v] = 1;
    ans[v] = id;
    for (ll u : adj[v]) {
        if (mark[u]) continue;
        DFS(u, id + 1);
    }
}

ll Topo() {
    queue<ll> Q;
    vector<ll> ts;
    ll cnt = 0;
    for (ll i = 1; i <= n + m; i++) {
        if (i == Find(i)) cnt++;
        if (deg[i] == 0 && (i == Find(i))) Q.push(i), ans[i] = 1;
    }
    while (sz(Q)) {
        ll v = Q.front();
        Q.pop();
        ts.push_back(v);
        for (ll u : adj[v]) {
            deg[u]--;
            if (deg[u] == 0) Q.push(u), ans[u] = ans[v] + 1;
        }
    }
    return sz(ts) != cnt;
}

int main() {
    fill(par, par + MAXN, -1);
    fill(Sz, Sz + MAXN, 1);
    scanf("%lld%lld", &n, &m);
    for (ll i = 1; i <= n; i++) {
        scanf("%s", A[i] + 1);
    }
    for (ll i = 1; i <= n; i++) {
        for (ll j = 1; j <= m; j++) {
            if (A[i][j] == '=') Union(i, n + j);
        }
    }
    for (ll i = 1; i <= n; i++) {
        for (ll j = 1; j <= m; j++) {
            if (A[i][j] == '=') continue;
            if (Find(i) == Find(n + j)) return !printf("No\n");
            if (A[i][j] == '<') adj[Find(i)].push_back(Find(j + n)), deg[j + n]++;
            if (A[i][j] == '>') adj[Find(j + n)].push_back(Find(i)), deg[i]++;
        }
    }
    if (Topo()) return !printf("No\n");
    printf("Yes\n");
    for (ll i = 1; i <= n + m; i++) {
        printf("%lld ", ans[Find(i)]);
        if (i == n) printf("\n");
    }
    return 0;
}


#include<bits/stdc++.h>
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define int long long
#define endl "\n"
#define mod 1000000007
#define mod2 998244353
#define double long double
#define pb push_back
#define swap(x,y) (x^=y^=x^=y)
#define TC int TESTCASE;cin>>TESTCASE;while(TESTCASE--)
#define oo 1500000000000000000
#define mem(a,b) memset(a,b,sizeof(a))
#define debug1(a) cerr<<#a<<" = "<<(a)<<endl;
#define debug2(a,b) cerr<<#a<<" = "<<(a)<<", "<<#b<<" = "<<(b)<<endl;
#define debug3(a,b,c) cerr<<#a<<" = "<<(a)<<", "<<#b<<" = "<<(b)<<", "<<#c<<" = "<<(c)<<endl;
#define debug4(a,b,c,d) cerr<<#a<<" = "<<(a)<<", "<<#b<<" = "<<(b)<<", "<<#c<<" = "<<(c)<<", "<<#d<<" = "<<(d)<<endl;
using namespace std;

int modexpo(int x,int p){
    int res = 1;x = x%mod;
    while(p){
        if(p%2)res = res * x;
        p >>= 1;
        x = x*x % mod;
        res %= mod;
    }
    return res;
}

int max(int a,int b){return (a>b?a:b);}

int min(int a,int b){return (a<b?a:b);}

struct edge{int u,v,w;edge(int a,int b,int c){u=a;v=b;w=c;}};

struct compare{
    bool operator() (const edge a, const edge b) const{
        if(a.u == b.u){
            if(a.v == b.v){
                return a.w < b.w;
            }
            return a.v < b.v;
        }
        return a.u < b.u;
    }
};

const int nax = 1e3 + 5;
int arr[nax][nax];
vector<int>g[2*nax];
int n, m, cycle, parent[2*nax], sz[2*nax];
int val[2*nax], vis[2*nax], ret[2*nax], indeg[2*nax];

int find(int x){
    if(x == parent[x]){
        return x;
    }
    return parent[x] = find(parent[x]);
}

void uni(int a,int b){
    a = find(a);
    b = find(b);
    if(a == b){
        return;
    }
    if(sz[a] >= sz[b]){
        parent[b] = a;
        sz[a] += sz[b];
    }
    else{
        parent[a] = b;
        sz[b] += sz[a];
    }
}

void dfs(int x, int cnt){
    vis[x] = 1;
    ret[x] = 1;
    val[x] = max(val[x], cnt);
    for(int i : g[x]){
        if(!vis[i]){
            dfs(i,cnt+1);
        }
        else if(ret[i]){
            cycle = 1;
        }
    }
    ret[x] = 0;
}

int32_t main(){
    IOS
    cin >> n >> m;
    for(int i = 0; i <= n+m; i++){
        parent[i] = i;
        sz[i] = 1;
    }
    for(int i = 1; i <= n; i++){
        for(int j = 1; j <= m; j++){
            char c;
            cin >> c;
            if(c == '='){
                arr[i][j] = 1;
                uni(i,n+j);
            }
            else if(c == '<'){
                arr[i][j] = 0;
            }
            else{
                arr[i][j] = 2;
            }
        }
    }
    for(int i = 1; i <= n; i++){
        for(int j = 1; j <= m; j++){
            if(arr[i][j] == 0){
                if(find(i) == find(n+j)){
                    cycle = 1;
                }
                g[find(n+j)].pb(find(i));
            }
            else if(arr[i][j] == 2){
                if(find(i) == find(n+j)){
                    cycle = 1;
                }
                g[find(i)].pb(find(n+j));
            }
        }
    }
    for(int i = 1; i <= n+m; i++){
        if(!vis[i]){
            dfs(i,1);
        }
    }
    if(cycle){
        cout << "No" << endl;
        return 0;
    }

    cout << "Yes" << endl;
    for(int i = 1; i <= n+m; i++){
        cout << val[find(i)] << " ";
    }
    cout << endl;
}


#include<bits/stdc++.h>
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define int long long
#define endl "\n"
#define mod 1000000007
#define mod2 998244353
#define double long double
#define pb push_back
#define swap(x,y) (x^=y^=x^=y)
#define TC int TESTCASE;cin>>TESTCASE;while(TESTCASE--)
#define oo 1500000000000000000
#define mem(a,b) memset(a,b,sizeof(a))
#define debug1(a) cerr<<#a<<" = "<<(a)<<endl;
#define debug2(a,b) cerr<<#a<<" = "<<(a)<<", "<<#b<<" = "<<(b)<<endl;
#define debug3(a,b,c) cerr<<#a<<" = "<<(a)<<", "<<#b<<" = "<<(b)<<", "<<#c<<" = "<<(c)<<endl;
#define debug4(a,b,c,d) cerr<<#a<<" = "<<(a)<<", "<<#b<<" = "<<(b)<<", "<<#c<<" = "<<(c)<<", "<<#d<<" = "<<(d)<<endl;
using namespace std;

int modexpo(int x,int p){
    int res = 1;x = x%mod;
    while(p){
        if(p%2)res = res * x;
        p >>= 1;
        x = x*x % mod;
        res %= mod;
    }
    return res;
}

int max(int a,int b){return (a>b?a:b);}

int min(int a,int b){return (a<b?a:b);}

struct edge{int u,v,w;edge(int a,int b,int c){u=a;v=b;w=c;}};

struct compare{
    bool operator() (const edge a, const edge b) const{
        if(a.u == b.u){
            if(a.v == b.v){
                return a.w < b.w;
            }
            return a.v < b.v;
        }
        return a.u < b.u;
    }
};

const int nax = 1e3 + 5;
int arr[nax][nax];
vector<int>g[2*nax];
int n, m, cycle, parent[2*nax], sz[2*nax];
int val[2*nax], vis[2*nax], ret[2*nax];

int find(int x){
    if(x == parent[x]){
        return x;
    }
    return parent[x] = find(parent[x]);
}

void uni(int a,int b){
    a = find(a);
    b = find(b);
    if(a == b){
        return;
    }
    if(sz[a] >= sz[b]){
        parent[b] = a;
        sz[a] += sz[b];
    }
    else{
        parent[a] = b;
        sz[b] += sz[a];
    }
}

void dfs(int x, int cnt){
    vis[x] = 1;
    ret[x] = 1;
    val[x] = max(val[x], cnt);
    for(int i : g[x]){
        if(!vis[i]){
            dfs(i,cnt+1);
        }
        else if(ret[i]){
            cycle = 1;
        }
    }
    ret[x] = 0;
}

int32_t main(){
    IOS
    cin >> n >> m;
    for(int i = 0; i <= n+m; i++){
        parent[i] = i;
        sz[i] = 1;
    }
    for(int i = 1; i <= n; i++){
        for(int j = 1; j <= m; j++){
            char c;
            cin >> c;
            if(c == '='){
                arr[i][j] = 1;
                uni(i,n+j);
            }
            else if(c == '<'){
                arr[i][j] = 0;
            }
            else{
                arr[i][j] = 2;
            }
        }
    }
    for(int i = 1; i <= n; i++){
        for(int j = 1; j <= m; j++){
            if(arr[i][j] == 0){
                if(find(i) == find(n+j)){
                    cycle = 1;
                }
                g[i].pb(n+j);
            }
            else if(arr[i][j] == 2){
                if(find(i) == find(n+j)){
                    cycle = 1;
                }
                g[n+j].pb(i);
            }
        }
    }
    for(int i = 1; i <= n+m; i++){
        if(vis[i] == 0 && g[i].size()){
            dfs(i,1);
        }
    }
    if(cycle){
        cout << "No" << endl;
    }
    else{
        cout << "Yes" << endl;
        for(int i = 1; i <= n+m; i++){
            if(val[i] == 0){
                int k = find(i);
                if(val[k] == 0){
                    val[k] = 1;
                }
                val[i] = val[k];

            }
            cout << val[i] << " ";
        }
        cout << endl;
    }
}


#include<bits/stdc++.h>
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define int long long
#define endl "\n"
#define mod 1000000007
#define mod2 998244353
#define double long double
#define pb push_back
#define swap(x,y) (x^=y^=x^=y)
#define TC int TESTCASE;cin>>TESTCASE;while(TESTCASE--)
#define oo 1500000000000000000
#define mem(a,b) memset(a,b,sizeof(a))
#define debug1(a) cerr<<#a<<" = "<<(a)<<endl;
#define debug2(a,b) cerr<<#a<<" = "<<(a)<<", "<<#b<<" = "<<(b)<<endl;
#define debug3(a,b,c) cerr<<#a<<" = "<<(a)<<", "<<#b<<" = "<<(b)<<", "<<#c<<" = "<<(c)<<endl;
#define debug4(a,b,c,d) cerr<<#a<<" = "<<(a)<<", "<<#b<<" = "<<(b)<<", "<<#c<<" = "<<(c)<<", "<<#d<<" = "<<(d)<<endl;
using namespace std;

int modexpo(int x,int p){
    int res = 1;x = x%mod;
    while(p){
        if(p%2)res = res * x;
        p >>= 1;
        x = x*x % mod;
        res %= mod;
    }
    return res;
}

int max(int a,int b){return (a>b?a:b);}

int min(int a,int b){return (a<b?a:b);}

struct edge{int u,v,w;edge(int a,int b,int c){u=a;v=b;w=c;}};

struct compare{
    bool operator() (const edge a, const edge b) const{
        if(a.u == b.u){
            if(a.v == b.v){
                return a.w < b.w;
            }
            return a.v < b.v;
        }
        return a.u < b.u;
    }
};

const int nax = 1e3 + 5;
int arr[nax][nax];
vector<int>g[2*nax];
int n, m, cycle, parent[2*nax], sz[2*nax];
int val[2*nax], vis[2*nax], ret[2*nax];

int find(int x){
    if(x == parent[x]){
        return x;
    }
    return parent[x] = find(parent[x]);
}

void uni(int a,int b){
    a = find(a);
    b = find(b);
    if(a == b){
        return;
    }
    if(sz[a] >= sz[b]){
        parent[b] = a;
        sz[a] += sz[b];
    }
    else{
        parent[a] = b;
        sz[b] += sz[a];
    }
}

void dfs(int x, int cnt){
    vis[x] = 1;
    ret[x] = 1;
    val[x] = max(val[x], cnt);
    for(int i : g[x]){
        if(!vis[i]){
            dfs(i,cnt+1);
        }
        else if(ret[i]){
            cycle = 1;
        }
    }
    ret[x] = 0;
}

int32_t main(){
    IOS
    cin >> n >> m;
    for(int i = 0; i <= n+m; i++){
        parent[i] = i;
        sz[i] = 1;
    }
    for(int i = 1; i <= n; i++){
        for(int j = 1; j <= m; j++){
            char c;
            cin >> c;
            if(c == '='){
                arr[i][j] = 1;
                uni(i,n+j);
            }
            else if(c == '<'){
                arr[i][j] = 0;
            }
            else{
                arr[i][j] = 2;
            }
        }
    }
    for(int i = 1; i <= n; i++){
        for(int j = 1; j <= m; j++){
            if(arr[i][j] == 0){
                if(find(i) == find(n+j)){
                    cycle = 1;
                }
                g[i].pb(n+j);
            }
            else if(arr[i][j] == 2){
                if(find(i) == find(n+j)){
                    cycle = 1;
                }
                g[n+j].pb(i);
            }
        }
    }
    for(int i = 1; i <= n+m; i++){
        if(vis[i] == 0 && g[i].size()){
            dfs(i,1);
        }
    }
    if(cycle){
        cout << "No" << endl;
    }
    else{
        cout << "Yes" << endl;
        for(int i = 1; i <= n+m; i++){
            if(val[i] == 0){
                val[i] = val[find(i)];
            }
            cout << val[i] << " ";
        }
        cout << endl;
    }
}


#include<bits/stdc++.h>
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define int long long
#define endl "\n"
#define mod 1000000007
#define mod2 998244353
#define double long double
#define pb push_back
#define swap(x,y) (x^=y^=x^=y)
#define TC int TESTCASE;cin>>TESTCASE;while(TESTCASE--)
#define oo 1500000000000000000
#define mem(a,b) memset(a,b,sizeof(a))
#define debug1(a) cerr<<#a<<" = "<<(a)<<endl;
#define debug2(a,b) cerr<<#a<<" = "<<(a)<<", "<<#b<<" = "<<(b)<<endl;
#define debug3(a,b,c) cerr<<#a<<" = "<<(a)<<", "<<#b<<" = "<<(b)<<", "<<#c<<" = "<<(c)<<endl;
#define debug4(a,b,c,d) cerr<<#a<<" = "<<(a)<<", "<<#b<<" = "<<(b)<<", "<<#c<<" = "<<(c)<<", "<<#d<<" = "<<(d)<<endl;
using namespace std;

int modexpo(int x,int p){
    int res = 1;x = x%mod;
    while(p){
        if(p%2)res = res * x;
        p >>= 1;
        x = x*x % mod;
        res %= mod;
    }
    return res;
}

int max(int a,int b){return (a>b?a:b);}

int min(int a,int b){return (a<b?a:b);}

struct edge{int u,v,w;edge(int a,int b,int c){u=a;v=b;w=c;}};

struct compare{
    bool operator() (const edge a, const edge b) const{
        if(a.u == b.u){
            if(a.v == b.v){
                return a.w < b.w;
            }
            return a.v < b.v;
        }
        return a.u < b.u;
    }
};

const int nax = 1e3 + 5;
int arr[nax][nax];
vector<int>g[2*nax];
int n, m, cycle, parent[2*nax], sz[2*nax];
int val[2*nax], vis[2*nax], ret[2*nax], indeg[2*nax];

int find(int x){
    if(x == parent[x]){
        return x;
    }
    return parent[x] = find(parent[x]);
}

void uni(int a,int b){
    a = find(a);
    b = find(b);
    if(a == b){
        return;
    }
    if(sz[a] >= sz[b]){
        parent[b] = a;
        sz[a] += sz[b];
    }
    else{
        parent[a] = b;
        sz[b] += sz[a];
    }
}

void dfs(int x, int cnt){
    vis[x] = 1;
    ret[x] = 1;
    val[x] = 1;
    for(int i : g[x]){
        if(!vis[i]){
            dfs(i,cnt+1);
        }
        else if(ret[i]){
            cycle = 1;
        }
        val[x] = max(val[x], val[i] + 1);
    }
    ret[x] = 0;
}

int32_t main(){
    IOS
    cin >> n >> m;
    for(int i = 0; i <= n+m; i++){
        parent[i] = i;
        sz[i] = 1;
    }
    for(int i = 1; i <= n; i++){
        for(int j = 1; j <= m; j++){
            char c;
            cin >> c;
            if(c == '='){
                arr[i][j] = 1;
                uni(i,n+j);
            }
            else if(c == '<'){
                arr[i][j] = 0;
            }
            else{
                arr[i][j] = 2;
            }
        }
    }
    for(int i = 1; i <= n; i++){
        for(int j = 1; j <= m; j++){
            if(arr[i][j] == 0){
                if(find(i) == find(n+j)){
                    cycle = 1;
                }
                g[find(n+j)].pb(find(i));
            }
            else if(arr[i][j] == 2){
                if(find(i) == find(n+j)){
                    cycle = 1;
                }
                g[find(i)].pb(find(n+j));
            }
        }
    }
    for(int i = 1; i <= n+m; i++){
        if(!vis[i]){
            dfs(i,1);
        }
    }
    if(cycle){
        cout << "No" << endl;
        return 0;
    }

    cout << "Yes" << endl;
    for(int i = 1; i <= n+m; i++){
        cout << val[find(i)] << " ";
    }
    cout << endl;
}


#include<bits/stdc++.h>
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define int long long
#define endl "\n"
#define mod 1000000007
#define mod2 998244353
#define double long double
#define pb push_back
#define swap(x,y) (x^=y^=x^=y)
#define TC int TESTCASE;cin>>TESTCASE;while(TESTCASE--)
#define oo 1500000000000000000
#define mem(a,b) memset(a,b,sizeof(a))
#define debug1(a) cerr<<#a<<" = "<<(a)<<endl;
#define debug2(a,b) cerr<<#a<<" = "<<(a)<<", "<<#b<<" = "<<(b)<<endl;
#define debug3(a,b,c) cerr<<#a<<" = "<<(a)<<", "<<#b<<" = "<<(b)<<", "<<#c<<" = "<<(c)<<endl;
#define debug4(a,b,c,d) cerr<<#a<<" = "<<(a)<<", "<<#b<<" = "<<(b)<<", "<<#c<<" = "<<(c)<<", "<<#d<<" = "<<(d)<<endl;
using namespace std;

int modexpo(int x,int p){
    int res = 1;x = x%mod;
    while(p){
        if(p%2)res = res * x;
        p >>= 1;
        x = x*x % mod;
        res %= mod;
    }
    return res;
}

int max(int a,int b){return (a>b?a:b);}

int min(int a,int b){return (a<b?a:b);}

struct edge{int u,v,w;edge(int a,int b,int c){u=a;v=b;w=c;}};

struct compare{
    bool operator() (const edge a, const edge b) const{
        if(a.u == b.u){
            if(a.v == b.v){
                return a.w < b.w;
            }
            return a.v < b.v;
        }
        return a.u < b.u;
    }
};

const int nax = 1e3 + 5;
int arr[nax][nax];
vector<int>g[2*nax];
int n, m, cycle, parent[2*nax], sz[2*nax];
int val[2*nax], vis[2*nax], ret[2*nax];

int find(int x){
    if(x == parent[x]){
        return x;
    }
    return parent[x] = find(parent[x]);
}

void uni(int a,int b){
    a = find(a);
    b = find(b);
    if(a == b){
        return;
    }
    if(sz[a] >= sz[b]){
        parent[b] = a;
        sz[a] += sz[b];
    }
    else{
        parent[a] = b;
        sz[b] += sz[a];
    }
}

void dfs(int x, int cnt){
    vis[x] = 1;
    ret[x] = 1;
    val[x] = max(val[x], cnt);
    for(int i : g[x]){
        if(!vis[i]){
            dfs(i,cnt+1);
        }
        else if(ret[i]){
            cycle = 1;
        }
    }
    ret[x] = 0;
}

int32_t main(){
    IOS
    cin >> n >> m;
    for(int i = 0; i <= n+m; i++){
        parent[i] = i;
        sz[i] = 1;
    }
    for(int i = 1; i <= n; i++){
        for(int j = 1; j <= m; j++){
            char c;
            cin >> c;
            if(c == '='){
                arr[i][j] = 1;
                uni(i,n+j);
            }
            else if(c == '<'){
                arr[i][j] = 0;
            }
            else{
                arr[i][j] = 2;
            }
        }
    }
    for(int i = 1; i <= n; i++){
        for(int j = 1; j <= m; j++){
            if(arr[i][j] == 0){
                if(find(i) == find(j)){
                    cycle = 1;
                }
                g[i].pb(n+j);
            }
            else if(arr[i][j] == 2){
                if(find(i) == find(j)){
                    cycle = 1;
                }
                g[n+j].pb(i);
            }
        }
    }
    for(int i = 1; i <= n+m; i++){
        if(vis[i] == 0 && g[i].size()){
            dfs(i,1);
        }
    }
    if(cycle){
        cout << "No" << endl;
    }
    else{
        cout << "Yes" << endl;
        for(int i = 1; i <= n+m; i++){
            cout << val[i] << " ";
        }
        cout << endl;
    }
}


#include<bits/stdc++.h>
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define int long long
#define endl "\n"
#define mod 1000000007
#define mod2 998244353
#define double long double
#define pb push_back
#define swap(x,y) (x^=y^=x^=y)
#define TC int TESTCASE;cin>>TESTCASE;while(TESTCASE--)
#define oo 1500000000000000000
#define mem(a,b) memset(a,b,sizeof(a))
#define debug1(a) cerr<<#a<<" = "<<(a)<<endl;
#define debug2(a,b) cerr<<#a<<" = "<<(a)<<", "<<#b<<" = "<<(b)<<endl;
#define debug3(a,b,c) cerr<<#a<<" = "<<(a)<<", "<<#b<<" = "<<(b)<<", "<<#c<<" = "<<(c)<<endl;
#define debug4(a,b,c,d) cerr<<#a<<" = "<<(a)<<", "<<#b<<" = "<<(b)<<", "<<#c<<" = "<<(c)<<", "<<#d<<" = "<<(d)<<endl;
using namespace std;

int modexpo(int x,int p){
    int res = 1;x = x%mod;
    while(p){
        if(p%2)res = res * x;
        p >>= 1;
        x = x*x % mod;
        res %= mod;
    }
    return res;
}

int max(int a,int b){return (a>b?a:b);}

int min(int a,int b){return (a<b?a:b);}

struct edge{int u,v,w;edge(int a,int b,int c){u=a;v=b;w=c;}};

struct compare{
    bool operator() (const edge a, const edge b) const{
        if(a.u == b.u){
            if(a.v == b.v){
                return a.w < b.w;
            }
            return a.v < b.v;
        }
        return a.u < b.u;
    }
};

const int nax = 1e3 + 5;
int arr[nax][nax];
vector<int>g[2*nax];
int n, m, cycle, parent[2*nax], sz[2*nax];
int val[2*nax], vis[2*nax], ret[2*nax], indeg[2*nax];

int find(int x){
    if(x == parent[x]){
        return x;
    }
    return parent[x] = find(parent[x]);
}

void uni(int a,int b){
    a = find(a);
    b = find(b);
    if(a == b){
        return;
    }
    if(sz[a] >= sz[b]){
        parent[b] = a;
        sz[a] += sz[b];
    }
    else{
        parent[a] = b;
        sz[b] += sz[a];
    }
}

void dfs(int x, int cnt){
    vis[x] = 1;
    ret[x] = 1;
    // val[x] = max(val[x], cnt);
    for(int i : g[x]){
        if(!vis[i]){
            dfs(i,cnt+1);
        }
        else if(ret[i]){
            cycle = 1;
        }
    }
    ret[x] = 0;
}

int32_t main(){
    IOS
    cin >> n >> m;
    for(int i = 0; i <= n+m; i++){
        parent[i] = i;
        sz[i] = 1;
    }
    for(int i = 1; i <= n; i++){
        for(int j = 1; j <= m; j++){
            char c;
            cin >> c;
            if(c == '='){
                arr[i][j] = 1;
                uni(i,n+j);
            }
            else if(c == '<'){
                arr[i][j] = 0;
            }
            else{
                arr[i][j] = 2;
            }
        }
    }
    for(int i = 1; i <= n; i++){
        for(int j = 1; j <= m; j++){
            if(arr[i][j] == 0){
                if(find(i) == find(n+j)){
                    cycle = 1;
                }
                g[find(i)].pb(find(n+j));
            }
            else if(arr[i][j] == 2){
                if(find(i) == find(n+j)){
                    cycle = 1;
                }
                g[find(n+j)].pb(find(i));
            }
        }
    }
    set<pair<int,int>>q;
    for(int i = 1; i <= n+m; i++){
        if(indeg[i] == 0 && g[i].size() && !vis[i]){
            dfs(i,1);
            q.insert({1,i});
        }
    }
    if(cycle){
        cout << "No" << endl;
        return 0;
    }
    mem(vis,0);
    while(!q.empty()){
        auto x = *q.begin();
        val[x.second] = x.first;
        vis[x.second] = 1;
        q.erase(q.begin());
        for(int i : g[x.second]){
            if(vis[i]){
                continue;
            }
            q.erase({val[i],i});
            val[i] = max(val[i], x.first+1);
            q.insert({val[i],i});
        }
    }

    cout << "Yes" << endl;
    for(int i = 1; i <= n+m; i++){
        if(val[i] == 0){
            int k = find(i);
            if(val[k] == 0){
                val[k] = 1;
            }
            val[i] = val[k];

        }
        cout << val[i] << " ";
    }
    cout << endl;
}


#include<bits/stdc++.h>
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define int long long
#define endl "\n"
#define mod 1000000007
#define mod2 998244353
#define double long double
#define pb push_back
#define swap(x,y) (x^=y^=x^=y)
#define TC int TESTCASE;cin>>TESTCASE;while(TESTCASE--)
#define oo 1500000000000000000
#define mem(a,b) memset(a,b,sizeof(a))
#define debug1(a) cerr<<#a<<" = "<<(a)<<endl;
#define debug2(a,b) cerr<<#a<<" = "<<(a)<<", "<<#b<<" = "<<(b)<<endl;
#define debug3(a,b,c) cerr<<#a<<" = "<<(a)<<", "<<#b<<" = "<<(b)<<", "<<#c<<" = "<<(c)<<endl;
#define debug4(a,b,c,d) cerr<<#a<<" = "<<(a)<<", "<<#b<<" = "<<(b)<<", "<<#c<<" = "<<(c)<<", "<<#d<<" = "<<(d)<<endl;
using namespace std;

int modexpo(int x,int p){
    int res = 1;x = x%mod;
    while(p){
        if(p%2)res = res * x;
        p >>= 1;
        x = x*x % mod;
        res %= mod;
    }
    return res;
}

int max(int a,int b){return (a>b?a:b);}

int min(int a,int b){return (a<b?a:b);}

struct edge{int u,v,w;edge(int a,int b,int c){u=a;v=b;w=c;}};

struct compare{
    bool operator() (const edge a, const edge b) const{
        if(a.u == b.u){
            if(a.v == b.v){
                return a.w < b.w;
            }
            return a.v < b.v;
        }
        return a.u < b.u;
    }
};

const int nax = 1e3 + 5;
int arr[nax][nax];
vector<int>g[2*nax];
int n, m, cycle, parent[2*nax], sz[2*nax];
int val[2*nax], vis[2*nax], ret[2*nax], indeg[2*nax];

int find(int x){
    if(x == parent[x]){
        return x;
    }
    return parent[x] = find(parent[x]);
}

void uni(int a,int b){
    a = find(a);
    b = find(b);
    if(a == b){
        return;
    }
    if(sz[a] >= sz[b]){
        parent[b] = a;
        sz[a] += sz[b];
    }
    else{
        parent[a] = b;
        sz[b] += sz[a];
    }
}

void dfs(int x, int cnt){
    vis[x] = 1;
    ret[x] = 1;
    // val[x] = max(val[x], cnt);
    for(int i : g[x]){
        if(!vis[i]){
            dfs(i,cnt+1);
        }
        else if(ret[i]){
            cycle = 1;
        }
    }
    ret[x] = 0;
}

int32_t main(){
    IOS
    cin >> n >> m;
    for(int i = 0; i <= n+m; i++){
        parent[i] = i;
        sz[i] = 1;
    }
    for(int i = 1; i <= n; i++){
        for(int j = 1; j <= m; j++){
            char c;
            cin >> c;
            if(c == '='){
                arr[i][j] = 1;
                uni(i,n+j);
            }
            else if(c == '<'){
                arr[i][j] = 0;
            }
            else{
                arr[i][j] = 2;
            }
        }
    }
    for(int i = 1; i <= n; i++){
        for(int j = 1; j <= m; j++){
            if(arr[i][j] == 0){
                if(find(i) == find(n+j)){
                    cycle = 1;
                }
                g[find(i)].pb(find(n+j));
            }
            else if(arr[i][j] == 2){
                if(find(i) == find(n+j)){
                    cycle = 1;
                }
                g[find(n+j)].pb(find(i));
            }
        }
    }
    set<pair<int,int>>q;
    for(int i = 1; i <= n+m; i++){
        if(indeg[i] == 0 && g[i].size() && !vis[i]){
            dfs(i,1);
            q.insert({1,i});
        }
    }
    if(cycle){
        cout << "No" << endl;
        return 0;
    }
    while(!q.empty()){
        auto x = *q.begin();
        val[x.second] = x.first;
        q.erase(q.begin());
        for(int i : g[x.second]){
            q.erase({val[i],i});
            val[i] = max(val[i], x.first+1);
            q.insert({val[i],i});
        }
    }

    cout << "Yes" << endl;
    for(int i = 1; i <= n+m; i++){
        if(val[i] == 0){
            int k = find(i);
            if(val[k] == 0){
                val[k] = 1;
            }
            val[i] = val[k];

        }
        cout << val[i] << " ";
    }
    cout << endl;
}


#include<bits/stdc++.h>
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define int long long
#define endl "\n"
#define mod 1000000007
#define mod2 998244353
#define double long double
#define pb push_back
#define swap(x,y) (x^=y^=x^=y)
#define TC int TESTCASE;cin>>TESTCASE;while(TESTCASE--)
#define oo 1500000000000000000
#define mem(a,b) memset(a,b,sizeof(a))
#define debug1(a) cerr<<#a<<" = "<<(a)<<endl;
#define debug2(a,b) cerr<<#a<<" = "<<(a)<<", "<<#b<<" = "<<(b)<<endl;
#define debug3(a,b,c) cerr<<#a<<" = "<<(a)<<", "<<#b<<" = "<<(b)<<", "<<#c<<" = "<<(c)<<endl;
#define debug4(a,b,c,d) cerr<<#a<<" = "<<(a)<<", "<<#b<<" = "<<(b)<<", "<<#c<<" = "<<(c)<<", "<<#d<<" = "<<(d)<<endl;
using namespace std;

int modexpo(int x,int p){
    int res = 1;x = x%mod;
    while(p){
        if(p%2)res = res * x;
        p >>= 1;
        x = x*x % mod;
        res %= mod;
    }
    return res;
}

int max(int a,int b){return (a>b?a:b);}

int min(int a,int b){return (a<b?a:b);}

struct edge{int u,v,w;edge(int a,int b,int c){u=a;v=b;w=c;}};

struct compare{
    bool operator() (const edge a, const edge b) const{
        if(a.u == b.u){
            if(a.v == b.v){
                return a.w < b.w;
            }
            return a.v < b.v;
        }
        return a.u < b.u;
    }
};

const int nax = 1e3 + 5;
int arr[nax][nax];
vector<int>g[2*nax];
int n, m, cycle, parent[2*nax], sz[2*nax];
int val[2*nax], vis[2*nax], ret[2*nax], indeg[2*nax];

int find(int x){
    if(x == parent[x]){
        return x;
    }
    return parent[x] = find(parent[x]);
}

void uni(int a,int b){
    a = find(a);
    b = find(b);
    if(a == b){
        return;
    }
    if(sz[a] >= sz[b]){
        parent[b] = a;
        sz[a] += sz[b];
    }
    else{
        parent[a] = b;
        sz[b] += sz[a];
    }
}

void dfs(int x, int cnt){
    vis[x] = 1;
    ret[x] = 1;
    // val[x] = max(val[x], cnt);
    for(int i : g[x]){
        if(!vis[i]){
            dfs(i,cnt+1);
        }
        else if(ret[i]){
            cycle = 1;
        }
    }
    ret[x] = 0;
}

int32_t main(){
    IOS
    cin >> n >> m;
    for(int i = 0; i <= n+m; i++){
        parent[i] = i;
        sz[i] = 1;
    }
    for(int i = 1; i <= n; i++){
        for(int j = 1; j <= m; j++){
            char c;
            cin >> c;
            if(c == '='){
                arr[i][j] = 1;
                uni(i,n+j);
            }
            else if(c == '<'){
                arr[i][j] = 0;
            }
            else{
                arr[i][j] = 2;
            }
        }
    }
    for(int i = 1; i <= n; i++){
        for(int j = 1; j <= m; j++){
            if(arr[i][j] == 0){
                if(find(i) == find(n+j)){
                    cycle = 1;
                }
                g[find(i)].pb(find(n+j));
            }
            else if(arr[i][j] == 2){
                if(find(i) == find(n+j)){
                    cycle = 1;
                }
                g[find(n+j)].pb(find(i));
            }
        }
    }
    set<pair<int,int>>q;
    for(int i = 1; i <= n+m; i++){
        if(indeg[i] == 0 && g[i].size() && !vis[i]){
            dfs(i,1);
            q.insert({1,i});
        }
    }
    if(cycle){
        cout << "No" << endl;
        return 0;
    }
    mem(vis,0);
    while(!q.empty()){
        auto x = *q.begin();
        val[x.second] = x.first;
        q.erase(q.begin());
        for(int i : g[x.second]){
            if(vis[i]){
                continue;
            }
            q.erase({val[i],i});
            val[i] = max(val[i], x.first+1);
            q.insert({val[i],i});
        }
    }

    cout << "Yes" << endl;
    for(int i = 1; i <= n+m; i++){
        if(val[i] == 0){
            int k = find(i);
            if(val[k] == 0){
                val[k] = 1;
            }
            val[i] = val[k];

        }
        cout << val[i] << " ";
    }
    cout << endl;
}


#include <bits/stdc++.h>

using namespace std;

typedef pair<int,int> pii;

string s[1100];
int in[2][1100];
bool vis[2][1100];
int ans[2][1100];

int main(){

	int n,m;
	cin>>n>>m;
	for(int i=0;i<n;++i){
		cin>>s[i];
		for(int j=0;j<m;++j){
			if(s[i][j]=='='){
				++in[0][i];
				++in[1][j];
			}else if(s[i][j]=='>'){
				++in[1][j];
			}else ++in[0][i];
		}
	}
	queue<pii> q;
	for(int i=0;i<n;++i){
		if(in[0][i]==m){
			q.push({0,i});
			ans[0][i]=1;
		}
	}
	for(int i=0;i<m;++i){
		if(in[1][i]==n){
			q.push({1,i});
			ans[1][i]=1;
		}
	}
	if(q.size()==0){
		cout<<"No"<<endl;
		return 0;
	}
	while(!q.empty()){
		pii tmp=q.front();
		q.pop();
		if(vis[tmp.first][tmp.second]){
			continue;
		}
		vis[tmp.first][tmp.second]=1;
		if(tmp.first){
			for(int i=0;i<n;++i){
				if(s[i][tmp.second]=='<'){
					ans[1][tmp.second]=max(ans[1][tmp.second],ans[0][i]+1);
				}else if(s[i][tmp.second]=='='){
					ans[1][tmp.second]=max(ans[1][tmp.second],ans[0][i]);
				}
			}
			for(int i=0;i<n;++i){
				if(s[i][tmp.second]=='='){
					ans[0][i]=ans[1][tmp.second];
				}else if(s[i][tmp.second]=='>'){
					ans[0][i]=max(ans[0][i],ans[1][tmp.second]+1);
				}
				q.push({0,i});
			}
		}else{
			for(int i=0;i<m;++i){
				if(s[tmp.second][i]=='>'){
					ans[0][tmp.second]=max(ans[0][tmp.second],ans[1][i]+1);
				}else if(s[tmp.second][i]=='='){
					ans[0][tmp.second]=max(ans[0][tmp.second],ans[1][i]);
				}
			}
			for(int i=0;i<m;++i){
				if(s[tmp.second][i]=='='){
					ans[1][i]=ans[0][tmp.second];
				}else if(s[tmp.second][i]=='<'){
					ans[1][i]=max(ans[1][i],ans[0][tmp.second]+1);
				}
				q.push({1,i});
			}
		}
	}
	// for(int i=0;i<n;++i){
	// 	cout<<ans[0][i]<<" ";
	// }
	// cout<<endl;
	// for(int i=0;i<m;++i){
	// 	cout<<ans[1][i]<<" ";
	// }
	for(int i=0;i<n;++i){
		for(int j=0;j<m;++j){
			if(ans[0][i]==0||ans[1][j]==0){
				cout<<"No"<<endl;
				return 0;
			}
			if(s[i][j]=='='){
				if(ans[0][i]!=ans[1][i]){
					cout<<"No"<<endl;
					return 0;
				}
			}else if(s[i][j]=='<'){
				if(ans[0][i]>=ans[1][j]){
					cout<<"No"<<endl;
					return 0;
				}
			}else{
				if(ans[0][i]<=ans[1][j]){
					cout<<"No"<<endl;
					return 0;
				}
			}
		}
	}
	cout<<"Yes"<<endl;
	for(int i=0;i<n;++i){
		cout<<ans[0][i]<<" ";
	}
	cout<<endl;
	for(int i=0;i<m;++i){
		cout<<ans[1][i]<<" ";
	}
	cout<<endl;
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

const int maxn=2e3+50;

int fa[maxn];
string s[maxn];
vector<int> v[maxn];
int ans[maxn];
int in[maxn];
int vis[maxn];

int fin(int f){
	return f==fa[f]?f:fa[f]=fin(fa[f]);
}

int main(){

	int n,m;
	cin>>n>>m;
	for(int i=0;i<n+m;++i) fa[i]=i;
	for(int i=0;i<n;++i){
		cin>>s[i];
		for(int j=0;j<m;++j){
			if(s[i][j]=='='){
				int fi=fin(i),fj=fin(j+n);
				if(fi!=fj){
					fa[fj]=fi;
				}
			}
		}
	}
	for(int i=0;i<n;++i){
		for(int j=0;j<m;++j){
			if(s[i][j]=='>'){
				v[fin(n+j)].push_back(fin(i));
				++in[fin(i)];
			}else if(s[i][j]=='<'){
				v[fin(i)].push_back(fin(n+j));
				++in[fin(n+j)];
			}
		}
	}
	queue<int> q;
	for(int i=0;i<n+m;++i){
		if(!in[fin(i)]){
			ans[fin(i)]=1;
			q.push(fin(i));
		}
	}
	while(!q.empty()){
		int tmp=q.front();
		q.pop();
		if(vis[tmp]){
			continue;
		}
		vis[tmp]=1;
		for(auto i:v[tmp]){
			ans[fin(i)]=max(ans[(fin(i))],ans[fin(tmp)]+1);
			--in[fin(i)];
			if(!in[fin(i)])
				q.push(fin(i));
		}
	}
	for(int i=0;i<n+m;++i){
		if(!vis[fin(i)]){
			cout<<"No"<<endl;
			return 0;
		}
	}
	cout<<"Yes"<<endl;
	for(int i=0;i<n;++i){
		cout<<ans[fin(i)]<<" ";
	}
	cout<<endl;
	for(int i=0;i<m;++i){
		cout<<ans[fin(i+n)]<<" ";
	}
	cout<<endl;
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

const int maxn=2e3+50;

int fa[maxn];
string s[maxn];
vector<int> v[maxn];
int ans[maxn];
int in[maxn];
int vis[maxn];

int fin(int f){
	return f==fa[f]?f:fa[f]=fin(fa[f]);
}

int main(){

	int n,m;
	cin>>n>>m;
	for(int i=0;i<n+m;++i) fa[i]=i;
	for(int i=0;i<n;++i){
		cin>>s[i];
		for(int j=0;j<m;++j){
			if(s[i][j]=='='){
				int fi=fin(i),fj=fin(j+n);
				if(fi!=fj){
					fa[fj]=fi;
				}
			}
		}
	}
	for(int i=0;i<n;++i){
		for(int j=0;j<m;++j){
			if(s[i][j]=='>'){
				v[fin(n+j)].push_back(fin(i));
				++in[i];
			}else if(s[i][j]=='<'){
				v[fin(i)].push_back(fin(n+j));
				++in[n+j];
			}
		}
	}
	queue<int> q;
	for(int i=0;i<n+m;++i){
		if(!in[i]){
			ans[fin(i)]=1;
			q.push(i);
		}
	}
	while(!q.empty()){
		int tmp=q.front();
		q.pop();
		if(vis[tmp]){
			continue;
		}
		vis[tmp]=1;
		for(auto i:v[tmp]){
			ans[fin(i)]=max(ans[(fin(i))],ans[fin(tmp)]+1);
			q.push(i);
		}
	}
	for(int i=0;i<n;++i){
		for(int j=0;j<m;++j){
			if(s[i][j]=='='){
				if(ans[fin(i)]!=ans[fin(n+j)]){
					cout<<"No"<<endl;
					return 0;
				}
			}
			if(s[i][j]=='<'){
				if(ans[fin(i)]>=ans[fin(j+n)]){
					cout<<"No"<<endl;
					return 0;
				}
			}
			if(s[i][j]=='>'){
				if(ans[fin(i)]<=ans[fin(j+n)]){
					cout<<"No"<<endl;
					return 0;
				}
			}
		}
	}
	for(int i=0;i<n+m;++i){
		if(!vis[fin(i)]){
			cout<<"No"<<endl;
			return 0;
		}
	}
	cout<<"Yes"<<endl;
	for(int i=0;i<n;++i){
		cout<<ans[fin(i)]<<" ";
	}
	cout<<endl;
	for(int i=0;i<m;++i){
		cout<<ans[fin(i+n)]<<" ";
	}
	cout<<endl;
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

typedef pair<int,int> pii;

string s[1100];
vector<vector< int> > v[2][1100];
int in[2][1100];
bool vis[2][1100];
int ans[2][1100];

int main(){

	int n,m;
	cin>>n>>m;
	for(int i=0;i<n;++i){
		cin>>s[i];
		for(int j=0;j<m;++j){
			if(s[i][j]=='='){
				++in[0][i];
				++in[1][j];
			}else if(s[i][j]=='>'){
				++in[1][j];
			}else ++in[0][i];
		}
	}
	queue<pii> q;
	for(int i=0;i<n;++i){
		if(in[0][i]==m){
			q.push({0,i});
			ans[0][i]=1;
		}
	}
	for(int i=0;i<m;++i){
		if(in[1][i]==n){
			q.push({1,i});
			ans[1][i]=1;
		}
	}
	while(!q.empty()){
		pii tmp=q.front();
		q.pop();
		if(vis[tmp.first][tmp.second]){
			continue;
		}
		vis[tmp.first][tmp.second]=1;
		if(tmp.first){
			for(int i=0;i<n;++i){
				if(s[i][tmp.second]=='='){
					ans[0][i]=ans[1][tmp.second];
				}else if(s[i][tmp.second]=='>'){
					ans[0][i]=max(ans[0][i],ans[1][tmp.second]+1);
				}
				q.push({0,i});
			}
		}else{
			for(int i=0;i<m;++i){
				if(s[tmp.second][i]=='='){
					ans[1][i]=ans[0][tmp.second];
				}else if(s[tmp.second][i]=='<'){
					ans[1][i]=max(ans[1][i],ans[0][tmp.second]+1);
				}
				q.push({1,i});
			}
		}
	}
	for(int i=0;i<n;++i){
		for(int j=0;j<m;++j){
			if(ans[0][i]==0||ans[1][j]==0){
				cout<<"No"<<endl;
				return 0;
			}
			if(s[i][j]=='='){
				if(ans[0][i]!=ans[1][i]){
					cout<<"No"<<endl;
					return 0;
				}
			}else if(s[i][j]=='<'){
				if(ans[0][i]>=ans[1][j]){
					cout<<"No"<<endl;
					return 0;
				}
			}else{
				if(ans[0][i]<=ans[1][j]){
					cout<<"No"<<endl;
					return 0;
				}
			}
		}
	}
	cout<<"Yes"<<endl;
	for(int i=0;i<n;++i){
		cout<<ans[0][i]<<" ";
	}
	cout<<endl;
	for(int i=0;i<m;++i){
		cout<<ans[1][i]<<" ";
	}
	cout<<endl;
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

const int maxn=2e3+50;

int fa[maxn];
string s[maxn];
vector<int> v[maxn];
int ans[maxn];
int in[maxn];
int vis[maxn];

int fin(int f){
	return f==fa[f]?f:fa[f]=fin(fa[f]);
}

int main(){

	int n,m;
	cin>>n>>m;
	for(int i=0;i<n+m;++i) fa[i]=i;
	for(int i=0;i<n;++i){
		cin>>s[i];
		for(int j=0;j<m;++j){
			if(s[i][j]=='='){
				int fi=fin(i),fj=fin(j+n);
				if(fi!=fj){
					fa[fj]=fi;
				}
			}
		}
	}
	for(int i=0;i<n;++i){
		for(int j=0;j<m;++j){
			if(s[i][j]=='>'){
				v[fin(n+j)].push_back(fin(i));
				++in[fin(i)];
			}else if(s[i][j]=='<'){
				v[fin(i)].push_back(fin(n+j));
				++in[fin(n+j)];
			}
		}
	}
	queue<int> q;
	for(int i=0;i<n+m;++i){
		if(!in[fin(i)]){
			ans[i]=1;
			q.push(i);
		}
	}
	while(!q.empty()){
		int tmp=q.front();
		q.pop();
		if(vis[fin(tmp)]){
			continue;
		}
		vis[fin(tmp)]=1;
		for(auto i:v[tmp]){
			ans[fin(i)]=max(ans[(fin(i))],ans[fin(tmp)]+1);
			q.push(i);
		}
	}
	for(int i=0;i<n+m;++i){
		if(!vis[fin(i)]){
			cout<<"No"<<endl;
			return 0;
		}
	}
	cout<<"Yes"<<endl;
	for(int i=0;i<n;++i){
		cout<<ans[fin(i)]<<" ";
	}
	cout<<endl;
	for(int i=0;i<m;++i){
		cout<<ans[fin(i+n)]<<" ";
	}
	cout<<endl;
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

const int maxn=2e3+50;

int fa[maxn];
string s[maxn];
vector<int> v[maxn];
int ans[maxn];
int in[maxn];
int vis[maxn];

int fin(int f){
	return f==fa[f]?f:fa[f]=fin(fa[f]);
}

int main(){

	int n,m;
	cin>>n>>m;
	for(int i=0;i<n+m;++i) fa[i]=i;
	for(int i=0;i<n;++i){
		cin>>s[i];
		for(int j=0;j<m;++j){
			if(s[i][j]=='='){
				int fi=fin(i),fj=fin(j+n);
				if(fi!=fj){
					fa[fj]=fi;
				}
			}
		}
	}
	for(int i=0;i<n;++i){
		for(int j=0;j<m;++j){
			if(s[i][j]=='>'){
				v[fin(n+j)].push_back(fin(i));
				++in[fin(i)];
			}else if(s[i][j]=='<'){
				v[fin(i)].push_back(fin(n+j));
				++in[fin(n+j)];
			}
		}
	}
	queue<int> q;
	for(int i=0;i<n+m;++i){
		if(!in[fin(i)]){
			ans[fin(i)]=1;
			q.push(fin(i));
		}
	}
	while(!q.empty()){
		int tmp=q.front();
		q.pop();
		if(vis[tmp]){
			continue;
		}
		vis[tmp]=1;
		for(auto i:v[tmp]){
			ans[fin(i)]=max(ans[(fin(i))],ans[fin(tmp)]+1);
			--in[fin(i)];
			if(!in[fin(i)])
				q.push(fin(i));
		}
	}
	for(int i=0;i<n;++i){
		for(int j=0;j<m;++j){
			if(s[i][j]=='='){
				if(ans[fin(i)]!=ans[fin(n+j)]){
					cout<<"No"<<endl;
					return 0;
				}
			}
			if(s[i][j]=='<'){
				if(ans[fin(i)]>=ans[fin(j+n)]){
					cout<<"No"<<endl;
					return 0;
				}
			}
			if(s[i][j]=='>'){
				if(ans[fin(i)]<=ans[fin(j+n)]){
					cout<<"No"<<endl;
					return 0;
				}
			}
		}
	}
	// for(int i=0;i<n+m;++i){
	// 	if(!vis[fin(i)]){
	// 		cout<<"No"<<endl;
	// 		return 0;
	// 	}
	// }
	cout<<"Yes"<<endl;
	for(int i=0;i<n;++i){
		cout<<ans[fin(i)]<<" ";
	}
	cout<<endl;
	for(int i=0;i<m;++i){
		cout<<ans[fin(i+n)]<<" ";
	}
	cout<<endl;
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

const int maxn=2e3+50;

int fa[maxn];
string s[maxn];
vector<int> v[maxn];
int ans[maxn];
int in[maxn];
int vis[maxn];

int fin(int f){
	return f==fa[f]?f:fa[f]=fin(fa[f]);
}

int main(){

	int n,m;
	cin>>n>>m;
	for(int i=0;i<n+m;++i) fa[i]=i;
	for(int i=0;i<n;++i){
		cin>>s[i];
		for(int j=0;j<m;++j){
			if(s[i][j]=='='){
				int fi=fin(i),fj=fin(j+n);
				if(fi!=fj){
					fa[fj]=fi;
				}
			}
		}
	}
	for(int i=0;i<n;++i){
		for(int j=0;j<m;++j){
			if(s[i][j]=='>'){
				v[fin(n+j)].push_back(fin(i));
				++in[fin(i)];
			}else if(s[i][j]=='<'){
				v[fin(i)].push_back(fin(n+j));
				++in[fin(n+j)];
			}
		}
	}
	queue<int> q;
	for(int i=0;i<n+m;++i){
		if(!in[i]){
			ans[i]=1;
			q.push(i);
		}
	}
	while(!q.empty()){
		int tmp=q.front();
		q.pop();
		if(vis[tmp]){
			continue;
		}
		vis[tmp]=1;
		for(auto i:v[tmp]){
			ans[fin(i)]=max(ans[(fin(i))],ans[fin(tmp)]+1);
			q.push(i);
		}
	}
	for(int i=0;i<n;++i){
		for(int j=0;j<m;++j){
			if(s[i][j]=='='){
				if(ans[fin(i)]!=ans[fin(n+j)]){
					cout<<"No"<<endl;
					return 0;
				}
			}
			if(s[i][j]=='<'){
				if(ans[fin(i)]>=ans[fin(j+n)]){
					cout<<"No"<<endl;
					return 0;
				}
			}
			if(s[i][j]=='>'){
				if(ans[fin(i)]<=ans[fin(j+n)]){
					cout<<"No"<<endl;
					return 0;
				}
			}
		}
	}
	for(int i=0;i<n+m;++i){
		if(!vis[fin(i)]){
			cout<<"No"<<endl;
			return 0;
		}
	}
	cout<<"Yes"<<endl;
	for(int i=0;i<n;++i){
		cout<<ans[fin(i)]<<" ";
	}
	cout<<endl;
	for(int i=0;i<m;++i){
		cout<<ans[fin(i+n)]<<" ";
	}
	cout<<endl;
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

typedef pair<int,int> pii;

string s[1100];
vector<vector< int> > v[2][1100];
int in[2][1100];
bool vis[2][1100];
int ans[2][1100];

int main(){

	int n,m;
	cin>>n>>m;
	for(int i=0;i<n;++i){
		cin>>s[i];
		for(int j=0;j<m;++j){
			if(s[i][j]=='='){
				++in[0][i];
				++in[1][j];
			}else if(s[i][j]=='>'){
				++in[1][j];
			}else ++in[0][i];
		}
	}
	queue<pii> q;
	for(int i=0;i<n;++i){
		if(in[0][i]==m){
			q.push({0,i});
			ans[0][i]=1;
		}
	}
	for(int i=0;i<m;++i){
		if(in[1][i]==n){
			q.push({1,i});
			ans[1][i]=1;
		}
	}
	while(!q.empty()){
		pii tmp=q.front();
		q.pop();
		if(vis[tmp.first][tmp.second]){
			continue;
		}
		vis[tmp.first][tmp.second]=1;
		if(tmp.first){
			for(int i=0;i<n;++i){
				if(s[i][tmp.second]=='='){
					ans[0][i]=ans[1][tmp.second];
				}else if(s[i][tmp.second]=='>'){
					ans[0][i]=max(ans[0][i],ans[1][tmp.second]+1);
				}
				q.push({0,i});
			}
		}else{
			for(int i=0;i<m;++i){
				if(s[tmp.second][i]=='='){
					ans[1][i]=ans[0][tmp.second];
				}else if(s[tmp.second][i]=='<'){
					ans[1][i]=max(ans[1][i],ans[0][tmp.second]+1);
				}
				q.push({1,i});
			}
		}
	}
	for(int i=0;i<n;++i){
		for(int j=0;j<m;++j){
			if(s[i][j]=='='){
				if(ans[0][i]!=ans[1][i]){
					cout<<"No"<<endl;
					return 0;
				}
			}else if(s[i][j]=='<'){
				if(ans[0][i]>=ans[1][j]){
					cout<<"No"<<endl;
					return 0;
				}
			}else{
				if(ans[0][i]<=ans[1][j]){
					cout<<"No"<<endl;
					return 0;
				}
			}
		}
	}
	cout<<"Yes"<<endl;
	for(int i=0;i<n;++i){
		cout<<ans[0][i]<<" ";
	}
	cout<<endl;
	for(int i=0;i<m;++i){
		cout<<ans[1][i]<<" ";
	}
	cout<<endl;
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

const int maxn=2e3+50;

int fa[maxn];
string s[maxn];
vector<int> v[maxn];
int ans[maxn];
int in[maxn];
int vis[maxn];

int fin(int f){
	return f==fa[f]?f:fa[f]=fin(fa[f]);
}

int main(){

	int n,m;
	cin>>n>>m;
	for(int i=0;i<n+m;++i) fa[i]=i;
	for(int i=0;i<n;++i){
		cin>>s[i];
		for(int j=0;j<m;++j){
			if(s[i][j]=='='){
				int fi=fin(i),fj=fin(j+n);
				if(fi!=fj){
					fa[fj]=fi;
				}
			}
		}
	}
	for(int i=0;i<n;++i){
		for(int j=0;j<m;++j){
			if(s[i][j]=='>'){
				v[fin(n+j)].push_back(fin(i));
				++in[fin(i)];
			}else if(s[i][j]=='<'){
				v[fin(i)].push_back(fin(n+j));
				++in[fin(n+j)];
			}
		}
	}
	queue<int> q;
	for(int i=0;i<n+m;++i){
		if(!in[fin(i)]){
			ans[i]=1;
			q.push(i);
		}
	}
	while(!q.empty()){
		int tmp=q.front();
		q.pop();
		if(vis[fin(tmp)]){
			continue;
		}
		vis[fin(tmp)]=1;
		for(auto i:v[tmp]){
			if(vis[fin(i)]){
				if(ans[fin(i)]<ans[fin(tmp)]){
					cout<<"No"<<endl;
					return 0;
				}
			}
			ans[fin(i)]=max(ans[(fin(i))],ans[fin(tmp)]+1);
			q.push(i);
		}
	}
	for(int i=0;i<n+m;++i){
		if(!vis[fin(i)]){
			cout<<"No"<<endl;
			return 0;
		}
	}
	cout<<"Yes"<<endl;
	for(int i=0;i<n;++i){
		cout<<ans[fin(i)]<<" ";
	}
	cout<<endl;
	for(int i=0;i<m;++i){
		cout<<ans[fin(i+n)]<<" ";
	}
	cout<<endl;
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

const int maxn=2e3+50;

int fa[maxn];
string s[maxn];
vector<int> v[maxn];
int ans[maxn];
int in[maxn];
int vis[maxn];

int fin(int f){
	return f==fa[f]?f:fa[f]=fin(fa[f]);
}

int main(){

	int n,m;
	cin>>n>>m;
	for(int i=0;i<n+m;++i) fa[i]=i;
	for(int i=0;i<n;++i){
		cin>>s[i];
		for(int j=0;j<m;++j){
			if(s[i][j]=='='){
				int fi=fin(i),fj=fin(j+n);
				if(fi!=fj){
					fa[fj]=fi;
				}
			}
		}
	}
	for(int i=0;i<n;++i){
		for(int j=0;j<m;++j){
			if(s[i][j]=='>'){
				v[fin(n+j)].push_back(fin(i));
				++in[i];
			}else if(s[i][j]=='<'){
				v[fin(i)].push_back(fin(n+j));
				++in[n+j];
			}
		}
	}
	queue<int> q;
	for(int i=0;i<n+m;++i){
		if(!in[i]){
			ans[fin(i)]=1;
			q.push(i);
		}
	}
	while(!q.empty()){
		int tmp=q.front();
		q.pop();
		if(vis[tmp]){
			continue;
		}
		vis[tmp]=1;
		for(auto i:v[tmp]){
			ans[fin(i)]=max(ans[(fin(i))],ans[fin(tmp)]+1);
			q.push(i);
		}
	}
	for(int i=0;i<n;++i){
		for(int j=0;j<m;++j){
			if(s[i][j]=='='){
				if(ans[fin(i)]!=ans[fin(n+j)]){
					cout<<"No"<<endl;
					return 0;
				}
			}
			if(s[i][j]=='<'){
				if(ans[fin(i)]>=ans[fin(j+n)]){
					cout<<"No"<<endl;
					return 0;
				}
			}
			if(s[i][j]=='>'){
				if(ans[fin(i)]<=ans[fin(j+n)]){
					cout<<"No"<<endl;
					return 0;
				}
			}
		}
	}
	// for(int i=0;i<n+m;++i){
	// 	if(!vis[fin(i)]){
	// 		cout<<"No"<<endl;
	// 		return 0;
	// 	}
	// }
	cout<<"Yes"<<endl;
	for(int i=0;i<n;++i){
		cout<<ans[fin(i)]<<" ";
	}
	cout<<endl;
	for(int i=0;i<m;++i){
		cout<<ans[fin(i+n)]<<" ";
	}
	cout<<endl;
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

typedef pair<int,int> pii;

string s[1100];
vector<vector< int> > v[2][1100];
int in[2][1100];
bool vis[2][1100];
int ans[2][1100];

int main(){

	int n,m;
	cin>>n>>m;
	for(int i=0;i<n;++i){
		cin>>s[i];
		for(int j=0;j<m;++j){
			if(s[i][j]=='='){
				++in[0][i];
				++in[1][j];
			}else if(s[i][j]=='>'){
				++in[1][j];
			}else ++in[0][i];
		}
	}
	queue<pii> q;
	for(int i=0;i<n;++i){
		if(in[0][i]==m){
			q.push({0,i});
			ans[0][i]=1;
		}
	}
	for(int i=0;i<m;++i){
		if(in[1][i]==n){
			q.push({1,i});
			ans[1][i]=1;
		}
	}
	if(q.size()==0){
		cout<<"No"<<endl;
		return 0;
	}
	while(!q.empty()){
		pii tmp=q.front();
		q.pop();
		if(vis[tmp.first][tmp.second]){
			continue;
		}
		vis[tmp.first][tmp.second]=1;
		if(tmp.first){
			for(int i=0;i<n;++i){
				if(s[i][tmp.second]=='='){
					ans[0][i]=ans[1][tmp.second];
				}else if(s[i][tmp.second]=='>'){
					ans[0][i]=max(ans[0][i],ans[1][tmp.second]+1);
				}
				q.push({0,i});
			}
		}else{
			for(int i=0;i<m;++i){
				if(s[tmp.second][i]=='='){
					ans[1][i]=ans[0][tmp.second];
				}else if(s[tmp.second][i]=='<'){
					ans[1][i]=max(ans[1][i],ans[0][tmp.second]+1);
				}
				q.push({1,i});
			}
		}
	}
	for(int i=0;i<n;++i){
		for(int j=0;j<m;++j){
			if(ans[0][i]==0||ans[1][j]==0){
				cout<<"No"<<endl;
				return 0;
			}
			if(s[i][j]=='='){
				if(ans[0][i]!=ans[1][i]){
					cout<<"No"<<endl;
					return 0;
				}
			}else if(s[i][j]=='<'){
				if(ans[0][i]>=ans[1][j]){
					cout<<"No"<<endl;
					return 0;
				}
			}else{
				if(ans[0][i]<=ans[1][j]){
					cout<<"No"<<endl;
					return 0;
				}
			}
		}
	}
	cout<<"Yes"<<endl;
	for(int i=0;i<n;++i){
		cout<<ans[0][i]<<" ";
	}
	cout<<endl;
	for(int i=0;i<m;++i){
		cout<<ans[1][i]<<" ";
	}
	cout<<endl;
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

const int maxn=2e3+50;

int fa[maxn];
string s[maxn];
vector<int> v[maxn];
int ans[maxn];
int in[maxn];
int vis[maxn];

int fin(int f){
	return f==fa[f]?f:fa[f]=fin(fa[f]);
}

int main(){

	int n,m;
	cin>>n>>m;
	for(int i=0;i<n+m;++i) fa[i]=i;
	for(int i=0;i<n;++i){
		cin>>s[i];
		for(int j=0;j<m;++j){
			if(s[i][j]=='='){
				int fi=fin(i),fj=fin(j+n);
				if(fi!=fj){
					fa[fj]=fi;
				}
			}
		}
	}
	for(int i=0;i<n;++i){
		for(int j=0;j<m;++j){
			if(s[i][j]=='>'){
				v[fin(n+j)].push_back(fin(i));
				++in[fin(i)];
			}else if(s[i][j]=='<'){
				v[fin(i)].push_back(fin(n+j));
				++in[fin(n+j)];
			}
		}
	}
	queue<int> q;
	for(int i=0;i<n+m;++i){
		if(!in[fin(i)]){
			ans[i]=1;
			q.push(i);
		}
	}
	while(!q.empty()){
		int tmp=q.front();
		q.pop();
		if(vis[fin(tmp)]){
			continue;
		}
		vis[fin(tmp)]=1;
		for(auto i:v[tmp]){
			ans[fin(i)]=max(ans[(fin(i))],ans[fin(tmp)]+1);
			q.push(i);
		}
	}
	for(int i=0;i<n;++i){
		for(int j=0;j<m;++j){
			if(s[i][j]=='='){
				if(ans[fin(i)]!=ans[fin(n+j)]){
					cout<<"No"<<endl;
					return 0;
				}
			}
			if(s[i][j]=='<'){
				if(ans[fin(i)]>=ans[fin(j+n)]){
					cout<<"No"<<endl;
					return 0;
				}
			}
			if(s[i][j]=='>'){
				if(ans[fin(i)]<=ans[fin(j+n)]){
					cout<<"No"<<endl;
					return 0;
				}
			}
		}
	}
	for(int i=0;i<n+m;++i){
		if(!vis[fin(i)]){
			cout<<"No"<<endl;
			return 0;
		}
	}
	cout<<"Yes"<<endl;
	for(int i=0;i<n;++i){
		cout<<ans[fin(i)]<<" ";
	}
	cout<<endl;
	for(int i=0;i<m;++i){
		cout<<ans[fin(i+n)]<<" ";
	}
	cout<<endl;
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

const int maxn=2e3+50;

int fa[maxn];
string s[maxn];
vector<int> v[maxn];
int ans[maxn];
int in[maxn];
int vis[maxn];

int fin(int f){
	return f==fa[f]?f:fa[f]=fin(fa[f]);
}

int main(){

	int n,m;
	cin>>n>>m;
	for(int i=0;i<n+m;++i) fa[i]=i;
	for(int i=0;i<n;++i){
		cin>>s[i];
		for(int j=0;j<m;++j){
			if(s[i][j]=='='){
				int fi=fin(i),fj=fin(j+n);
				if(fi!=fj){
					fa[fj]=fi;
				}
			}
		}
	}
	for(int i=0;i<n;++i){
		for(int j=0;j<m;++j){
			if(s[i][j]=='>'){
				v[fin(n+j)].push_back(fin(i));
				++in[fin(i)];
			}else if(s[i][j]=='<'){
				v[fin(i)].push_back(fin(n+j));
				++in[fin(n+j)];
			}
		}
	}
	queue<int> q;
	for(int i=0;i<n+m;++i){
		if(!in[fin(i)]){
			ans[fin(i)]=1;
			q.push(fin(i));
		}
	}
	while(!q.empty()){
		int tmp=q.front();
		q.pop();
		if(vis[tmp]){
			continue;
		}
		vis[tmp]=1;
		for(auto i:v[tmp]){
			ans[fin(i)]=max(ans[(fin(i))],ans[fin(tmp)]+1);
			q.push(fin(i));
		}
	}
	for(int i=0;i<n;++i){
		for(int j=0;j<m;++j){
			if(s[i][j]=='='){
				if(ans[fin(i)]!=ans[fin(n+j)]){
					cout<<"No"<<endl;
					return 0;
				}
			}
			if(s[i][j]=='<'){
				if(ans[fin(i)]>=ans[fin(j+n)]){
					cout<<"No"<<endl;
					return 0;
				}
			}
			if(s[i][j]=='>'){
				if(ans[fin(i)]<=ans[fin(j+n)]){
					cout<<"No"<<endl;
					return 0;
				}
			}
		}
	}
	// for(int i=0;i<n+m;++i){
	// 	if(!vis[fin(i)]){
	// 		cout<<"No"<<endl;
	// 		return 0;
	// 	}
	// }
	cout<<"Yes"<<endl;
	for(int i=0;i<n;++i){
		cout<<ans[fin(i)]<<" ";
	}
	cout<<endl;
	for(int i=0;i<m;++i){
		cout<<ans[fin(i+n)]<<" ";
	}
	cout<<endl;
	return 0;
}


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

vector<int> g[2010];

struct union_find_tree {
    std::vector<int> par, rank;
    union_find_tree(){}
    union_find_tree(int size)
    {
        par=std::vector<int>(size);
        rank=std::vector<int>(size);
        for(int i=0; i<size; ++i) par[i]=i;
    }
    int root(int x)
    {
        if (x==par[x]) return x;
        return par[x]=root(par[x]);
    }
    void unite(int x, int y)
    {
        x=root(x);
        y=root(y);
        if (x==y) return;
        if (rank[x]<rank[y]) {
            par[x]=y;
        }
        else {
            par[y]=x;
            if (rank[x]==rank[y]) ++rank[x];
        }
    }
    bool same(int x, int y)
    {
        return root(x)==root(y);
    }
};

int res[2010];
int visited[2010];
bool tsort(int v, int k)
{
    if (visited[v]==2) {
        res[v]=k;
        return true;
    }
    if (visited[v]==1) return false;
    visited[v]=1;
    for(auto& u: g[v]) if (!tsort(u, k+1)) return false;
    visited[v]=2;
    res[v]=k;
    return true;
}

int main()
{
    int n, m; cin>>n>>m;
    union_find_tree T(n+m);

    vector<string> a(n);
    unordered_set<int> S;
    for(int i=0; i<n+m; ++i) S.insert(i);
    for(int i=0; i<n; ++i) {
        cin>>a[i];
        for(int j=0; j<m; ++j) if (a[i][j]=='=') T.unite(i, j+n);
    }
    for(int i=0; i<n; ++i) {
        for(int j=0; j<m; ++j) {
            if (a[i][j]=='<') {
                g[T.root(i)].push_back(T.root(j+n));
                S.erase(T.root(j+n));
            }
            else if (a[i][j]=='>') {
                g[T.root(j+n)].push_back(T.root(i));
                S.erase(T.root(i));
            }
        }
    }
    for(int i=0; i<n+m; ++i) {
        int v=T.root(i);
        if (v!=i or visited[v] or !S.count(v)) continue;
        if (!tsort(v, 1)) { cout<<"No"<<endl; return 0; }
    }
    for(int i=0; i<n+m; ++i) res[i]=res[T.root(i)];

    cout<<"Yes"<<endl;
    for(int i=0; i<n+m; ++i) cout<<res[i]<<(i==n-1 ? '\n' : ' ');
    cout<<endl;
}


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

vector<int> g[2010];

struct union_find_tree {
    std::vector<int> par, rank;
    union_find_tree(){}
    union_find_tree(int size)
    {
        par=std::vector<int>(size);
        rank=std::vector<int>(size);
        for(int i=0; i<size; ++i) par[i]=i;
    }
    int root(int x)
    {
        if (x==par[x]) return x;
        return par[x]=root(par[x]);
    }
    void unite(int x, int y)
    {
        x=root(x);
        y=root(y);
        if (x==y) return;
        if (rank[x]<rank[y]) {
            par[x]=y;
        }
        else {
            par[y]=x;
            if (rank[x]==rank[y]) ++rank[x];
        }
    }
    bool same(int x, int y)
    {
        return root(x)==root(y);
    }
};

int res[2010];
int visited[2010];
bool tsort(int v, int k)
{
    if (visited[v]==2) return true;
    if (visited[v]==1) return false;
    visited[v]=1;
    for(auto& u: g[v]) if (!tsort(u, k+1)) return false;
    visited[v]=2;
    res[v]=k;
    return true;
}

int main()
{
    int n, m; cin>>n>>m;
    union_find_tree T(n+m);

    vector<string> a(n);
    unordered_set<int> S;
    for(int i=0; i<n+m; ++i) S.insert(i);
    for(int i=0; i<n; ++i) {
        cin>>a[i];
        for(int j=0; j<m; ++j) if (a[i][j]=='=') T.unite(i, j+n);
    }
    for(int i=0; i<n; ++i) {
        for(int j=0; j<m; ++j) {
            if (a[i][j]=='<') {
                g[T.root(i)].push_back(T.root(j+n));
                S.erase(T.root(j+n));
            }
            else if (a[i][j]=='>') {
                g[T.root(j+n)].push_back(T.root(i));
                S.erase(T.root(i));
            }
        }
    }
    for(int i=0; i<n+m; ++i) {
        int v=T.root(i);
        if (v!=i or visited[v] or !S.count(v)) continue;
        if (!tsort(v, 1)) { cout<<"No"<<endl; return 0; }
    }
    for(int i=0; i<n+m; ++i) res[i]=res[T.root(i)];

    cout<<"Yes"<<endl;
    for(int i=0; i<n+m; ++i) cout<<res[i]<<(i==n-1 ? '\n' : ' ');
    cout<<endl;
}


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

vector<int> g[2010];

struct union_find_tree {
    std::vector<int> par, rank;
    union_find_tree(){}
    union_find_tree(int size)
    {
        par=std::vector<int>(size);
        rank=std::vector<int>(size);
        for(int i=0; i<size; ++i) par[i]=i;
    }
    int root(int x)
    {
        if (x==par[x]) return x;
        return par[x]=root(par[x]);
    }
    void unite(int x, int y)
    {
        x=root(x);
        y=root(y);
        if (x==y) return;
        if (rank[x]<rank[y]) {
            par[x]=y;
        }
        else {
            par[y]=x;
            if (rank[x]==rank[y]) ++rank[x];
        }
    }
    bool same(int x, int y)
    {
        return root(x)==root(y);
    }
};

int res[2010];
int visited[2010];
bool tsort(int v, int k)
{
    if (visited[v]==2) {
        res[v]=k;
        return true;
    }
    if (visited[v]==1) return false;
    visited[v]=1;
    for(auto& u: g[v]) if (!tsort(u, k+1)) return false;
    visited[v]=2;
    res[v]=k;
    return true;
}

int main()
{
    int n, m; cin>>n>>m;
    union_find_tree T(n+m);

    vector<string> a(n);
    unordered_set<int> S;
    for(int i=0; i<n+m; ++i) S.insert(i);
    for(int i=0; i<n; ++i) {
        cin>>a[i];
        for(int j=0; j<m; ++j) if (a[i][j]=='=') T.unite(i, j+n);
    }
    for(int i=0; i<n; ++i) {
        for(int j=0; j<m; ++j) {
            if (a[i][j]=='<') {
                g[T.root(i)].push_back(T.root(j+n));
                S.erase(T.root(j+n));
            }
            else if (a[i][j]=='>') {
                g[T.root(j+n)].push_back(T.root(i));
                S.erase(T.root(i));
            }
        }
    }
    for(int i=0; i<n+m; ++i) {
        int v=T.root(i);
        if (v!=i or visited[v] or !S.count(v)) continue;
        if (!tsort(v, 1)) { cout<<"No"<<endl; return 0; }
    }
    for(int i=0; i<n+m; ++i) {
        res[i]=res[T.root(i)];
        if (res[i]==0) { cout<<"No"<<endl; return 0; }
    }

    cout<<"Yes"<<endl;
    for(int i=0; i<n+m; ++i) cout<<res[i]<<(i==n-1 ? '\n' : ' ');
    cout<<endl;
}


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

vector<int> g[2010];

struct union_find_tree {
    std::vector<int> par, rank;
    union_find_tree(){}
    union_find_tree(int size)
    {
        par=std::vector<int>(size);
        rank=std::vector<int>(size);
        for(int i=0; i<size; ++i) par[i]=i;
    }
    int root(int x)
    {
        if (x==par[x]) return x;
        return par[x]=root(par[x]);
    }
    void unite(int x, int y)
    {
        x=root(x);
        y=root(y);
        if (x==y) return;
        if (rank[x]<rank[y]) {
            par[x]=y;
        }
        else {
            par[y]=x;
            if (rank[x]==rank[y]) ++rank[x];
        }
    }
    bool same(int x, int y)
    {
        return root(x)==root(y);
    }
};

int res[2010];
int visited[2010];
bool tsort(int v, int k)
{
    if (visited[v]==2) {
        res[v]=max(res[v], k);
        return true;
    }
    if (visited[v]==1) return false;
    visited[v]=1;
    for(auto& u: g[v]) if (!tsort(u, k+1)) return false;
    visited[v]=2;
    res[v]=max(res[v], k);
    return true;
}

int main()
{
    int n, m; cin>>n>>m;
    union_find_tree T(n+m);

    vector<string> a(n);
    unordered_set<int> S;
    for(int i=0; i<n+m; ++i) S.insert(i);
    for(int i=0; i<n; ++i) {
        cin>>a[i];
        for(int j=0; j<m; ++j) if (a[i][j]=='=') T.unite(i, j+n);
    }
    for(int i=0; i<n; ++i) {
        for(int j=0; j<m; ++j) {
            if (a[i][j]=='<') {
                g[T.root(i)].push_back(T.root(j+n));
                S.erase(T.root(j+n));
            }
            else if (a[i][j]=='>') {
                g[T.root(j+n)].push_back(T.root(i));
                S.erase(T.root(i));
            }
        }
    }
    for(int i=0; i<n+m; ++i) {
        int v=T.root(i);
        if (v!=i or visited[v] or !S.count(v)) continue;
        if (!tsort(v, 1)) { cout<<"No"<<endl; return 0; }
    }
    for(int i=0; i<n+m; ++i) {
        res[i]=res[T.root(i)];
        if (res[i]==0) { cout<<"No"<<endl; return 0; }
    }

    cout<<"Yes"<<endl;
    for(int i=0; i<n+m; ++i) cout<<res[i]<<(i==n-1 ? '\n' : ' ');
    cout<<endl;
}


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

struct union_find_tree {
    std::vector<int> par, rank;
    union_find_tree(){}
    union_find_tree(int size)
    {
        par=std::vector<int>(size);
        rank=std::vector<int>(size);
        for(int i=0; i<size; ++i) par[i]=i;
    }
    int root(int x)
    {
        if (x==par[x]) return x;
        return par[x]=root(par[x]);
    }
    void unite(int x, int y)
    {
        x=root(x);
        y=root(y);
        if (x==y) return;
        if (rank[x]<rank[y]) {
            par[x]=y;
        }
        else {
            par[y]=x;
            if (rank[x]==rank[y]) ++rank[x];
        }
    }
    bool same(int x, int y)
    {
        return root(x)==root(y);
    }
};

const int MAXN=2010;
unordered_set<int> g[MAXN];
int visited[MAXN], isDeg0[MAXN];
deque<int> L;
bool tsort(int v)
{
    if (visited[v]==1) return false;
    if (visited[v]==2) return true;
    visited[v]=1;
    for(auto& u: g[v]) if (!tsort(u)) return false;
    visited[v]=2;
    L.push_front(v);
    return true;
}

vector<int> numbering(int V)
{
    vector<int> res(V);
    for(int i=0; i<V; ++i) if (isDeg0[i] and !visited[i]) {
        L.clear();
        if (!tsort(i)) return {};
        int k=1;
        res[L[0]]=k;
        for(int j=1; j<L.size(); ++j) {
            if (g[L[j-1]].count(L[j])) ++k;
            res[L[j]]=k;
        }
    }
    return res;
}

int main()
{
    int n, m; cin>>n>>m;
    union_find_tree T(n+m);

    vector<string> a(n);
    for(int i=0; i<n; ++i) {
        cin>>a[i];
        for(int j=0; j<m; ++j) if (a[i][j]=='=') T.unite(i, j+n);
    }
    for(int i=0; i<n+m; ++i) isDeg0[i]=(i==T.root(i));
    for(int i=0; i<n; ++i) {
        for(int j=0; j<m; ++j) {
            if (a[i][j]=='<') {
                g[T.root(i)].insert(T.root(j+n));
                isDeg0[T.root(j+n)]=false;
            }
            else if (a[i][j]=='>') {
                g[T.root(j+n)].insert(T.root(i));
                isDeg0[T.root(i)]=false;
            }
        }
    }
    auto res=numbering(n+m);
    if (res.empty()) { cout<<"No"<<endl; return 0; }
    for(int i=0; i<n+m; ++i) {
        res[i]=res[T.root(i)];
        if (res[i]==0) { cout<<"No"<<endl; return 0; }
    }

    cout<<"Yes"<<endl;
    for(int i=0; i<n+m; ++i) cout<<res[i]<<(i==n-1 ? '\n' : ' ');
    cout<<endl;
}


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

vector<int> g[2010];

struct union_find_tree {
    std::vector<int> par, rank;
    union_find_tree(){}
    union_find_tree(int size)
    {
        par=std::vector<int>(size);
        rank=std::vector<int>(size);
        for(int i=0; i<size; ++i) par[i]=i;
    }
    int root(int x)
    {
        if (x==par[x]) return x;
        return par[x]=root(par[x]);
    }
    void unite(int x, int y)
    {
        x=root(x);
        y=root(y);
        if (x==y) return;
        if (rank[x]<rank[y]) {
            par[x]=y;
        }
        else {
            par[y]=x;
            if (rank[x]==rank[y]) ++rank[x];
        }
    }
    bool same(int x, int y)
    {
        return root(x)==root(y);
    }
};

int res[2010];
int visited[2010], NG;
void tsort(int v, int k)
{
    if (NG) return;
    if (visited[v]==1) { NG=1; return; }
    visited[v]=1;
    for(auto& u: g[v]) if (visited[v]<2) tsort(u, k+1);
    visited[v]=2;
    res[v]=k;
}

int main()
{
    int n, m; __builtin_scanf("%d%d", &n, &m);
    union_find_tree T(n+m);

    vector<string> a(n);
    for(int i=0; i<n; ++i) {
        char s[2010];
        __builtin_scanf("%s", s);
        a[i]=string(s);
        for(int j=0; j<m; ++j) if (s[j]=='=') T.unite(i, j+n);
    }
    for(int i=0; i<n; ++i) {
        for(int j=0; j<m; ++j) {
            if (a[i][j]=='<')
                g[T.root(i)].push_back(T.root(j+n));
            else if (a[i][j]=='>')
                g[T.root(j+n)].push_back(T.root(i));
        }
    }
    for(int i=0; i<n+m; ++i) {
        int v=T.root(i);
        if (visited[v]) continue;
        NG=0;
        tsort(v, 1);
        if (NG) { cout<<"No"<<endl; return 0; }
    }
    for(int i=0; i<n+m; ++i) res[i]=res[T.root(i)];

    cout<<"Yes"<<endl;
    for(int i=0; i<n+m; ++i) cout<<res[i]<<(i==n-1 ? '\n' : ' ');
    cout<<endl;
}


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

vector<int> g[2010];

struct union_find_tree {
    std::vector<int> par, rank;
    union_find_tree(){}
    union_find_tree(int size)
    {
        par=std::vector<int>(size);
        rank=std::vector<int>(size);
        for(int i=0; i<size; ++i) par[i]=i;
    }
    int root(int x)
    {
        if (x==par[x]) return x;
        return par[x]=root(par[x]);
    }
    void unite(int x, int y)
    {
        x=root(x);
        y=root(y);
        if (x==y) return;
        if (rank[x]<rank[y]) {
            par[x]=y;
        }
        else {
            par[y]=x;
            if (rank[x]==rank[y]) ++rank[x];
        }
    }
    bool same(int x, int y)
    {
        return root(x)==root(y);
    }
};

int res[2010];
int visited[2010], NG;
void tsort(int v, int k)
{
    if (NG) return;
    if (visited[v]==1) { NG=1; return; }
    visited[v]=1;
    for(auto& u: g[v]) tsort(u, k+1);
    visited[v]=2;
    res[v]=k;
}

int main()
{
    int n, m; cin>>n>>m;
    union_find_tree T(n+m);

    vector<string> a(n);
    for(int i=0; i<n; ++i) {
        cin>>a[i];
        for(int j=0; j<m; ++j) if (a[i][j]=='=') T.unite(i, j+n);
    }
    for(int i=0; i<n; ++i) {
        for(int j=0; j<m; ++j) {
            if (a[i][j]=='<')
                g[T.root(i)].push_back(T.root(j+n));
            else if (a[i][j]=='>')
                g[T.root(j+n)].push_back(T.root(i));
        }
    }
    for(int i=0; i<n+m; ++i) {
        int v=T.root(i);
        if (visited[v]) continue;
        NG=0;
        tsort(v, 1);
        if (NG) { cout<<"No"<<endl; return 0; }
    }
    for(int i=0; i<n+m; ++i) res[i]=res[T.root(i)];

    cout<<"Yes"<<endl;
    for(int i=0; i<n; ++i) cout<<res[i]<<' ';
    cout<<endl;
    for(int i=n; i<n+m; ++i) cout<<res[i]<<' ';
    cout<<endl;
}


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

vector<int> g[2010];

struct union_find_tree {
    std::vector<int> par, rank;
    union_find_tree(){}
    union_find_tree(int size)
    {
        par=std::vector<int>(size);
        rank=std::vector<int>(size);
        for(int i=0; i<size; ++i) par[i]=i;
    }
    int root(int x)
    {
        if (x==par[x]) return x;
        return par[x]=root(par[x]);
    }
    void unite(int x, int y)
    {
        x=root(x);
        y=root(y);
        if (x==y) return;
        if (rank[x]<rank[y]) {
            par[x]=y;
        }
        else {
            par[y]=x;
            if (rank[x]==rank[y]) ++rank[x];
        }
    }
    bool same(int x, int y)
    {
        return root(x)==root(y);
    }
};

int res[2010];
int visited[2010], NG;
void tsort(int v, int k)
{
    if (NG) return;
    if (visited[v]==1) { NG=1; return; }
    visited[v]=1;
    for(auto& u: g[v]) tsort(u, k+1);
    visited[v]=2;
    res[v]=k;
}

int main()
{
    int n, m; cin>>n>>m;
    union_find_tree T(n+m);
    for(int i=0; i<n; ++i) {
        string s; cin>>s;
        for(int j=0; j<m; ++j) {
            if (s[j]=='<') g[i].push_back(j+n);
            else if (s[j]=='>') g[j+n].push_back(i);
            else T.unite(i, j+n);
        }
    }
    for(int i=0; i<n+m; ++i) if (!visited[i]) {
        NG=0;
        tsort(i, 1);
        if (NG) { cout<<"No"<<endl; return 0; }
    }
    for(int i=0; i<n+m; ++i) {
        for(int j=i+1; j<n+m; ++j) {
            if (T.same(i, j) and res[i]!=res[j]) {
                cout<<"No"<<endl;
                return 0;
            }
        }
    }
    cout<<"Yes"<<endl;
    for(int i=0; i<n; ++i) cout<<res[i]<<' ';
    cout<<endl;
    for(int i=n; i<n+m; ++i) cout<<res[i]<<' ';
    cout<<endl;
}


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

vector<int> g[2010];

struct union_find_tree {
    std::vector<int> par, rank;
    union_find_tree(){}
    union_find_tree(int size)
    {
        par=std::vector<int>(size);
        rank=std::vector<int>(size);
        for(int i=0; i<size; ++i) par[i]=i;
    }
    int root(int x)
    {
        if (x==par[x]) return x;
        return par[x]=root(par[x]);
    }
    void unite(int x, int y)
    {
        x=root(x);
        y=root(y);
        if (x==y) return;
        if (rank[x]<rank[y]) {
            par[x]=y;
        }
        else {
            par[y]=x;
            if (rank[x]==rank[y]) ++rank[x];
        }
    }
    bool same(int x, int y)
    {
        return root(x)==root(y);
    }
};

int res[2010];
int visited[2010];
bool tsort(int v, int k)
{
    if (visited[v]==1) return false;
    if (visited[v]==2) return true;
    visited[v]=1;
    for(auto& u: g[v]) if (!tsort(u, k+1)) return false;
    visited[v]=2;
    res[v]=k;
    return true;
}

int main()
{
    int n, m; cin>>n>>m;
    union_find_tree T(n+m);

    vector<string> a(n);
    for(int i=0; i<n; ++i) {
        cin>>a[i];
        for(int j=0; j<m; ++j) if (a[i][j]=='=') T.unite(i, j+n);
    }
    for(int i=0; i<n; ++i) {
        for(int j=0; j<m; ++j) {
            if (a[i][j]=='<')
                g[T.root(i)].push_back(T.root(j+n));
            else if (a[i][j]=='>')
                g[T.root(j+n)].push_back(T.root(i));
        }
    }
    for(int i=0; i<n+m; ++i) {
        int v=T.root(i);
        if (visited[v]) continue;
        if (!tsort(v, 1)) { cout<<"No"<<endl; return 0; }
    }
    for(int i=0; i<n+m; ++i) res[i]=res[T.root(i)];

    cout<<"Yes"<<endl;
    for(int i=0; i<n+m; ++i) cout<<res[i]<<(i==n-1 ? '\n' : ' ');
    cout<<endl;
}


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

vector<int> g[2010];

struct union_find_tree {
    std::vector<int> par, rank;
    union_find_tree(){}
    union_find_tree(int size)
    {
        par=std::vector<int>(size);
        rank=std::vector<int>(size);
        for(int i=0; i<size; ++i) par[i]=i;
    }
    int root(int x)
    {
        if (x==par[x]) return x;
        return par[x]=root(par[x]);
    }
    void unite(int x, int y)
    {
        x=root(x);
        y=root(y);
        if (x==y) return;
        if (rank[x]<rank[y]) {
            par[x]=y;
        }
        else {
            par[y]=x;
            if (rank[x]==rank[y]) ++rank[x];
        }
    }
    bool same(int x, int y)
    {
        return root(x)==root(y);
    }
};

int res[2010];
int visited[2010], NG;
void tsort(int v, int k)
{
    if (NG) return;
    if (visited[v]==1) { NG=1; return; }
    visited[v]=1;
    for(auto& u: g[v]) if (visited[v]<2) tsort(u, k+1);
    visited[v]=2;
    res[v]=k;
}

int main()
{
    int n, m; cin>>n>>m;
    union_find_tree T(n+m);

    vector<string> a(n);
    for(int i=0; i<n; ++i) {
        cin>>a[i];
        for(int j=0; j<m; ++j) if (a[i][j]=='=') T.unite(i, j+n);
    }
    for(int i=0; i<n; ++i) {
        for(int j=0; j<m; ++j) {
            if (a[i][j]=='<')
                g[T.root(i)].push_back(T.root(j+n));
            else if (a[i][j]=='>')
                g[T.root(j+n)].push_back(T.root(i));
        }
    }
    for(int i=0; i<n+m; ++i) {
        int v=T.root(i);
        if (visited[v]) continue;
        NG=0;
        tsort(v, 1);
        if (NG) { cout<<"No"<<endl; return 0; }
    }
    for(int i=0; i<n+m; ++i) res[i]=res[T.root(i)];

    cout<<"Yes"<<endl;
    for(int i=0; i<n; ++i) cout<<res[i]<<' ';
    cout<<endl;
    for(int i=n; i<n+m; ++i) cout<<res[i]<<' ';
    cout<<endl;
}


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

vector<int> g[2010];

struct union_find_tree {
    std::vector<int> par, rank;
    union_find_tree(){}
    union_find_tree(int size)
    {
        par=std::vector<int>(size);
        rank=std::vector<int>(size);
        for(int i=0; i<size; ++i) par[i]=i;
    }
    int root(int x)
    {
        if (x==par[x]) return x;
        return par[x]=root(par[x]);
    }
    void unite(int x, int y)
    {
        x=root(x);
        y=root(y);
        if (x==y) return;
        if (rank[x]<rank[y]) {
            par[x]=y;
        }
        else {
            par[y]=x;
            if (rank[x]==rank[y]) ++rank[x];
        }
    }
    bool same(int x, int y)
    {
        return root(x)==root(y);
    }
};

int res[2010];
int visited[2010], NG;
void tsort(int v, int k)
{
    if (NG) return;
    if (visited[v]==1) { NG=1; return; }
    visited[v]=1;
    for(auto& u: g[v]) tsort(u, k+1);
    visited[v]=2;
    res[v]=k;
}

int main()
{
    int n, m; cin>>n>>m;
    union_find_tree T(n+m);
    for(int i=0; i<n; ++i) {
        string s; cin>>s;
        for(int j=0; j<m; ++j) {
            if (s[j]=='<') g[i].push_back(j+n);
            else if (s[j]=='>') g[j+n].push_back(i);
            else T.unite(i, j+n);
        }
    }
    for(int i=0; i<n+m; ++i) if (!visited[i]) {
        NG=0;
        tsort(i, 1);
        if (NG) { cout<<"No"<<endl; return 0; }
    }
    for(int i=0; i<n+m; ++i) {
        for(int j=i+1; j<n+m; ++j) {
            if (T.same(i, j) != (res[i]==res[j])) {
                cout<<"No"<<endl;
                return 0;
            }
        }
    }
    cout<<"Yes"<<endl;
    for(int i=0; i<n; ++i) cout<<res[i]<<' ';
    cout<<endl;
    for(int i=n; i<n+m; ++i) cout<<res[i]<<' ';
    cout<<endl;
}


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

struct union_find_tree {
    std::vector<int> par, rank;
    union_find_tree(){}
    union_find_tree(int size)
    {
        par=std::vector<int>(size);
        rank=std::vector<int>(size);
        for(int i=0; i<size; ++i) par[i]=i;
    }
    int root(int x)
    {
        if (x==par[x]) return x;
        return par[x]=root(par[x]);
    }
    void unite(int x, int y)
    {
        x=root(x);
        y=root(y);
        if (x==y) return;
        if (rank[x]<rank[y]) {
            par[x]=y;
        }
        else {
            par[y]=x;
            if (rank[x]==rank[y]) ++rank[x];
        }
    }
    bool same(int x, int y)
    {
        return root(x)==root(y);
    }
};

unordered_set<int> g[2010];
int res[2010];
int visited[2010];
deque<int> L;
bool tsort(int v, int k)
{
    if (visited[v]==1) return false;
    if (visited[v]==2) return true;
    visited[v]=1;
    for(auto& u: g[v]) if (!tsort(u, k+1)) return false;
    visited[v]=2;
    L.push_front(v);
    return true;
}

int main()
{
    int n, m; cin>>n>>m;
    union_find_tree T(n+m);

    vector<string> a(n);
    vector<bool> deg0(n+m, true);
    for(int i=0; i<n; ++i) {
        cin>>a[i];
        for(int j=0; j<m; ++j) if (a[i][j]=='=') T.unite(i, j+n);
    }
    for(int i=0; i<n; ++i) {
        for(int j=0; j<m; ++j) {
            if (a[i][j]=='<') {
                g[T.root(i)].insert(T.root(j+n));
                deg0[T.root(j+n)]=false;
            }
            else if (a[i][j]=='>') {
                g[T.root(j+n)].insert(T.root(i));
                deg0[T.root(i)]=false;
            }
        }
    }
    for(int i=0; i<n+m; ++i) {
        int v=T.root(i);
        if (v!=i or visited[v] or !deg0[v]) continue;
        L.clear();
        if (!tsort(v, 1)) { cout<<"No"<<endl; return 0; }
        int k=1;
        res[L[0]]=k;
        for(int j=1; j<size(L); ++j) {
            if (g[L[j-1]].count(L[j])) ++k;
            res[L[j]]=k;
        }
    }
    for(int i=0; i<n+m; ++i) {
        res[i]=res[T.root(i)];
        if (res[i]==0) { cout<<"No"<<endl; return 0; }
    }

    cout<<"Yes"<<endl;
    for(int i=0; i<n+m; ++i) cout<<res[i]<<(i==n-1 ? '\n' : ' ');
    cout<<endl;
}


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

vector<int> g[2010];

struct union_find_tree {
    std::vector<int> par, rank;
    union_find_tree(){}
    union_find_tree(int size)
    {
        par=std::vector<int>(size);
        rank=std::vector<int>(size);
        for(int i=0; i<size; ++i) par[i]=i;
    }
    int root(int x)
    {
        if (x==par[x]) return x;
        return par[x]=root(par[x]);
    }
    void unite(int x, int y)
    {
        x=root(x);
        y=root(y);
        if (x==y) return;
        if (rank[x]<rank[y]) {
            par[x]=y;
        }
        else {
            par[y]=x;
            if (rank[x]==rank[y]) ++rank[x];
        }
    }
    bool same(int x, int y)
    {
        return root(x)==root(y);
    }
};

int res[2010];
int visited[2010];
bool tsort(int v, int k)
{
    if (visited[v]==1) return false;
    k=max(k, res[v]);
    if (visited[v]==2) {
        res[v]=k;
        return true;
    }
    visited[v]=1;
    for(auto& u: g[v]) if (!tsort(u, k+1)) return false;
    visited[v]=2;
    res[v]=k;
    return true;
}

int main()
{
    int n, m; cin>>n>>m;
    union_find_tree T(n+m);

    vector<string> a(n);
    unordered_set<int> S;
    for(int i=0; i<n+m; ++i) S.insert(i);
    for(int i=0; i<n; ++i) {
        cin>>a[i];
        for(int j=0; j<m; ++j) if (a[i][j]=='=') T.unite(i, j+n);
    }
    for(int i=0; i<n; ++i) {
        for(int j=0; j<m; ++j) {
            if (a[i][j]=='<') {
                g[T.root(i)].push_back(T.root(j+n));
                S.erase(T.root(j+n));
            }
            else if (a[i][j]=='>') {
                g[T.root(j+n)].push_back(T.root(i));
                S.erase(T.root(i));
            }
        }
    }
    for(int i=0; i<n+m; ++i) {
        int v=T.root(i);
        if (v!=i or visited[v] or !S.count(v)) continue;
        if (!tsort(v, 1)) { cout<<"No"<<endl; return 0; }
    }
    for(int i=0; i<n+m; ++i) {
        res[i]=res[T.root(i)];
        if (res[i]==0) { cout<<"No"<<endl; return 0; }
    }

    cout<<"Yes"<<endl;
    for(int i=0; i<n+m; ++i) cout<<res[i]<<(i==n-1 ? '\n' : ' ');
    cout<<endl;
}


#include<stdio.h>
int main()
{
int n,m,max=0,min=0,m1=0,i;
scanf("%d%d",&n,&m);
int a[n],b[m];
for(i=0;i<n;i++)
scanf("%d",&a[i]);
for(i=0;i<m;i++)
scanf("%d",&b[i]);
min=b[0];
for(i=1;i<m;i++)
{
if(b[i]<min)
min=b[i];
}
max=a[0];
for(i=1;i<n;i++)
{
if(a[i]>max)
max=a[i];
}
m1=a[0];
for(i=1;i<n;i++)
{
if(a[i]<m1)
m1=a[i];
}
if(2*max<min&&2*m1<=2*max)
{
max=2*max;
printf("%d",max);
}
else if(min>max&&2*m1<=max)
printf("%d",max);
else
printf("-1");
}


#include<stdio.h>
int main()
{
    int n,m,i,j,min,max,w_min;
    scanf("%d %d",&n,&m);
    max=0;min=101;w_min=101;
    for(i=0;i<n;i++)
    {
        scanf("%d",&j);
        if(min>j)
            min=j;
        if(max<j)
            max=j;
    }
    for(i=0;i<m;i++)
    {
        scanf("%d",&j);
        if(w_min>j)
            w_min=j;
    }
    if(max>=2*min&&w_min>max)
        printf("%d\n",max);
    else if(2*min<w_min)
        printf("%d\n",2*min);
    else
        printf("-1\n");
    return(0);
}


#include<stdio.h>
int main()
{
    int n,m,i,j,min,max,w_min;
    scanf("%d %d",&n,&m);
    max=0;min=101;w_min=101;
    for(i=0;i<n;i++)
    {
        scanf("%d",&j);
        if(min>j)
            min=j;
        if(max<j)
            max=j;
    }
    for(i=0;i<m;i++)
    {
        scanf("%d",&j);
        if(w_min>j)
            w_min=j;
    }
    if(max>=2*min&&w_min>max)
        printf("%d\n",max);
    else if(2*min<w_min&&max<w_min)
        printf("%d\n",2*min);
    else
        printf("-1\n");
    return(0);
}


#include <stdio.h>
int partition(int *A,int p,int r)
{
	int i=p-1,j=p;
	int key=A[r];
	while(j<=(r-1))
	{
		if(A[j]<=key)
		{
			i++;
			int temp=A[j];
			A[j]=A[i];
			A[i]=temp;
			j++;
		}
		else j++;
	}
	A[r]=A[i+1];
	A[i+1]=key;
	return i+1;
}

void quick_sort(int *A,int p,int r)
{
	if(p<r)
	{
		int q=partition(A,p,r);
		quick_sort(A,p,q-1);
		quick_sort(A,q+1,r);
	}
}
int main()
{
	int n,m;
	scanf("%d%d",&n,&m);
	int i,ca[n],wa[m];
	for(i=0;i<n;i++)
	scanf("%d",&ca[i]);
	for(i=0;i<m;i++)
	scanf("%d",&wa[i]);
	quick_sort(ca,0,n-1);
	quick_sort(wa,0,m-1);
	if(2*ca[0]>ca[n-1]||wa[0]<=ca[n-1])
	printf("-1\n");
	else printf("%d\n",ca[n-1]);
	return 0;
}


#include <stdio.h>
int partition(int *A,int p,int r)
{
	int i=p-1,j=p;
	int key=A[r];
	while(j<=(r-1))
	{
		if(A[j]<=key)
		{
			i++;
			int temp=A[j];
			A[j]=A[i];
			A[i]=temp;
			j++;
		}
		else j++;
	}
	A[r]=A[i+1];
	A[i+1]=key;
	return i+1;
}

void quick_sort(int *A,int p,int r)
{
	if(p<r)
	{
		int q=partition(A,p,r);
		quick_sort(A,p,q-1);
		quick_sort(A,q+1,r);
	}
}
int main()
{
	int n,m;
	scanf("%d%d",&n,&m);
	int i,ca[n],wa[m];
	for(i=0;i<n;i++)
	scanf("%d",&ca[i]);
	for(i=0;i<m;i++)
	scanf("%d",&wa[i]);
	quick_sort(ca,0,n-1);
	quick_sort(wa,0,m-1);
	if(2*ca[0]>ca[n-1]||wa[0]>=ca[n-1])
	printf("-1\n");
	else printf("%d\n",ca[n-1]);
	return 0;
}


#include <stdio.h>
int partition(int *A,int p,int r)
{
	int i=p-1,j=p;
	int key=A[r];
	while(j<=(r-1))
	{
		if(A[j]<=key)
		{
			i++;
			int temp=A[j];
			A[j]=A[i];
			A[i]=temp;
			j++;
		}
		else j++;
	}
	A[r]=A[i+1];
	A[i+1]=key;
	return i+1;
}

void quick_sort(int *A,int p,int r)
{
	if(p<r)
	{
		int q=partition(A,p,r);
		quick_sort(A,p,q-1);
		quick_sort(A,q+1,r);
	}
}
int main()
{
	int n,m;
	scanf("%d%d",&n,&m);
	int i,ca[n],wa[m];
	for(i=0;i<n;i++)
	scanf("%d",&ca[i]);
	for(i=0;i<m;i++)
	scanf("%d",&wa[i]);
	//sorting
	quick_sort(ca,0,n-1);
	quick_sort(wa,0,m-1);
	if(2*ca[0]>=wa[0]||wa[0]<=ca[n-1])
	printf("-1\n");
	else if (2*ca[0]>ca[n-1]) printf("%d\n",2*ca[0]);
	else if (2*ca[0]<=ca[n-1]) printf("%d\n",ca[n-1]);
	return 0;
}


#include <stdio.h>
int partition(int *A,int p,int r)
{
	int i=p-1,j=p;
	int key=A[r];
	while(j<=(r-1))
	{
		if(A[j]<=key)
		{
			i++;
			int temp=A[j];
			A[j]=A[i];
			A[i]=temp;
			j++;
		}
		else j++;
	}
	A[r]=A[i+1];
	A[i+1]=key;
	return i+1;
}

void quick_sort(int *A,int p,int r)
{
	if(p<r)
	{
		int q=partition(A,p,r);
		quick_sort(A,p,q-1);
		quick_sort(A,q+1,r);
	}
}
int main()
{
	int n,m;
	scanf("%d%d",&n,&m);
	int i,ca[n],wa[m];
	for(i=0;i<n;i++)
	scanf("%d",&ca[i]);
	for(i=0;i<m;i++)
	scanf("%d",&wa[i]);
	//sorting
	quick_sort(ca,0,n-1);
	quick_sort(wa,0,m-1);
	if(2*ca[0]>wa[0]||wa[0]<=ca[n-1])
	printf("-1\n");
	else if(2*ca[0]>ca[n-1]&&2*ca[0]<wa[0]) printf("%d\n",2*ca[0]);
	else if(2*ca[0]<ca[n-1]&&ca[n-1]<wa[0]) printf("%d\n",ca[n-1]);
	return 0;
}


#include <stdio.h>
int partition(int *A,int p,int r)
{
	int i=p-1,j=p;
	int key=A[r];
	while(j<=(r-1))
	{
		if(A[j]<=key)
		{
			i++;
			int temp=A[j];
			A[j]=A[i];
			A[i]=temp;
			j++;
		}
		else j++;
	}
	A[r]=A[i+1];
	A[i+1]=key;
	return i+1;
}

void quick_sort(int *A,int p,int r)
{
	if(p<r)
	{
		int q=partition(A,p,r);
		quick_sort(A,p,q-1);
		quick_sort(A,q+1,r);
	}
}
int main()
{
	int n,m;
	scanf("%d%d",&n,&m);
	int i,ca[n],wa[m];
	for(i=0;i<n;i++)
	scanf("%d",&ca[i]);
	for(i=0;i<m;i++)
	scanf("%d",&wa[i]);
	quick_sort(ca,0,n-1);
	quick_sort(wa,0,m-1);
	if(2*ca[0]>ca[n-1])
	printf("-1\n");
	else printf("%d\n",ca[n-1]);
	return 0;
}


#include <stdio.h>
int partition(int *A,int p,int r)
{
    int i=p-1,j=p;
    int key=A[r];
    while(j<=(r-1))
    {
        if(A[j]<=key)
        {
            i++;
            int temp=A[j];
            A[j]=A[i];
            A[i]=temp;
            j++;
        }
        else j++;
    }
    A[r]=A[i+1];
    A[i+1]=key;
    return i+1;
}

void quick_sort(int *A,int p,int r)
{
    if(p<r)
    {
        int q=partition(A,p,r);
        quick_sort(A,p,q-1);
        quick_sort(A,q+1,r);
    }
}
int main()
{
    int n,m;
    scanf("%d%d",&n,&m);
    int i,ca[n],wa[m];
    for(i=0;i<n;i++)
    scanf("%d",&ca[i]);
    for(i=0;i<m;i++)
    scanf("%d",&wa[i]);
    quick_sort(ca,0,n-1);
    quick_sort(wa,0,m-1);
    if(2*ca[0]>ca[n-1]||wa[0]>=ca[n-1])
    printf("-1\n");
    else printf("%d",ca[n-1]);
    return 0;
}


#include <stdio.h>
int partition(int *A,int p,int r)
{
	int i=p-1,j=p;
	int key=A[r];
	while(j<=(r-1))
	{
		if(A[j]<=key)
		{
			i++;
			int temp=A[j];
			A[j]=A[i];
			A[i]=temp;
			j++;
		}
		else j++;
	}
	A[r]=A[i+1];
	A[i+1]=key;
	return i+1;
}

void quick_sort(int *A,int p,int r)
{
	if(p<r)
	{
		int q=partition(A,p,r);
		quick_sort(A,p,q-1);
		quick_sort(A,q+1,r);
	}
}
int main()
{
	int n,m;
	scanf("%d%d",&n,&m);
	int i,ca[n],wa[m];
	for(i=0;i<n;i++)
	scanf("%d",&ca[i]);
	for(i=0;i<m;i++)
	scanf("%d",&wa[i]);
	//sorting
	quick_sort(ca,0,n-1);
	quick_sort(wa,0,m-1);
	if(2*ca[0]>=wa[0]||wa[0]<=ca[n-1])
	printf("-1\n");
	else printf("%d\n",ca[n-1]);
	return 0;
}


#include <stdio.h>
int partition(int *A,int p,int r)
{
    int i=p-1,j=p;
    int key=A[r];
    while(j<=(r-1))
    {
        if(A[j]<=key)
        {
            i++;
            int temp=A[j];
            A[j]=A[i];
            A[i]=temp;
            j++;
        }
        else j++;
    }
    A[r]=A[i+1];
    A[i+1]=key;
    return i+1;
}

void quick_sort(int *A,int p,int r)
{
    if(p<r)
    {
        int q=partition(A,p,r);
        quick_sort(A,p,q-1);
        quick_sort(A,q+1,r);
    }
}
int main()
{
    int n,m;
    scanf("%d%d",&n,&m);
    int i,ca[n],wa[m];
    for(i=0;i<n;i++)
    scanf("%d",&ca[i]);
    for(i=0;i<m;i++)
    scanf("%d",&wa[i]);
    quick_sort(ca,0,n-1);
    if(2*ca[0]>ca[n-1])
    printf("-1\n");
    else printf("%d",ca[n-1]);
    return 0;
}


#include <stdio.h>
int partition(int *A,int p,int r)
{
	int i=p-1,j=p;
	int key=A[r];
	while(j<=(r-1))
	{
		if(A[j]<=key)
		{
			i++;
			int temp=A[j];
			A[j]=A[i];
			A[i]=temp;
			j++;
		}
		else j++;
	}
	A[r]=A[i+1];
	A[i+1]=key;
	return i+1;
}

void quick_sort(int *A,int p,int r)
{
	if(p<r)
	{
		int q=partition(A,p,r);
		quick_sort(A,p,q-1);
		quick_sort(A,q+1,r);
	}
}
int main()
{
	int n,m;
	scanf("%d%d",&n,&m);
	int i,ca[n],wa[m];
	for(i=0;i<n;i++)
	scanf("%d",&ca[i]);
	for(i=0;i<m;i++)
	scanf("%d",&wa[i]);
	//sorting
	quick_sort(ca,0,n-1);
	quick_sort(wa,0,m-1);
	if(wa[0]<=ca[n-1])
	printf("-1\n");
	else if(2*ca[0]>ca[n-1]&&2*ca[0]<wa[0]) printf("%d\n",2*ca[0]);
	else if(2*ca[0]<ca[n-1]&&ca[n-1]<wa[0]) printf("%d\n",ca[n-1]);
	return 0;
}


#include <stdio.h>
int partition(int *A,int p,int r)
{
	int i=p-1,j=p;
	int key=A[r];
	while(j<=(r-1))
	{
		if(A[j]<=key)
		{
			i++;
			int temp=A[j];
			A[j]=A[i];
			A[i]=temp;
			j++;
		}
		else j++;
	}
	A[r]=A[i+1];
	A[i+1]=key;
	return i+1;
}

void quick_sort(int *A,int p,int r)
{
	if(p<r)
	{
		int q=partition(A,p,r);
		quick_sort(A,p,q-1);
		quick_sort(A,q+1,r);
	}
}
int main()
{
	int n,m;
	scanf("%d%d",&n,&m);
	int i,ca[n],wa[m];
	for(i=0;i<n;i++)
	scanf("%d",&ca[i]);
	for(i=0;i<m;i++)
	scanf("%d",&wa[i]);
	//sorting
	quick_sort(ca,0,n-1);
	quick_sort(wa,0,m-1);
	if(2*ca[0]>ca[n-1]||wa[0]<=ca[n-1])
	printf("-1\n");
	else printf("%d\n",ca[n-1]);
	return 0;
}


#include <stdio.h>
int partition(int *A,int p,int r)
{
	int i=p-1,j=p;
	int key=A[r];
	while(j<=(r-1))
	{
		if(A[j]<=key)
		{
			i++;
			int temp=A[j];
			A[j]=A[i];
			A[i]=temp;
			j++;
		}
		else j++;
	}
	A[r]=A[i+1];
	A[i+1]=key;
	return i+1;
}

void quick_sort(int *A,int p,int r)
{
	if(p<r)
	{
		int q=partition(A,p,r);
		quick_sort(A,p,q-1);
		quick_sort(A,q+1,r);
	}
}
int main()
{
	int n,m;
	scanf("%d%d",&n,&m);
	int i,ca[n],wa[m];
	for(i=0;i<n;i++)
	scanf("%d",&ca[i]);
	for(i=0;i<m;i++)
	scanf("%d",&wa[i]);
	//sorting
	quick_sort(ca,0,n-1);
	quick_sort(wa,0,m-1);
	if(wa[0]<=ca[n-1])
	printf("-1\n");
	else if(2*ca[0]>ca[n-1]&&2*ca[0]<wa[0]) printf("%d\n",2*ca[0]);
	else if(2*ca[0]<ca[n-1]) printf("%d\n",ca[n-1]);
	return 0;
}


#include<stdio.h>
int main()
{
    int n,m,ma,lb,c=0,la;
    scanf("%d%d",&n,&m);
    int i,a[n],b[m];
    ma=0;
    //la=101;
    for (i=0;i<n;i++)   //first array'r highest
    {
        scanf("%d",&a[i]);
        if (a[i]>ma) ma=a[i];
    //  if (a[i]<la) la=a[i];
    }
    lb=101;
    for (i=0;i<m;i++) //second array'r lowest
    {
        scanf("%d",&b[i]);
        if(b[i]<lb) lb=b[i];
    }
    // first array te digun khujum,counter f***
    for (i=0;i<n;i++)
    {
        if (2*a[i]<=ma) c=1;
    }
    if (c==1 && ma<lb) printf("%d",ma);
    else printf("-1");

}


#include<stdio.h>
int main()
{
    int n,m,ma,lb,c=0,la;
    scanf("%d%d",&n,&m);
    int i,a[n],b[m];
    ma=0;
    la=101;
    for (i=0;i<n;i++)   //first array'r highest
    {
        scanf("%d",&a[i]);
        if (a[i]>ma) ma=a[i];
        if (a[i]<la) la=a[i];
    }
    lb=101;
    for (i=0;i<m;i++) //second array'r lowest
    {
        scanf("%d",&b[i]);
        if(b[i]<lb) lb=b[i];
    }
//  // first array te digun khujum,counter f***
//  for (i=0;i<n;i++)
//  {
//      if (2*a[i]<=ma) c=1;
//  }
//  if (c==1 && lb>2*ma) printf("%d",ma);
//  else printf("-1");
    if ((2*la)>ma)
    {
        c=2*la;
    }
    else c=ma;
    if (c<lb) printf("%d",c);
    else printf("-1");

}


#include<stdio.h>
int main()
{
	int n,m,ma,lb,c=0,la;
	scanf("%d%d",&n,&m);
	int i,a[n],b[m];
	ma=0;
	//la=101;
	for (i=0;i<n;i++) 	//first array'r highest
	{
		scanf("%d",&a[i]);
		if (a[i]>ma) ma=a[i];
	//	if (a[i]<la) la=a[i];
	}
	lb=101;
	for (i=0;i<m;i++) //second array'r lowest
	{
		scanf("%d",&b[i]);
		if(b[i]<lb) lb=b[i];
	}
	// first array te digun khujum,counter f***
	for (i=0;i<n;i++)
	{
		if (2*a[i]<=ma) c=1;
	}
	if (c==1 && ma<lb) printf("%d",ma);
	else if (n==1 && lb>2*ma) printf("%d",2*ma);
	else printf("-1");

}


#include<stdio.h>
int main()
{
    int n,m,ma,lb,c=0,la;
    scanf("%d%d",&n,&m);
    int i,a[n],b[m];
    ma=0;
    //la=101;
    for (i=0;i<n;i++)   //first array'r highest
    {
        scanf("%d",&a[i]);
        if (a[i]>ma) ma=a[i];
    //  if (a[i]<la) la=a[i];
    }
    lb=101;
    for (i=0;i<m;i++) //second array'r lowest
    {
        scanf("%d",&b[i]);
        if(b[i]<lb) lb=b[i];
    }
    // first array te digun khujum,counter f***
    for (i=0;i<n;i++)
    {
        if (2*a[i]<=ma) c=1;
    }
    if (c==1 && ma<lb) printf("%d",ma);
    else if (n==1 && lb>1) printf("%d",2*ma);
    else printf("-1");

}


#include <stdio.h>

int main(void){
	int n,m;
	int i;
	int a[200];
	int b[200];
	int maxa=0,mina=200,minb=200;
	scanf("%d%d",&n,&m);
	for (i=0; i<n; i++){
		scanf("%d",&a[i]);
		if (a[i]>maxa)
			maxa=a[i];
		if (a[i]<mina)
			mina=a[i];
	}
	for (i=0; i<m; i++){
		scanf("%d",&b[i]);
			if (b[i]<minb)
				minb=b[i];
	}
	if (maxa<minb&&2*mina<=minb-1)
		printf("%d",2*mina);
	else
		printf("-1");
	return 0;
}


#include <stdio.h>

int main(void){
	int n,m;
	int i;
	int a[200];
	int b[200];
	int maxa=0,mina=200,minb=200;
	scanf("%d%d",&n,&m);
	for (i=0; i<n; i++){
		scanf("%d",&a[i]);
		if (a[i]>maxa)
			maxa=a[i];
		if (a[i]<mina)
			mina=a[i];
	}
	for (i=0; i<m; i++){
		scanf("%d",&b[i]);
			if (b[i]<minb)
				minb=b[i];
	}
	if (maxa<minb&&2*mina<=minb-1)
	{
		if (2*mina>maxa)
			printf("%d",2*mina);
		else
			printf("%d",maxa);
	}
	else
		printf("-1");
	return 0;
}


#include <stdio.h>

int main(void){
    int n,m;
    int i;
    int a[200];
    int b[200];
    int maxa=0,mina=200,minb=200;
    scanf("%d%d",&n,&m);
    for (i=0; i<n; i++){
        scanf("%d",&a[i]);
        if (a[i]>maxa)
            maxa=a[i];
        if (a[i]<mina)
            mina=a[i];
    }
    for (i=0; i<m; i++){
        scanf("%d",&b[i]);
            if (b[i]<minb)
                minb=b[i];
    }
    if (maxa<minb&&2*mina<=minb-1)
        printf("%d",minb-1);
    else
        printf("-1");
    return 0;
}


#include <stdio.h>

int main(void){
	int n,m;
	int i;
	int a[200];
	int b[200];
	int maxa=0,mina=200,minb=200;
	scanf("%d%d",&n,&m);
	for (i=0; i<n; i++){
		scanf("%d",&a[i]);
		if (a[i]>maxa)
			maxa=a[i];
		if (a[i]<mina)
			mina=a[i];
	}
	for (i=0; i<m; i++){
		scanf("%d",&b[i]);
			if (b[i]<minb)
				minb=b[i];
	}
	if (maxa<minb&&2*mina<maxa)
		printf("%d",maxa);
	else
		printf("-1");
	return 0;
}


#include<stdio.h>

int main()
{
int n,m,i;
int max=0;
int min=101,mA=101;
scanf("%d %d",&n,&m);
int a[n],b[m];

for(i=0;i<n;i++)
	{
	scanf("%d",&a[i]);
	if(a[i]>max)
		max=a[i];
	if(a[i]<mA)
		mA=a[i];
	}

for(i=0;i<m;i++)
	{
	scanf("%d",&b[i]);
	if(b[i]<min)
		min=b[i];
	}

if(min<=max)
	printf("-1");
else
	{
	if(max>=2*mA)
		printf("%d",max);
	else
		printf("-1");
	}

return 0;
}


#include<stdio.h>

int main()
{
int n,m,i,res;
int maxc=0;
int minw=101,minc=101;
scanf("%d %d",&n,&m);
int a[n],b[m];

for(i=0;i<n;i++)
    {
    scanf("%d",&a[i]);
    if(a[i]>maxc)
        maxc=a[i];
    if(a[i]<minc)
        minc=a[i];
    }

for(i=0;i<m;i++)
    {
    scanf("%d",&b[i]);
    if(b[i]<minw)
        minw=b[i];
    }

if(maxc<minw)
    {
    res=2*minc;
    if(res>=maxc)
        {
        if(res<minw)
            printf("%d",res);
        else
            printf("-1");
        }
    else
        printf("%d",maxc);
    }
else
    printf("-1");

return 0;
}


#include<stdio.h>
//#include<conio.h>
int main()
{
 int n,m,min1,min2,max,ans,i,a[105],b[105],found=0;
// printf("Enter the values of n and m:");
 scanf("%d %d",&n,&m);
 for(i=1;i<=n;i++)
 {
  scanf("%d",&a[i]);
  if(i==1)
  {
   min1=a[i];
   max=a[i];
  }
  if(a[i]<min1)
  min1=a[i];
  if(a[i]>max)
  max=a[i];
 }
 for(i=1;i<=m;i++)
 {
  scanf("%d",&b[i]);
  if(i==1)
  min2=b[i];
  if(b[i]<min2)
  min2=b[i];
 }
 ans=max;
 while(found<1)
 {
  if(2*min1<=ans && min2>ans)
  found=1;
  else if(ans==min2)
  {
   found=1;
   ans=-1;
  }
  else
  ans++;
 }
 printf("%d",ans);
// getch();
// clrscr();
return 0;
}


#include<stdio.h>
//#include<conio.h>
int main()
{
 int n,m,min1,min2,max,ans,i,a[105],b[105],found=0;
// printf("Enter the values of n and m:");
 scanf("%d %d",&n,&m);
 for(i=1;i<=n;i++)
 {
  scanf("%d",&a[i]);
  if(i==1)
  {
   min1=a[i];
   max=a[i];
  }
  if(a[i]<min1)
  min1=a[i];
  if(a[i]>max)
  max=a[i];
 }
 for(i=1;i<=m;i++)
 {
  scanf("%d",&b[i]);
  if(i==1)
  min2=b[i];
  if(b[i]<min2)
  min2=b[i];
 }
 ans=max;
 while(found<1)
 {
  if(2*min1<=ans && min2>ans)
  found=1;
  else if(ans>=min2)
  {
   found=1;
   ans=-1;
  }
  else
  ans++;
 }
 printf("%d",ans);
// getch();
// clrscr();
return 0;
}


#include <stdio.h>

int main()
{
	int i;
	int m, n;
	int a;
	int v;
	int minn = 100, maxn = 1, minm = 100;
	scanf("%d%d", &n, &m);
	for(i = 0; i < n; i++)
	{
		scanf("%d", &a);
		if(a < minn)
			minn = a;
		if(a > maxn)
			maxn = a;
	}
	for(i = 0; i < m; i++)
	{
		scanf("%d", &a);
		if(a < minm)
			minm = a;
	}
	v = minn * 2;
	if(maxn > v)
		v = maxn;
	if(v >= minm)
		printf("-1\n");
	else
		printf("%d\n", v);
	return 0;
}


By zhaohaoshu, contest: Codeforces Round #203 (Div. 2), problem: (A) TL, Accepted, #

#include <stdio.h>

int main()
{
	int i;
	int m, n;
	int a;
	int v;
	int minn = 100, maxn = 1, minm = 100;
	scanf("%d%d", &n, &m);
	for(i = 0; i < n; i++)
	{
		scanf("%d", &a);
		if(a < minn)
			minn = a;
		if(a > maxn)
			maxn = a;
	}
	for(i = 0; i < m; i++)
	{
		scanf("%d", &a);
		if(a < minm)
			minm = a;
	}
	v = minn * 2;
	if(maxn > v)
		v = maxn;
	if(v >= minm)
		printf("-1\n");
	else
		printf("%d\n", v);
	return 0;
}


#include<stdio.h>
int main()
{
	int n,m;
	scanf("%d%d",&n,&m);
	int a[n],b[m],i,j,k=0,t,max=0,min=100000,maxb=0;
	for(i=0;i<n;i++)
	{
		scanf("%d",&a[i]);
		if(a[i]>max)
			max=a[i];
		if(a[i]<min)min=a[i];
	}
	for(i=0;i<m;i++)
	{
		scanf("%d",&b[i]);
		if(maxb<b[i])
		{
			maxb=b[i];
		}
	}
	for(i=0;i<m;i++)
		if(b[i]>=2*min&&b[i]>=max&&b[i]!=maxb)
		{
			k=b[i];
		}

	if(2*min<=max&&max<maxb)
		printf("%d",max);
	else
	{
		if(k==0)
			printf("-1");
		else
			printf("%d",k);
	}
	return 0;
}


#include<stdio.h>
int main()
{
	int n,m;
	scanf("%d%d",&n,&m);
	int a[n],b[m],i,j,k=0,t,max=0,min=100000,maxb=0;
	for(i=0;i<n;i++)
	{
		scanf("%d",&a[i]);
		if(a[i]>max)
			max=a[i];
		if(a[i]<min)min=a[i];
	}
	for(i=0;i<m;i++)
	{
		scanf("%d",&b[i]);
		if(maxb<b[i])
		{
			maxb=b[i];
		}
	}
	for(i=0;i<m;i++)
		if(b[i]>=2*min&&b[i]>=max&&b[i]!=maxb)
		{
			k=b[i];
		}

	if(2*min<=max)
		printf("%d",max);
	else
	{
		if(k==0)
			printf("-1");
		else
			printf("%d",k);
	}
	return 0;
}


#include <stdio.h>
#include<math.h>
#include<string.h>
int main(void) {
int n,m,i,j,temp,freq;
scanf("%d%d",&n,&m);
int a[n],b[m];
for(i=0;i<n;i++){
  scanf("%d",&a[i]);
}
for(i=0;i<m;i++){
  scanf("%d",&b[i]);
}
for(i=0;i<n;i++){
  for(j=i+1;j<n;j++){
if(a[i]>a[j]){
  temp=a[i];
  a[i]=a[j];
  a[j]=temp;
}
  }
}
for(i=0;i<m;i++){
  for(j=i+1;j<m;j++){
if(b[i]>b[j]){
  temp=b[i];
  b[i]=b[j];
  b[j]=temp;
}
  }
}
 i=2*a[0];
while(1){freq=0;

  for(j=0;j<n;j++){
    if(i>=a[j]){
      freq++;
    }
  }
  if(freq==n){
    break;
  }
  i++;
}
if(i<b[0]){
  printf("%d",i);
}
else{
  printf("-1");
}
  return 0;
}


#include<stdio.h>

int main(){
    int small, large, wsmall, n ,m;
    int arr[101] = {0}, brr[101] = {0}, i, j;
    scanf("%d %d", &n, &m);
    for(i=0; i<n; i++){
        scanf("%d", &j);
        arr[j]++;
    }
    for(i=0; i<m; i++){
        scanf("%d", &j);
        brr[j]++;
    }
    for(i=0; i<101; i++){
        if(arr[i]){
            small = i;
            break;
        }
    }
    for(i=100; i>=0; i--){
        if(arr[i]){
            large = i;
            break;
        }
    }
    for(i=0; i<101; i++){
        if(brr[i]){
            wsmall = i;
            break;
        }
    }
   if(large > wsmall || (2 * small) >= wsmall){
        printf("-1");
    }
    else{
        if(large > (2 * small)){
            printf("%d", large);
        }
        else{
            printf("%d", (2 * small));
        }
    }
return 0;
}


#include<stdio.h>

int main(){
    int small, large, wsmall, n ,m;
    int arr[101] = {0}, brr[101] = {0}, i, j;
    scanf("%d %d", &n, &m);
    for(i=0; i<n; i++){
        scanf("%d", &j);
        arr[j]++;
    }
    for(i=0; i<m; i++){
        scanf("%d", &j);
        brr[j]++;
    }
    for(i=0; i<101; i++){
        if(arr[i]){
            small = i;
            break;
        }
    }
    for(i=100; i>=0; i--){
        if(arr[i]){
            large = i;
            break;
        }
    }
    for(i=0; i<101; i++){
        if(brr[i]){
            wsmall = i;
            break;
        }
    }
    if((2*small) > large)
        printf("-1");
    else if(large > wsmall){
        printf("-1");
    }
    else{
        printf("%d", large);
    }
return 0;
}