#ifdef _MSC_VER
#define _CRT_SECURE_NO_WARNINGS
#endif
#include<bits/stdc++.h>
#include<chrono>
#include<unordered_map>
#include<random>
#include<complex>
using namespace std;
typedef complex<long double> point;
#define vec(a,b) ((b)-(a))
#define X real()
#define Y imag()
#define length(v) ((long double)hypot((v).Y,(v).X))
#define cross(a,b) ((conj(a)*(b)).imag())
#define ll long long
#define ld long double
#define ull unsigned ll
#define endl '\n'
#define mk make_pair
#ifndef ONLINE_JUDGE
int __builtin_popcount(int mask) {
	int cnt = 0;
	for (int i = 0; i < 23; i++)
		if (mask & (1 << i)) ++cnt;
	return cnt;
}
#endif
void fast_in_out() {
	std::ios_base::sync_with_stdio(NULL);
	cin.tie(NULL); cout.tie(NULL);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}
int dx[] = { 0,0,-1,1,-1,1,-1,1,0 };
int dy[] = { -1,1,0,0,-1,-1,1,1,0 };
int lx[] = { 2, 2, -1, 1, -2, -2, -1, 1 };
int ly[] = { -1, 1, 2, 2, 1, -1, -2, -2 };
const ld eps = 1e-9;
const int N = 1e3 + 50, M = 1e5 + 10, mod = 1e9+7;
ll gcd(ll a, ll b) {  return b ?gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { ll t = gcd(a, b); return t ? (a / t * b) : 0; }
bool prm[N];
int take[N];
int sieve(int n,int nn) {
	memset(prm, 1, sizeof prm);
	prm[0] = prm[1] = 0;
	int cnt = 0;
	for (int i = 2; i <= n; i++) {
		if (prm[i]) {
			for (int j = i; j <= nn; j += i)
				take[j] = 1, prm[j] = 0;
		}
	}
	for (int i = 1; i <= nn; i++)
		cnt += take[i];
	return cnt;
}
int main() {
	fast_in_out();
	//cout << fixed << setprecision(9);
	string s;
	cin >> s;
	int n = s.size();
	int ar[26]{ 0 };
	int mx = 0,id=-1;
	for (auto e : s) {
		ar[e - 'a']++;
		if (ar[e - 'a'] > mx) {
			mx = ar[e - 'a'];
			id = e - 'a';
		}
	}
	int cnt=sieve(n/2,n);
	if (mx >= cnt) {
		cout << "YES\n";
		string ss = "";
		for (auto e : s)
			if (e == (id + 'a'))
				ss += e;
		for (auto e : s)
			if (e != (id + 'a'))
				ss += e;
		for (int i = 1; i <= n; i++) {
			if (take[i]) s[i - 1] = id + 'a';
			else s[i - 1] = ss.back(), ss.pop_back();
		}
		cout << s;
	}
	else {
		cout << "NO\n";
	}
	return 0;

}


#include <bits/stdc++.h>
using namespace std;
#define all(c) (c).begin(), (c).end()
#define pb push_back
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;

bool isP(int a) {
	if(a <= 1) return false;
	for(int i = 2; i * i <= a; i++)
		if(a%i == 0) return false;
	return true;
}

int main() {
    std::ios::sync_with_stdio(false); cin.tie(NULL);
 	string s; cin >> s;
	int n = s.size();

	vi primes;

	for(int i = 1; i <= n; i++)
		if(isP(i)) primes.pb(i);

	int b[n+5];
	memset(b, 0, sizeof(b));
	int ind = 1;

	for(auto p:primes) {
		int other = -1;
		for(int i = 1; i * p <= n; i++)
			if(b[i*p]) other = b[i];

		if(other == -1) other = ind++;

		for(int i = 1; i * p <= n; i++)
			b[i*p] = other;
	}

	for(int i = 1; i <= n; i++)
		if(b[i] == 0) b[i] = ind++;

	int cnt[30];
	memset(cnt, 0, sizeof(cnt));

	for(int i = 0; i < n; i++)
		cnt[s[i]-'a']++;

	int cnt2[ind+5];
	memset(cnt2, 0, sizeof(cnt2));

	for(int i = 1; i <= n; i++)
		cnt2[b[i]]++;

	vector<char> a(ind+5);
	bool ok = true;
	for(int i = 1; i < ind; i++) {
		bool comp = false;
		for(int j = 0; j < 26; j++) {
			if(cnt2[i] <= cnt[j]) {
				cnt[j] -= cnt2[i];
				comp = true;
				a[i] = j+'a';
				break;
			}
		}
		if(!comp) ok = false;
	}

	if(!ok) cout << "NO";
	else {
		cout << "YES\n";
		for(int i = 1; i <= n; i++)
			cout << a[b[i]];
	}

    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define loop(i,b,e) for(int i=b;i<=e;i++)
#define loop2(i,e,b) for(int i=e;i>=b;i--)
#define io ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define fi first
#define se second
#define X real()
#define Y imag()
#define cp(a,b)	( (conj(a)*(b)).imag() )
#define length(a) (hypot((a).imag(), (a).real()))
typedef complex<double> point;
typedef long long ll;
typedef unsigned long long ull;
double PI = 3.141592653589793;
const double EPS = 1e-9;
const int N = 1e6 + 5;
const ll mod = 1e9 + 7;
const int oo = 1e9;
int dx[] = { 0, 0, 1, -1, 1, -1, 1, -1 };
int dy[] = { 1, -1, 0, 0, -1, 1, 1, -1 };

int freq[30];
string s;
bool prime[1005];

void generateprime(int n) {
	int i;
	for (i = 0; i <= n; i++)
		prime[i] = true;
	for (i = 2; i*i <= n; i++)
		if (prime[i] == true)
			for (int j = i; i*j <= n; j++)
				prime[i*j] = false;
}

int main() {
	generateprime(1001);
	cin >> s;
	char cmx = 'a';
	loop(i, 0, s.size() - 1) {
		freq[s[i] - 'a']++;
		if (freq[cmx - 'a'] < freq[s[i] - 'a'])
			cmx = s[i];
		s[i] = '?';
	}
	bool yes = 1;
	for (int i = 1; i < s.size() && yes; i++) {
		if (s[i] != '?' || (i + 1) * 2 > s.size()) continue;
		for (int j = i; j < s.size(); j += (i + 1)) {
			if (s[j] != '?') continue;
			if (freq[cmx - 'a'] == 0) {
				yes = 0;
				break;
			}
			freq[cmx - 'a']--;
			s[j] = cmx;
		}
	}
	if (!yes) {
		cout << "NO";
		return 0;
	}
	char j = 'a';
	loop(i, 0, s.size() - 1) {
		if (s[i] != '?') continue;
		while (freq[j - 'a'] == 0) j++;
		freq[j - 'a']--;
		s[i] = j;
	}
	cout << "YES" << endl << s;
}


#include <bits/stdc++.h>
using namespace std;
#define loop(i,b,e) for(int i=b;i<=e;i++)
#define loop2(i,e,b) for(int i=e;i>=b;i--)
#define io ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define fi first
#define se second
#define X real()
#define Y imag()
#define cp(a,b)	( (conj(a)*(b)).imag() )
#define length(a) (hypot((a).imag(), (a).real()))
typedef complex<double> point;
typedef long long ll;
typedef unsigned long long ull;
double PI = 3.141592653589793;
const double EPS = 1e-9;
const int N = 1e6 + 5;
const ll mod = 1e9 + 7;
const int oo = 1e9;
int dx[] = { 0, 0, 1, -1, 1, -1, 1, -1 };
int dy[] = { 1, -1, 0, 0, -1, 1, 1, -1 };

int freq[30];
string s;

int main() {
	io;
	cin >> s;
	char cmx = 'a';
	loop(i, 0, s.size() - 1) {
		freq[s[i] - 'a']++;
		if (freq[cmx - 'a'] < freq[s[i] - 'a'])
			cmx = s[i];
		s[i] = '?';
	}
	bool yes = 1;
	for (int i = 1; i < s.size() && yes; i++) {
		if (s[i] != '?' || (i + 1) * 2 > s.size()) continue;
		for (int j = i; j < s.size(); j += (i + 1)) {
			if (s[j] != '?') continue;
			if (freq[cmx - 'a'] == 0) {
				yes = 0;
				break;
			}
			freq[cmx - 'a']--;
			s[j] = cmx;
		}
	}
	if (!yes) {
		cout << "NO";
		return 0;
	}
	char j = 'a';
	loop(i, 0, s.size() - 1) {
		if (s[i] != '?') continue;
		while (freq[j - 'a'] == 0) j++;
		freq[j - 'a']--;
		s[i] = j;
	}
	cout << "YES" << endl << s;
}


#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdalign>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
using namespace std;
#pragma warning(disable : 4996)

#define all(v)             v.begin(),v.end()
#define sz(v)            ((int)((v).size()))
#define psh(x)                  push_back(x)
#define sc(x)                 scanf("%d",&x)
#define sc2(x,y)         scanf("%d%d",&x,&y)
#define scl(x)              scanf("%lld",&x)
#define scl2(x,y)              scanf("%lld%lld",&x,&y)
#define lop(i,n)        for(register int i=0;i<n;i++)
#define loop(i,f,l)     for(register int i=f;i<l;i++)
#define R_(s)         freopen(s, "r", stdin)
#define W_(s)        freopen(s, "w", stdout)
#define R_W R_("input.txt"),W_("output.txt")
#define PI                        acos(-1.0)
#define INF                       1000000000
#define DFS_GRAY  -1
#define DFS_WHITE  0
#define DFS_BLACK  1

#define fr first
#define sc second
#define loopm(i,f,l)     for(register int i=f;i>l;i--)

#define IO 				std::ios_base::sync_with_stdio(0);cin.tie(NULL)

#define scc(x)           scanf("%c",&x)
#define mem(v, d)		memset(v, d, sizeof(v))
#define oo				2000000100
#define OO				4000000000000000100
typedef unsigned int uint;
typedef unsigned long long ull;

typedef string            ss;
typedef long long         ll;
typedef pair <int, int>   ii;
typedef pair<ss, int>     si;
typedef pair<int, ss>     is;
typedef pair<char, int>  chi;
typedef pair<ss, ss>     pss;
typedef vector<ii>       vii;
typedef vector<int>       vi;
typedef vector<vi>       vvi;
typedef vector<ss>        vs;
typedef vector<ll>       vll;
typedef vector<vll>     vvll;

//-----------------------------------------------------

const ll MOD = 1e9 + 7;

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

ll GCD(ll num, ll ones) { return !ones ? num : GCD(ones, num % ones); }
ll lcm(ll a, ll b) { return (a / GCD(a, b)) * b; }
double Len(int x, int y, int X, int Y) { return sqrt((X - x) * (X - x) + (Y - y) * (Y - y)); }
ll fastP(ll b, ll p)
{
    if (p == 0) return 1;
    else if (p == 1) return b;
    ll a = fastP(b, p / 2) % MOD;
    if (p % 2) return (((a * a) % MOD) * b) % MOD;
    else return (a * a) % MOD;
}
//----------------- ------   -------

const int N = 200005;
const double EPS = 1e-9;

int solve(int test)
{
    string str;cin >> str;
    vector<int>v(27, 0);
    vector<int>out(sz(str), -1);
    int mx = 0;
    lop(i, sz(str))
        if (++v[str[i] - 'a'] > v[mx])mx =str[i] - 'a';
    loop(i, 2, sz(str) + 1)
    {
        if (sz(str) / i < 2||~out[i-1])continue;
        for (int j = i; j <= sz(str); j += i)
        {
            if (~out[j-1])continue;
            if (!v[mx])
                return cout << "NO\n", 0;
            out[j - 1] = mx;
            v[mx]--;
        }
    }
    cout << "YES\n";
    lop(i, sz(str))
        if (~out[i])
            cout << char(out[i] + 'a');
        else
            lop(i,27)
            if (v[i])
            {
                v[i]--;
                cout << char(i + 'a');
                break;
            }
    cout << "\n";
    return test;
}

int main()
{
    IO;

    int t = 1;
#ifndef ONLINE_JUDGE
    freopen("Text.txt", "r", stdin);
    cin>>t;
    //freopen("output.txt", "w", stdout);
#endif

    // cin>>t;
    for (int i = 1; i <= t; i++) solve(i);

    return 0;
}

//3 3 /1 3 /1 2 10.0 10.0/ 1 2 11.0 9.0/2 3 11.0 10.0 /Answer should be: 1 2 3 /19.0 11.0
//timues judge_id: 298505JT


#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdalign>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
using namespace std;
#pragma warning(disable : 4996)

#define all(v)             v.begin(),v.end()
#define sz(v)            ((int)((v).size()))
#define psh(x)                  push_back(x)
#define sc(x)                 scanf("%d",&x)
#define sc2(x,y)         scanf("%d%d",&x,&y)
#define scl(x)              scanf("%lld",&x)
#define scl2(x,y)              scanf("%lld%lld",&x,&y)
#define lop(i,n)        for(register int i=0;i<n;i++)
#define loop(i,f,l)     for(register int i=f;i<l;i++)
#define R_(s)         freopen(s, "r", stdin)
#define W_(s)        freopen(s, "w", stdout)
#define R_W R_("input.txt"),W_("output.txt")
#define PI                        acos(-1.0)
#define INF                       1000000000
#define DFS_GRAY  -1
#define DFS_WHITE  0
#define DFS_BLACK  1

#define fr first
#define sc second
#define loopm(i,f,l)     for(register int i=f;i>l;i--)

#define IO 				std::ios_base::sync_with_stdio(0);cin.tie(NULL)

#define scc(x)           scanf("%c",&x)
#define mem(v, d)		memset(v, d, sizeof(v))
#define oo				2000000100
#define OO				4000000000000000100
typedef unsigned int uint;
typedef unsigned long long ull;

typedef string            ss;
typedef long long         ll;
typedef pair <int, int>   ii;
typedef pair<ss, int>     si;
typedef pair<int, ss>     is;
typedef pair<char, int>  chi;
typedef pair<ss, ss>     pss;
typedef vector<ii>       vii;
typedef vector<int>       vi;
typedef vector<vi>       vvi;
typedef vector<ss>        vs;
typedef vector<ll>       vll;
typedef vector<vll>     vvll;

//-----------------------------------------------------

const ll MOD = 1e9 + 7;

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

ll GCD(ll num, ll ones) { return !ones ? num : GCD(ones, num % ones); }
ll lcm(ll a, ll b) { return (a / GCD(a, b)) * b; }
double Len(int x, int y, int X, int Y) { return sqrt((X - x) * (X - x) + (Y - y) * (Y - y)); }
ll fastP(ll b, ll p)
{
    if (p == 0) return 1;
    else if (p == 1) return b;
    ll a = fastP(b, p / 2) % MOD;
    if (p % 2) return (((a * a) % MOD) * b) % MOD;
    else return (a * a) % MOD;
}
//----------------- ------   -------

const int N = 200005;
const double EPS = 1e-9;

int solve(int test)
{
    string str;cin >> str;
    vector<pair<int, int>>v(27);
    lop(i, 27)v[i].sc = i;
    lop(i, sz(str))
        v[str[i] - 'a'].fr++;
    sort(all(v),greater<pair<int,int>>());
    int cnt = 0;
    vector<int>out(sz(str), -1);
    loop(i, 2, sz(str)+1)
    {
        if ((i&1)&&sz(str) / i < 2)continue;
        if (!v[cnt].fr)
            return cout << "NO\n", 0;
        out[i-1] = v[cnt].sc;
        v[cnt].fr--;
    }
    cout << "YES\n";
    lop(i, sz(str))
        if (~out[i])
            cout << char(out[i] + 'a');
        else
        {
            cout << char((v[cnt].fr ? v[cnt].sc : v[++cnt].sc) + 'a');
            v[cnt].fr--;
        }
    cout << "\n";
    return test;
}

int main()
{
    IO;

    int t = 1;
#ifndef ONLINE_JUDGE
    freopen("Text.txt", "r", stdin);
    cin>>t;
    //freopen("output.txt", "w", stdout);
#endif

    // cin>>t;
    for (int i = 1; i <= t; i++) solve(i);

    return 0;
}

//3 3 /1 3 /1 2 10.0 10.0/ 1 2 11.0 9.0/2 3 11.0 10.0 /Answer should be: 1 2 3 /19.0 11.0
//timues judge_id: 298505JT


//kid_kb//

#include<iostream>
#include<algorithm>
#include<vector>
#include<set>
#include<unordered_set>
#include<stack>
#include<queue>
#include<deque>
#include<cwctype>
#include<cmath>
#include<map>
#include<cwchar>
#include<climits>
#include<unordered_map>
#include<cstring>
#include <iomanip>
#include <deque>
#include <list>
using namespace std;
#define endl '\n'
#define ll long long
#define ull unsigned long long int
#define lower(str) transform(str.begin(),str.end(),str.begin(),::tolower);
#define upper(str) transform(str.begin(),str.end(),str.begin(),::toupper);
#define mod 1000000007
#define SORT(vec) sort(vec.begin(),vec.end());
#define pb push_back
#define csb __builtin_popcount
#define msb(n) (ll)(log2(n))
#define kb ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define ptr(arr) for(auto i:arr)cout<<i<<" ";
#define ptr2(vec) for(auto i:vec){for(auto j: i){cout<<j<<" ";}cout<<endl;}
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define mem(a,val) memset(a,val,sizeof(a))
//cout<<fixed<<setprecision(8)<<endl;

vector<int>v;
void sieve(ll n){
    int arr[n+1];
    mem(arr,-1);

    for(int i=2;i*i<=n;i++){
        if(arr[i]==-1){
            for(int j=i*i;j<=n;j+=i)arr[j]=1;
        }
    }

    rep(i,2,n+1){
        if(arr[i]==-1)v.pb(i);
    }
}
int main()
{
    kb
    //                                                     Let's Fight!!!!!!!!!!!
    ll t;
     t=1;
//    cin>>t;
    while(t--){
        string s;
        cin>>s;
       // cout<<s.length();
        unordered_map<char,int>mp;
        char c;
        int maxi=INT_MIN;
        rep(i,0,s.length()){
            mp[s[i]]++;
            if(mp[s[i]]>maxi){
                maxi=mp[s[i]];
                c=s[i];
            }
        }

        sieve(s.length());
        v.pb(-1);
        string ans(s.length(),'0');
        int j=0;
        int f=1;
      //  ptr(v);
        //cout<<c<<endl;
        rep(i,1,s.length()+1){
            if(i==1)continue;
            if(i==v[j]){
                j++;
                if(s.length()/i==1)continue;
            }
            if(mp[c]==0){
                f=0;
                //cout<<i<<endl;
                break;
            }
            ans[i-1]=c;
            mp[c]--;
        }
//        for(auto i:mp)cout<<i.first<<" "<<i.second<<endl;
//        cout<<ans<<endl;
        if(f){
            stack<char>st;
            for(auto j:mp)
            {
                int temp=j.second;
                while(temp--)st.push(j.first);
            }
            rep(i,0,s.length()){
                if(ans[i]=='0'){
                    ans[i]=st.top();
                    st.pop();
                }
            }
            cout<<"YES"<<endl;
            cout<<ans<<endl;
        }
        else cout<<"NO"<<endl;
    }
    return 0;
}


//kid_kb//

#include<iostream>
#include<algorithm>
#include<vector>
#include<set>
#include<unordered_set>
#include<stack>
#include<queue>
#include<deque>
#include<cwctype>
#include<cmath>
#include<map>
#include<cwchar>
#include<climits>
#include<unordered_map>
#include<cstring>
#include <iomanip>
#include <deque>
#include <list>
using namespace std;
#define endl '\n'
#define ll long long
#define ull unsigned long long int
#define lower(str) transform(str.begin(),str.end(),str.begin(),::tolower);
#define upper(str) transform(str.begin(),str.end(),str.begin(),::toupper);
#define mod 1000000007
#define SORT(vec) sort(vec.begin(),vec.end());
#define pb push_back
#define csb __builtin_popcount
#define msb(n) (ll)(log2(n))
#define kb ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define ptr(arr) for(auto i:arr)cout<<i<<" ";
#define ptr2(vec) for(auto i:vec){for(auto j: i){cout<<j<<" ";}cout<<endl;}
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define mem(a,val) memset(a,val,sizeof(a))
//cout<<fixed<<setprecision(8)<<endl;

vector<int>v;
void sieve(ll n){
    int arr[n+1];
    mem(arr,-1);

    for(int i=2;i*i<=n;i++){
        if(arr[i]==-1){
            for(int j=i*i;j<=n;j+=i)arr[j]=1;
        }
    }

    rep(i,2,n+1){
        if(arr[i]==-1)v.pb(i);
    }
}
int main()
{
    kb
    //                                                     Let's Fight!!!!!!!!!!!
    ll t;
     t=1;
//    cin>>t;
    while(t--){
        string s;
        cin>>s;
        unordered_map<char,int>mp;
        char c;
        int maxi=INT_MIN;
        rep(i,0,s.length()){
            mp[s[i]]++;
            if(mp[s[i]]>maxi){
                maxi=mp[s[i]];
                c=s[i];
            }
        }

        sieve(s.length());
        v.pb(-1);
        string ans(s.length(),'0');
        int j=0;
        int f=1;
      //  ptr(v);
        //cout<<c<<endl;
        rep(i,1,s.length()+1){
            if(i==1)continue;
            if(i==v[j]){
                j++;
                if(s.length()/v[j]==1)continue;
            }
            if(mp[c]==0){
                f=0;
                cout<<i<<endl;
                break;
            }
            ans[i-1]=c;
            mp[c]--;
        }
//        for(auto i:mp)cout<<i.first<<" "<<i.second<<endl;
//        cout<<ans<<endl;
        if(f){
            stack<char>st;
            for(auto j:mp)
            {
                int temp=j.second;
                while(temp--)st.push(j.first);
            }
            rep(i,0,s.length()){
                if(ans[i]=='0'){
                    ans[i]=st.top();
                    st.pop();
                }
            }
            cout<<"YES"<<endl;
            cout<<ans<<endl;
        }
        else cout<<"NO"<<endl;
    }
    return 0;
}


//kid_kb//

#include<iostream>
#include<algorithm>
#include<vector>
#include<set>
#include<unordered_set>
#include<stack>
#include<queue>
#include<deque>
#include<cwctype>
#include<cmath>
#include<map>
#include<cwchar>
#include<climits>
#include<unordered_map>
#include<cstring>
#include <iomanip>
#include <deque>
#include <list>
using namespace std;
#define endl '\n'
#define ll long long
#define ull unsigned long long int
#define lower(str) transform(str.begin(),str.end(),str.begin(),::tolower);
#define upper(str) transform(str.begin(),str.end(),str.begin(),::toupper);
#define mod 1000000007
#define SORT(vec) sort(vec.begin(),vec.end());
#define pb push_back
#define csb __builtin_popcount
#define msb(n) (ll)(log2(n))
#define kb ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define ptr(arr) for(auto i:arr)cout<<i<<endl;
#define ptr2(vec) for(auto i:vec){for(auto j: i){cout<<j<<" ";}cout<<endl;}
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define mem(a,val) memset(a,val,sizeof(a))
//cout<<fixed<<setprecision(8)<<endl;

vector<int>v;
void sieve(ll n){
    int arr[n+1];
    mem(arr,1);

    for(int i=2;i*i<=n;i++){
        if(arr[i]){
            for(int j=i;j<=n;j+=i)arr[j]=1;
        }
    }

    rep(i,2,n+1){
        if(arr[i])v.pb(i);
    }
}
int main()
{
    kb
    //                                                     Let's Fight!!!!!!!!!!!
    ll t;
     t=1;
//    cin>>t;
    while(t--){
        string s;
        cin>>s;
        unordered_map<char,int>mp;
        char c;
        int maxi=INT_MIN;
        rep(i,0,s.length()){
            mp[s[i]]++;
            if(mp[s[i]]>maxi){
                maxi=mp[s[i]];
                c=s[i];
            }
        }

        sieve(s.length());
        v.pb(-1);
        string ans(s.length(),'0');
        int j=0;
        int f=1;
        rep(i,1,s.length()+1){
            if(i==1)continue;
            if(i==v[j]){
                if(s.length()/v[j]==1){j++;continue;}
            }
            if(mp[c]==0){
                f=0;
                break;
            }
            ans[i-1]=c;
            mp[c]--;
        }
//        for(auto i:mp)cout<<i.first<<" "<<i.second<<endl;
//        cout<<ans<<endl;
        if(f){
            rep(i,0,s.length()){
                if(ans[i]=='0'){
                    for(auto j:mp){
                            ans[i]=j.first;
                            --j.second;
                        if(j.second==0)mp.erase(j.first);
                            break;
                    }
                }
            }
            cout<<"YES"<<endl;
            cout<<ans<<endl;
        }
        else cout<<"NO"<<endl;
    }
    return 0;
}


//kid_kb//

#include<iostream>
#include<algorithm>
#include<vector>
#include<set>
#include<unordered_set>
#include<stack>
#include<queue>
#include<deque>
#include<cwctype>
#include<cmath>
#include<map>
#include<cwchar>
#include<climits>
#include<unordered_map>
#include<cstring>
#include <iomanip>
#include <deque>
#include <list>
using namespace std;
#define endl '\n'
#define ll long long
#define ull unsigned long long int
#define lower(str) transform(str.begin(),str.end(),str.begin(),::tolower);
#define upper(str) transform(str.begin(),str.end(),str.begin(),::toupper);
#define mod 1000000007
#define SORT(vec) sort(vec.begin(),vec.end());
#define pb push_back
#define csb __builtin_popcount
#define msb(n) (ll)(log2(n))
#define kb ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define ptr(arr) for(auto i:arr)cout<<i<<" ";
#define ptr2(vec) for(auto i:vec){for(auto j: i){cout<<j<<" ";}cout<<endl;}
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define mem(a,val) memset(a,val,sizeof(a))
//cout<<fixed<<setprecision(8)<<endl;

vector<int>v;
void sieve(ll n){
    int arr[n+1];
    mem(arr,-1);

    for(int i=2;i*i<=n;i++){
        if(arr[i]==-1){
            for(int j=i*i;j<=n;j+=i)arr[j]=1;
        }
    }

    rep(i,2,n+1){
        if(arr[i]==-1)v.pb(i);
    }
}
int main()
{
    kb
    //                                                     Let's Fight!!!!!!!!!!!
    ll t;
     t=1;
//    cin>>t;
    while(t--){
        string s;
        cin>>s;
        unordered_map<char,int>mp;
        char c;
        int maxi=INT_MIN;
        rep(i,0,s.length()){
            mp[s[i]]++;
            if(mp[s[i]]>maxi){
                maxi=mp[s[i]];
                c=s[i];
            }
        }

        sieve(s.length());
        v.pb(-1);
        string ans(s.length(),'0');
        int j=0;
        int f=1;
      //  ptr(v);
        //cout<<c<<endl;
        rep(i,1,s.length()+1){
            if(i==1)continue;
            if(i==v[j]){
                j++;
                if(s.length()/v[j]==1)continue;
            }
            if(mp[c]==0){
                f=0;
                //cout<<i<<endl;
                break;
            }
            ans[i-1]=c;
            mp[c]--;
        }
//        for(auto i:mp)cout<<i.first<<" "<<i.second<<endl;
//        cout<<ans<<endl;
        if(f){
            stack<char>st;
            for(auto j:mp)
            {
                int temp=j.second;
                while(temp--)st.push(j.first);
            }
            rep(i,0,s.length()){
                if(ans[i]=='0'){
                    ans[i]=st.top();
                    st.pop();
                }
            }
            cout<<"YES"<<endl;
            cout<<ans<<endl;
        }
        else cout<<"NO"<<endl;
    }
    return 0;
}


#include<bits/stdc++.h>
#define int long long
#define endl '\n'
using namespace std;
clock_t time_p = clock();
void time()
{
  time_p = clock() - time_p;
  cerr << "Time elapsed : " << (double)(time_p) / CLOCKS_PER_SEC << endl;
}
bool checkprime(int n)
{
  for (int i = 2; i <= sqrt(n); i++)
    if (n % i == 0)
      return false;
  return true;
}
signed main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  string s;
  cin >> s;
  vector<int>freq(26, 0);
  int res = 0;
  for (auto &x : s)
  {
    freq[x - 'a']++;
    res = max(res, freq[x - 'a']);
  }
  char c;
  for (int i = 0; i < 26; i++)
    if (freq[i] == res)
      c = (char)(i + 'a');
  int n = s.length();
  char str[n + 1];
  for (int i = 1; i <= n; i++)
    str[i] = s[i - 1];
  int left = n / 2 + 1;
  char ans[n + 1];
  memset(ans, '0', sizeof(ans));
  for (int i = 2; i < left; i++)
  {
    ans[i] = c;
    freq[c - 'a']--;
    if (freq[c - 'a'] < 0)
    {
      cout << "NO\n";
      return 0;
    }
  }
  for (int i = left; i <= n; i++)
  {
    if (!checkprime(i))
    {
      ans[i] = c;
      freq[c - 'a']--;
      if (freq[c - 'a'] < 0)
      {
        cout << "NO\n";
        return 0;
      }
    }
  }
  string temp;
  for (int i = 0; i < 26; i++)
    for (int j = 0; j < freq[i]; j++)
      temp += (char)(i + 'a');
  int current = 0;
  for (int i = 1; i <= n; i++)
    if (ans[i] == '0')
      ans[i] = temp[current++];
  cout << "YES\n";
  for (int i = 1; i <= n; i++)
    cout << ans[i];
  cout << endl;
  time();
  return 0;
}


#include<bits/stdc++.h>
#define int long long
#define endl '\n'
using namespace std;
clock_t time_p = clock();
void time()
{
  time_p = clock() - time_p;
  cerr << "Time elapsed : " << (double)(time_p) / CLOCKS_PER_SEC << endl;
}
bool checkprime(int n)
{
  for (int i = 2; i <= sqrt(n); i++)
    if (n % i == 0)
      return false;
  return true;
}
signed main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  string s;
  cin >> s;
  vector<int>freq(26, 0);
  int res = 0;
  for (auto &x : s)
  {
    freq[x - 'a']++;
    res = max(res, freq[x - 'a']);
  }
  char c;
  for (int i = 0; i < 26; i++)
    if (freq[i] == res)
      c = (char)(i + 'a');
  int n = s.length();
  char str[n + 1];
  for (int i = 1; i <= n; i++)
    str[i] = s[i - 1];
  int left = ceil(1.0 * n / 2);
  char ans[n + 1];
  memset(ans, '0', sizeof(ans));
  ans[1] = c;
  freq[c - 'a']--;
  for (int i = 2; i < left; i++)
  {
    ans[i] = c;
    freq[c - 'a']--;
    if (freq[c - 'a'] < 0)
    {
      cout << "NO\n";
      return 0;
    }
  }
  for (int i = left; i <= n; i++)
  {
    if (!checkprime(i))
    {
      ans[i] = c;
      freq[c - 'a']--;
      if (freq[c - 'a'] < 0)
      {
        cout << "NO\n";
        return 0;
      }
    }
  }
  string temp;
  for (int i = 0; i < 26; i++)
    for (int j = 0; j < freq[i]; j++)
      temp += (char)(i + 'a');
  int current = 0;
  for (int i = 1; i <= n; i++)
    if (ans[i] == '0')
      ans[i] = temp[current++];
  cout << "YES\n";
  for (int i = 1; i <= n; i++)
    cout << ans[i];
  cout << endl;
  time();
  return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define pb              push_back
#define mp              make_pair
#define ll              long long
#define lp(i,n)         for(int i=0;i<n;i++)
#define clr(v, d)		memset(v, d, sizeof(v))
#define vi              vector<int>
#define ull             unsigned long long
#define rep(i,a,n) for (int i = a; i <= n; ++i)
#define pii             pair<int,int>
#define vi              vector<int>
bool compare(const pair<int, double>&i, const pair<int,double>&j)
{
    return i.second < j.second ;
}

int gcd (int a , int b){
    if (b==0) return a;
return gcd(b,a%b);
}

void FastIO(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
}

void txtINPUT(){
	freopen("input.txt" , "r" , stdin) ;
	freopen("output.txt" , "w" , stdout) ;
}

bool comparator(const pair<string,int> &p1 , const pair<string,int> &p2 ){
	if (p1.second != p2.second)
		return p1.second > p2.second ;
	else
		return p1.first < p2.first ;
}

int countBits(int n){
	int cnt = 0 ;
	while(n){
		if (n & 1)
			cnt++;
		n = n >> 1 ;
	}
	return cnt ;
}

// function to calculate power fast
ll fastPower(int x , int y){
	if (y==1)
		return x ;
	if (y==0)
		return 1 ;
	if (y%2)
		return x * fastPower(x,y-1) ;
	ll ans = fastPower(x,y/2);
	return ans * ans ;
}

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

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

struct dsu {

	vector<int>parent ;
	vector<int>size ;

	void init(int n){
		parent.resize(n+1);
		size.resize(n+1);
		for(int i=1;i<=n;i++){
			parent[i]=i;
			size[i]=1;
		}
	}

	int root(int node){
		if (parent[node]==node)
			return node ;
		return parent[node] = root(parent[node]) ;
	}

	bool isUnion(int node1 , int node2){
		int p1 = root(node1) ;
		int p2 = root(node2) ;
		if (p1 == p2 )
			return true ;

		return false ;
	}

	int getSize(int node){
		int p = root(node) ;
		return size[p] ;
	}

	void link (int node1 , int node2){
		int p1 = root(node1) ;
		int p2 = root(node2) ;

		if(size[p1] > size[p2])
			swap(p1,p2);

		parent[p1] = p2 ;
		size[p2]+=size[p1];
	}
};

bool ok = false ;
const int OO = (int)1e8;
const double EPS = (1e-7);
const int maxN = 100000 ;
map<int,int>m;
set<pair<int,int>>s ;
string str ;
bool vis[1002] ;
vi primes ;
int main()
{
    //txtINPUT() ;
	FastIO() ;
	cin>>str;
	int n = str.size() ;
	for (int i=0;i<n;i++)
		m[str[i]-'a']++;

	for (int i=2;i<=n;i++){
		if (vis[i])
			   continue ;
		primes.pb(i) ;
		for (int j=i;j<=n;j+=i)
			vis[j] = true ;
	}

	dsu g ;
	g.init(n);

	for (int j=0;j<(int)primes.size();j++){
		int p = primes[j] ;
		for (int i=1;i<=(n/p);i++){
			if (!g.isUnion(p,p*i))
				g.link(p,p*i) ;
		}
	}

	for (auto entry : m){
		pii pr = mp(entry.second , entry.first) ;
		//cout << entry.second << " " << entry.first << "\n" ;
		s.insert(pr) ;
	}

	for (int i=1;i<=n;i++){
		if (g.parent[i] == i){
			int sz = g.getSize(i) ;
			auto it = s.lower_bound(mp(sz,-1));
			if (it==s.end()){
				cout << "NO" << "\n" ;
				return 0 ;
			}
			vi nodes ;
			for (int node=1;node<=n;node++){
				if (g.root(node)==i)
					nodes.pb(node);
			}
			pii tmp = *it ;

			for (int j=0;j<sz;j++){
				int pos = nodes[j]-1 ;
				str[pos] = tmp.second + 'a' ;
				tmp.first--;
			}
			s.erase(it) ;
			if (tmp.first)
				s.insert(tmp) ;
		}
	}
	cout << "YES" << "\n" ;
	cout << str << "\n" ;
	return 0;
}


#define _CRT_SECURE_NO_WARNINGS
#define ll long long
#define vi vector<int>
#define LLMAX 4000000000000000000LL
#include <bits/stdc++.h>
#include <unordered_set>
using namespace std;
struct edge
{
	int t, f, w;
	bool operator < (const edge& e) const
	{
		return w > e.w;
	}
	edge(int from, int to, int weight)
	{
		t = to;
		f = from;
		w = weight;
	}
};
#define pll pair<ll,ll>
#define ii pair<int,int>
#define MOD 1000000007
const double EPS = (1e-5);
struct line { double a, b, c; };
struct point {
	double x, y;
	point() { x = y = 0.0; }
	point(double _x, double _y) : x(_x), y(_y) {}
	// use EPS (1e-9) when testing equality of two floating points
	bool operator == (point other) const {
		return (fabs(x - other.x) < EPS && (fabs(y - other.y) < EPS));
	}
};
double dist(point p1, point p2) { // Euclidean distance
// hypot(dx, dy) returns sqrt(dx * dx + dy * dy)
	return hypot(p1.x - p2.x, p1.y - p2.y);
}
void pointsToLine(point p1, point p2, line& l) {
	if (fabs(p1.x - p2.x) < EPS) { // vertical line is fine
		l.a = 1.0; l.b = 0.0; l.c = -p1.x; // default values
	}
	else {
		l.a = -(double)(p1.y - p2.y) / (p1.x - p2.x);
		l.b = 1.0; // IMPORTANT: we fix the value of b to 1.0
		l.c = -(double)(l.a * p1.x) - p1.y;
	}
}
bool areParallel(line l1, line l2) { // check coefficients a & b
	return (fabs(l1.a - l2.a) < EPS) && (fabs(l1.b - l2.b) < EPS);
}
bool areSame(line l1, line l2) { // also check coefficient c
	return areParallel(l1, l2) && (fabs(l1.c - l2.c) < EPS);
}
// returns true (+ intersection point) if two lines are intersect
bool areIntersect(line l1, line l2, point& p) {
	if (areParallel(l1, l2)) return false; // no intersection
	// solve system of 2 linear algebraic equations with 2 unknowns
	p.x = (l2.b * l1.c - l1.b * l2.c) / (l2.a * l1.b - l1.a * l2.b);
	// special case: test for vertical line to avoid division by zero
	if (fabs(l1.b) > EPS) p.y = -(l1.a * p.x + l1.c);
	else p.y = -(l2.a * p.x + l2.c);
	return true;
}
long long binpowmod(long long a, long long b, long long m){a %= m;long long res = 1;while (b > 0){if (b & 1)res = res * a % m;a = a * a % m;b >>= 1;}return res;}
long long binpow(long long a, long long b){long long res = 1;while (b > 0){if (b & 1)res = res * a;a = a * a;b >>= 1;}return res;}
int findXOR(int n){switch (n % 4){case 0:return n;case 1:return 1;case 2:return n + 1;case 3:return 0;}}
int rangeXOR(int l, int r){return (findXOR(l - 1) ^ findXOR(r));}
int getbit(int mask, int bit){return (mask & (1 << bit));}void setbit(int& mask, int bit, int val){if (val)mask |= (1 << bit);else mask &= ~(1 << bit);}
//ll gcd(ll a, ll b){return b == 0 ? a : gcd(b, a % b);}
//ll lcm(ll a, ll b){return a * (b / gcd(a, b));}
const int N = 2e3+2;
const int M = 26;
const ll INF = N;
#define PI 3.141592653589793
#define pb push_back
int freq[26];
bitset<N> bs;
vi primes;
void sieve(int upperbound)
{
	bs.set();
	bs[0] = bs[1] = 0;
	int n = upperbound + 1;
	for (int i = 2; i * i <= n; ++i)
	{
		if (bs[i])
		{
			for (int j = i * i; j <= n; j += i)
				bs[j] = 0;
			primes.pb(i);
		}
	}
}
vi AdjList[N];
bool vis[N];
int sz;
vi goodprimes;
vi st;
char output[N];
void dfs(int u)
{
	st.push_back(goodprimes[u]);
	vis[u] = true;
	for (int i = 0; i < (int)AdjList[u].size(); ++i)
		if (!vis[AdjList[u][i]])
			dfs(AdjList[u][i]);
}
void solve()
{
	sieve(1000);
	string s;
	cin >> s;
	for (int i = 0; i < (int)s.size(); ++i)
		freq[s[i] - 'a']++;
	int j = 0;
	while (j < (int)primes.size())
	{
		if ((int)s.size() / primes[j] <= 1)
			break;
		goodprimes.push_back(primes[j]);
		j++;
	}
	for (int i = 0; i < (int)goodprimes.size(); ++i)
	{
		for (int j = i + 1; j < (int)goodprimes.size(); ++j)
		{
			if (lcm(goodprimes[i], goodprimes[j]) <= (int)s.size())
			{
				AdjList[i].push_back(j);
				AdjList[j].push_back(i);
			}
		}
	}
	priority_queue<pair<int, char>> pq;
	for (int i = 0; i < 26; ++i)
		if (freq[i])
			pq.push({ freq[i],char(i + 'a') });
	sz = (int)s.size();
	vector<pair<int,vector<int>>> ans;
	for (int i = 0; i < (int)goodprimes.size(); ++i)
	{
		if (!vis[i])
		{
			dfs(i);
			int sum = 0;
			for (int k = 0; k < (int)st.size(); ++k)
				sum += sz / st[k];
			ans.push_back({ sum,st });
			st.clear();
		}
	}
	sort(ans.rbegin(), ans.rend());
	for (int i = 0; i < (int)ans.size(); ++i)
	{
		pair<int, char> t = pq.top();
		pq.pop();
		for (int f = 0; f < sz; ++f)
		{
			for (j = 0; j < (int)ans[i].second.size(); ++j)
			{
				if ((f + 1) % ans[i].second[j] == 0)
				{
					output[f] = t.second;
					t.first--;
					break;
				}
			}
		}
		if (t.first < 0)
		{
			cout << "NO\n";
			return;
		}
		if (t.first > 0)
			pq.push(t);
	}
	for (int i = 0; i < sz; ++i)
	{
		if (output[i] == '\0')
		{
			pair<int, char> t = pq.top();
			pq.pop();
			output[i] = t.second;
			t.first--;
			if (t.first)
				pq.push(t);
		}
	}
	printf("YES\n%s", output);

}
int main(void)
{
	//freopen("commandos.in", "r", stdin);
	//freopen("output.txt", "w", stdout);
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int tc = 1;
	//cin >> tc;
	//scanf("%d", &tc);
	while (tc--)
	{
		solve();
		//if (tc)
			//cout << '\n';
	}
}


#define _CRT_SECURE_NO_WARNINGS
#define ll long long
#define vi vector<int>
#define LLMAX 4000000000000000000LL
#include <bits/stdc++.h>
#include <unordered_set>
using namespace std;
struct edge
{
	int t, f, w;
	bool operator < (const edge& e) const
	{
		return w > e.w;
	}
	edge(int from, int to, int weight)
	{
		t = to;
		f = from;
		w = weight;
	}
};
#define pll pair<ll,ll>
#define ii pair<int,int>
#define MOD 1000000007
const double EPS = (1e-5);
struct line { double a, b, c; };
struct point {
	double x, y;
	point() { x = y = 0.0; }
	point(double _x, double _y) : x(_x), y(_y) {}
	// use EPS (1e-9) when testing equality of two floating points
	bool operator == (point other) const {
		return (fabs(x - other.x) < EPS && (fabs(y - other.y) < EPS));
	}
};
double dist(point p1, point p2) { // Euclidean distance
// hypot(dx, dy) returns sqrt(dx * dx + dy * dy)
	return hypot(p1.x - p2.x, p1.y - p2.y);
}
void pointsToLine(point p1, point p2, line& l) {
	if (fabs(p1.x - p2.x) < EPS) { // vertical line is fine
		l.a = 1.0; l.b = 0.0; l.c = -p1.x; // default values
	}
	else {
		l.a = -(double)(p1.y - p2.y) / (p1.x - p2.x);
		l.b = 1.0; // IMPORTANT: we fix the value of b to 1.0
		l.c = -(double)(l.a * p1.x) - p1.y;
	}
}
bool areParallel(line l1, line l2) { // check coefficients a & b
	return (fabs(l1.a - l2.a) < EPS) && (fabs(l1.b - l2.b) < EPS);
}
bool areSame(line l1, line l2) { // also check coefficient c
	return areParallel(l1, l2) && (fabs(l1.c - l2.c) < EPS);
}
// returns true (+ intersection point) if two lines are intersect
bool areIntersect(line l1, line l2, point& p) {
	if (areParallel(l1, l2)) return false; // no intersection
	// solve system of 2 linear algebraic equations with 2 unknowns
	p.x = (l2.b * l1.c - l1.b * l2.c) / (l2.a * l1.b - l1.a * l2.b);
	// special case: test for vertical line to avoid division by zero
	if (fabs(l1.b) > EPS) p.y = -(l1.a * p.x + l1.c);
	else p.y = -(l2.a * p.x + l2.c);
	return true;
}
long long binpowmod(long long a, long long b, long long m){a %= m;long long res = 1;while (b > 0){if (b & 1)res = res * a % m;a = a * a % m;b >>= 1;}return res;}
long long binpow(long long a, long long b){long long res = 1;while (b > 0){if (b & 1)res = res * a;a = a * a;b >>= 1;}return res;}
int findXOR(int n){switch (n % 4){case 0:return n;case 1:return 1;case 2:return n + 1;case 3:return 0;}}
int rangeXOR(int l, int r){return (findXOR(l - 1) ^ findXOR(r));}
int getbit(int mask, int bit){return (mask & (1 << bit));}void setbit(int& mask, int bit, int val){if (val)mask |= (1 << bit);else mask &= ~(1 << bit);}
//ll gcd(ll a, ll b){return b == 0 ? a : gcd(b, a % b);}
//ll lcm(ll a, ll b){return a * (b / gcd(a, b));}
const int N = 1e3+10;
const int M = 26;
const ll INF = N;
#define PI 3.141592653589793
#define pb push_back
int freq[26];
bitset<N> bs;
vi primes;
void sieve(int upperbound)
{
	bs.set();
	bs[0] = bs[1] = 0;
	int n = upperbound + 1;
	for (int i = 2; i <= n; ++i)
	{
		if (bs[i])
		{
			for (int j = i * i; j <= n; j += i)
				bs[j] = 0;
			primes.pb(i);
		}
	}
}
vi AdjList[N];
bool vis[N];
int sz;
vi goodprimes;
vi st;
char output[N];
void dfs(int u)
{
	st.push_back(goodprimes[u]);
	vis[u] = true;
	for (int i = 0; i < (int)AdjList[u].size(); ++i)
		if (!vis[AdjList[u][i]])
			dfs(AdjList[u][i]);
}
void solve()
{
	sieve((1000 + 5)/2);
	string s;
	cin >> s;
	for (int i = 0; i < (int)s.size(); ++i)
		freq[s[i] - 'a']++;
	int j = 0;
	while (j < (int)primes.size())
	{
		if ((int)s.size() / primes[j] <= 1)
			break;
		goodprimes.push_back(primes[j]);
		j++;
	}
	for (int i = 0; i < (int)goodprimes.size(); ++i)
	{
		for (int j = i + 1; j < (int)goodprimes.size(); ++j)
		{
			if (lcm(goodprimes[i], goodprimes[j]) <= (int)s.size())
			{
				AdjList[i].push_back(j);
				AdjList[j].push_back(i);
			}
		}
	}
	priority_queue<pair<int, char>> pq;
	for (int i = 0; i < 26; ++i)
		if (freq[i])
			pq.push({ freq[i],char(i + 'a') });
	sz = (int)s.size();
	vector<pair<int,vector<int>>> ans;
	for (int i = 0; i < (int)goodprimes.size(); ++i)
	{
		if (!vis[i])
		{
			dfs(i);
			int sum = 0;
			for (int k = 0; k < (int)st.size(); ++k)
				sum += sz / st[k];
			ans.push_back({ sum,st });
			st.clear();
		}
	}
	sort(ans.rbegin(), ans.rend());
	for (int i = 0; i < (int)ans.size(); ++i)
	{
		pair<int, char> t = pq.top();
		pq.pop();
		for (int f = 0; f < sz; ++f)
		{
			for (j = 0; j < (int)ans[i].second.size(); ++j)
			{
				if ((f + 1) % ans[i].second[j] == 0)
				{
					output[f] = t.second;
					t.first--;
					break;
				}
			}
		}
		if (t.first < 0)
		{
			cout << "NO\n";
			return;
		}
		if (t.first > 0)
			pq.push(t);
	}
	for (int i = 0; i < sz; ++i)
	{
		if (output[i] == '\0')
		{
			pair<int, char> t = pq.top();
			pq.pop();
			output[i] = t.second;
			t.first--;
			if (t.first)
				pq.push(t);
		}
	}
	printf("YES\n%s", output);

}
int main(void)
{
	//freopen("commandos.in", "r", stdin);
	//freopen("output.txt", "w", stdout);
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int tc = 1;
	//cin >> tc;
	//scanf("%d", &tc);
	while (tc--)
	{
		solve();
		//if (tc)
			//cout << '\n';
	}
}


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;

#define x() real()
#define y() imag()

typedef complex<double> point; // 2D point only
typedef long long ll;
typedef unsigned long long ull;
typedef long double ldob;
typedef pair<ll, ll> ii;
typedef pair<ll, ii> iii;
typedef pair<ii, ll> ii_i;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef vector<iii> viii;

// OST
template <typename T>
using ordered_set = __gnu_pbds::tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

// from: https://codeforces.com/blog/entry/62393
struct custom_hash {
	static uint64_t splitmix64(uint64_t x) {
		// http://xorshift.di.unimi.it/splitmix64.c
		x += 0x9e3779b97f4a7c15;
		x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
		x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
		return x ^ (x >> 31);
	}

	size_t operator()(uint64_t x) const {
		static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
		return splitmix64(x + FIXED_RANDOM);
	}
};

const int INF = ~(1<<31);
const ll LINF = (1LL << 60);
const long double EPS = 1e-9;
const long double PI = acos(-1);

const int N = 1007;
const int NN = 1000000;
const int MOD = 1e9+7;
const int IMAX = 1e9+7;
const int dx[4] = {0,0,-1,1};
const int dy[4] = {-1,1,0,0};

bitset<N> is; // #include <bitset>
int pr[N], primes = 0;
void sieve() {
    is[2] = true; pr[primes++] = 2;
    for (int i = 3; i < N; i += 2) is[i] = 1;
    for (int i = 3; i*i < N; i += 2)
        if (is[i])
            for (int j = i*i; j < N; j += i)
                is[j]= 0;
    for (int i = 3; i < N; i += 2)
        if (is[i])
            pr[primes++] = i;}

int n;
string s;
char ans[N];

int main () {
	ios_base::sync_with_stdio(false); cin.tie(0);
	// cout.precision(3); cout << fixed;

	sieve();
	cin >> s;
	n = s.size();

	vector<pair<int,char>> v;
	for (char i = 'a'; i <= 'z'; ++i) {
		v.push_back({0,i});
	}
	for (int i = 0; i < n; ++i) {
		v[s[i]-'a'].first++;
	}

	sort(v.rbegin(), v.rend());

	is[1] = 1;
	for (int i = 2; i + i <= n; ++i)
		is[i] = 0;

	for (int i = 1; i <= n; ++i) {
		if (not is[i]) {
			if (v[0].first <= 0) {
				cout << "NO" << endl;
				return 0;
			}
			ans[i] = v[0].second;
			v[0].first--;
		}
	}

	cout << "YES" << endl;
	int k = 0;
	for (int i = 1; i <= n; ++i) {
		if (not is[i]) continue;
		while (v[k].first <= 0 and k < 26) k++;
		ans[i] = v[k].second;
		v[k].first--;
	}

	for (int i = 1; i <= n; ++i)
		cout << ans[i];
	cout << endl;

	return 0;
}


#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
typedef long long ll;
#define mod 1000000007
#define debug(x) cout  << #x << " : " << x << endl
using namespace std;

int main()
{
	#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	#endif

	string s;
	cin >> s;

	int len = s.length();
	unordered_map <char, int> mp;
	for(int i = 0; i < len; i ++)
	{
		mp[s[i]] ++;
	}

	int distinctChar = mp.size();
	vector <bool> primes(len + 1, true);
	vector <int> primeList;
	for(int i = 2; i * i <= len; i ++)
	{
		if(primes[i] == true)
		{
			for(int j = i; i * j <= len; j ++)
			{
				primes[i * j] = false;
			}
		}
	}

	for(int i = 2; i <= len; i ++)
	{
		if(primes[i] == true)
			primeList.push_back(i);
	}

	vector <pair<int, char>> store;

	for(auto it = mp.begin(); it != mp.end(); it ++)
	{
		store.push_back({it->second, it->first});
	}

	// for(int i = 0; i < store.size(); i ++)
	// 	cout << store[i].first << " " << store[i].second << endl;

	sort(store.begin(), store.end());
	int count = 1;
	vector <char> str(len, 'A');
	for(int i = 0; i < primeList.size(); i ++)
	{
		if(primeList[i] * 2 > len)
		{
			count ++;
			for(int j = 0; j < store.size(); j ++)
			{
				if(store[j].first > 0)
				{
					// cout << store[j].second << " ";
					str[primeList[i] - 1] = store[j].second;
					store[j].first --;
					break;
				}
			}
		}
	}

	for(int j = 0; j < store.size(); j ++)
	{
		if(store[j].first > 0)
		{
			str[0] = store[j].second;
			store[j].first --;
			break;
		}
	}

	// cout << len << endl;
	int need = len - count;
	int left = store[distinctChar - 1].first;

	// cout << need << " " << left << endl;
	if(need > left)
		cout << "NO" << endl;
	else
	{
		cout << "YES" << endl;
		for(int i = 0; i < len; i ++)
		{
			if(str[i] == 'A')
				cout << store[distinctChar - 1].second;
			else
				cout << str[i];
		}
	}
}


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

void prime(int a,vector<int> &v){
    for(ll i=2;i*i<=a;i++){
        if(a%i==0)v.push_back(i);
        while(a%i==0){
            a=a/i;
        }
    }
    if(a>1)
    v.push_back(a);
}

 ll mod;
ll expmod(ll a,ll b) {
	if(b == 1) return a;
	if(b == 0) return 1;
	ll m1 = expmod(a,b/2)%mod;
	if(b%2) return ((m1*m1)%mod*a%mod)%mod;
	return (m1*m1)%mod;
}

ll gcd(ll a,ll b){
    if(b==0) return a;
    return gcd(b,a%b);
}
ll lcm(ll a,ll b){
    return (a*b)/gcd(a,b);
}

int main(){
  string s;cin>>s;
  string h=s;
  int n=s.size();
  bool soe[n+1]={false};
  for(int i=2;i<=n;i++){
      if(!soe[i]&&n/i>1){
      for(int j=i;j<=n;j+=i){
          soe[j]=true;
      }
      }
  }
 // cout<<soe[2]<<soe[3]<<soe[4]<<soe[6]<<" ";
  int c=0;
  for(int i=0;i<n;i++)
  if(soe[i+1])
  c++;

  int a[123]={0};
  for(int i=0;i<n;i++){
     int t=int(s[i]);
     a[t]++;
  }
  int e=-1;
  int m=0;
  for(int i=97;i<=122;i++){
      if(m<a[i]){
          m=a[i];e=i;
      }
  }
  //cout<<a[e]<<" "<<e<<" ";
  //string g="";
  for(int i=0;i<n;i++){
      if(s[i]!=char(e))
      g.push_back(s[i]);
  }
 // cout<<g<<" ";
  int j=0;
  if(a[e]<c)
  cout<<"NO";
  else{
      cout<<"YES"<<endl;
  for(int i=0;i<n;i++){
      if(soe[i+1]){s[i]=char(e),a[e]--;}
  }
  for(int i=0;i<n;i++){
      if(!soe[i+1]){
          if(a[e]>0){s[i]=char(e),a[e]--;}
          else{ s[i]=g[j],j++;}
      }
  }
  for(int i=0;i<n;i++)
  cout<<s[i];
  }
}


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

void prime(int a,vector<int> &v){
    for(ll i=2;i*i<=a;i++){
        if(a%i==0)v.push_back(i);
        while(a%i==0){
            a=a/i;
        }
    }
    if(a>1)
    v.push_back(a);
}

 ll mod;
ll expmod(ll a,ll b) {
	if(b == 1) return a;
	if(b == 0) return 1;
	ll m1 = expmod(a,b/2)%mod;
	if(b%2) return ((m1*m1)%mod*a%mod)%mod;
	return (m1*m1)%mod;
}

ll gcd(ll a,ll b){
    if(b==0) return a;
    return gcd(b,a%b);
}
ll lcm(ll a,ll b){
    return (a*b)/gcd(a,b);
}

int main(){
  string s;cin>>s;
  string h=s;
  int n=s.size();
  bool soe[n+1]={false};
  for(int i=2;i<=n;i++){
      if(!soe[i]&&n/i>1){
      for(int j=i;j<=n;j+=i){
          soe[j]=true;
      }
      }
  }
 // cout<<soe[2]<<soe[3]<<soe[4]<<soe[6]<<" ";
  int c=0;
  for(int i=0;i<n;i++)
  if(soe[i+1])
  c++;

  int a[123]={0};
  for(int i=0;i<n;i++){
     int t=int(s[i]);
     a[t]++;
  }
  int e=-1;
  int m=0;
  for(int i=97;i<=122;i++){
      if(m<a[i]){
          m=a[i];e=i;
      }
  }
  //cout<<a[e]<<" "<<e<<" ";
  string g="";
  for(int i=0;i<n;i++){
      if(s[i]!=char(e))
      g.push_back(s[i]);
  }
 // cout<<g<<" ";
  int j=0;
  if(a[e]<c)
  cout<<"NO";
  else{
      cout<<"YES"<<endl;
  for(int i=0;i<n;i++){
      if(soe[i+1]){s[i]=char(e),a[e]--;}
  }
  for(int i=0;i<n;i++){
      if(!soe[i+1]){
          if(a[e]>0){s[i]=char(e),a[e]--;}
          else{ s[i]=g[j],j++;}
      }
  }
  for(int i=0;i<n;i++)
  cout<<s[i];
  }
}


#include<bits/stdc++.h>
using namespace std;
#define pb(x)           push_back(x)
#define mkp(x,y)        make_pair(x,y)
#define L               length()
#define int             long long
#define bs              binary_search
#define mod             1e9+7
#define IOS             ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define all(v)          v.begin(),v.end()
#define mem0(a)         memset(a,0,sizeof(a))
#define mem1(a)         memset(a,-1,sizeof(a))
#define F               first
#define S               second
#define pii             pair<int,int>
#define vi              vector<int>
#define vs              size()
#define gcd(a,b)        __ gcd(a,b)
#define endl            '\n'
#define atoi            stoi
#define elasped_time    1.0 * clock() / CLOCKS_PER_SEC
#define si              set <int>
#define vpii            vector < pair <int,int> >
#define memf(a)         memset(a,false,sizeof(a))
#define memt(a)         memset(a,true,sizeof(a))
#define xxx             998244353
#define pi              3.141592653589
int max(int a,int b){if(a>b){return a;}else{return b;}}
int min(int a,int b){if(a<b){return a;}else{return b;}}
int power(int b,int e)
{
    if(e==0)
    return 1;
    if(e%2)
    return ((b*power((b)*(b),(e-1)/2)));
    else
    return power((b)*(b),e/2);
}
int modpower(int b,int e,int q)
{
    int MOD=q;
    if(e==0)
    return 1;
    if(e%2)
    return ((b%MOD)*modpower((b%MOD)*(b%MOD),(e-1)/2,q))%MOD;
    else
    return modpower((b%MOD)*(b%MOD),e/2,q)%MOD;
}
void dpv(vi v)
{
    for(int i=0;i<v.vs;i++)
    {
        cout<<v[i]<<" ";
    }
    cout<<endl;
}
void dpv(vpii v)
{
    for(int i=0;i<v.vs;i++)
    {
        cout<<v[i].F<<" "<<v[i].S<<endl;
    }
}
void dpv(set <int> v)
{
    for(auto i:v)
    {
        cout<<i<<" ";
    }
    cout<<endl;
}
/////////////////////// //**TREE MOVES STARTS**//////////////////////////////////////////////
/*vector <vi> v(200005);
vi dad;
vi intime;
vi outtime;
vi depth;
vector <bool> vis;
int timer=0;
void treemoves(int n)
{
    dad.assign(n+1,1);
    intime.assign(n+1,0);
    outtime.assign(n+1,0);
    depth.assign(n+1,0);
    vis.assign(n+1,false);
}
void dfs_calc(int root)
{
    vis[root]=true;
    intime[root]=timer++;
    for(auto i:v[root])
    {
        if(!vis[i])
        {
            depth[i]=depth[root]+1;
            dad[i]=root;
            dfs_calc(i);
        }
    }
    outtime[root]=timer++;
}
///// **TREE MOVES ENDS**////////////////////////////

////*SOLUTION TO THE QUESTION STARTS HERE*///////
bool prime[2000];
void seive()
{
    memset(prime,true,sizeof(prime));
    prime[1]=false;
    for(int i=4;i<2000;i+=2)
    {
        prime[i]=false;
    }
    for(int i=3;i<2000;i+=2)
    {
        if(prime[i])
        {
            for(int j=i*2;j<2000;j+=i)
            {
                prime[j]=false;
            }
        }
    }
}
void oblivious()
{
    seive();
    string a;
    cin>>a;
    int z=a.L;
    vi pr;
    for(int i=1;i<=z;i++)
    {
        if(prime[i])
        {
            pr.pb(i);
        }
    }
    si s;
    int cnt=0;
    si s1;
    for(auto i:pr)
    {
        if(z/i>=2)
        {
            for(int j=1;j<=z/i;j++)
            {
                s.insert(j*i-1);
            }
        }
        else
        {
            s1.insert(i-1);
        }
    }
    s1.insert(0);
    map <char,int> m;
    for(int i=0;i<a.L;i++)
    {
        m[a[i]]++;
    }
    char c1;
    bool f1=false;
    for(int i=0;i<26;i++)
    {
        if(m[i+'a']>=s.vs)
        {
            f1=true;
            c1=i+'a';
            break;
        }
    }
    if(!f1)
    {
        cout<<"NO"<<endl;
    }
    else
    {
        cout<<"YES"<<endl;
        string s2;
        for(int i=0;i<a.L;i++)
        {
            s2.pb('0');
        }
        for(auto i:s)
        {
            s2[i]=c1;
        }
        m[c1]-=s.vs;
        for(int i=0;i<26;i++)
        {
            if(!s1.empty())
            {
                if(m[i+'a']>=1)
                {
                    s2[*s1.begin()]=i+'a';
                    m[i+'a']--;
                    i--;
                    s1.erase(s1.begin());
                }
            }
            else
            {
                break;
            }
        }
        cout<<s2<<endl;
    }
}
signed main()
{
    IOS;
    int t=1;
    /*#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif*/
    //cin>>t;
    while(t--)
    {
        oblivious();
    }
    return 0;
}
//Md Zuhair


#include<bits/stdc++.h>
#define ll long long
#define mkp make_pair
#define pb push_back
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
using namespace std;
int main()
{
//fastio
string str;
ll i,j,k,n,mxv=1100;
ll arr[mxv]={0};
for(i=2;i<=sqrt(mxv);i++){for(j=i+i;j<=mxv;j+=i)arr[j]=1;}
cin>>str;
ll ans=0;
n=str.size();
vector<ll>v;
map<char,ll>mp;
for(i=0;i<n;i++)
mp[str[i]]++;
vector<ll>coll;coll.pb(2);
ll last=1;
for(i=3;i<=n/2;i++)
{   if(!arr[i])
	coll.pb(i);
	last=i;
}

for(i=last+1;i<=n;i++)
{
	if(!arr[i])v.pb(i);
}
v.pb(1);
char alp[n+1];
for(i=0;i<=n;i++)alp[i]='?';
if(coll.size()>1)
{  char temp;ll req=0;
   for(i=1;i<=n;i++)
   {
   	for(j=0;j<coll.size();j++)
   	{if(i%coll[j]==0)
   	{req++;break;
	   }
	   }
//	cout<<"f\n";
   }

	for(temp='a';temp<='z';temp++)
	{
//		cout<<mp[temp]<<" "<<req<<"  "<<v[i]<<"\n";
		if(mp[temp]>=req)
		{mp[temp]-=req;
		alp[2]=temp;
////		cout<<temp<<" "<<req<<"\n";
		break;
		}
	}
}
for(i=0;i<v.size();i++)
{
    char temp;
	ll req=n/v[i];
	if(v[i]==1)req=1;
	for(temp='a';temp<='z';temp++)
	{
//		cout<<mp[temp]<<" "<<req<<"  "<<v[i]<<"\n";
		if(mp[temp]>=req)
		{mp[temp]-=req;
		alp[v[i]]=temp;
		break;
		}
	}
}
string s;for(i=0;i<=n;i++)s.pb('?');
s[1]=alp[1];
for(i=0;i<v.size();i++)
{
////	cout<<v[i]<<" "<<alp[v[i]]<<"\n";
	if(v[i]!=1)
	{
		for(j=v[i];j<=n;j+=v[i])
		s[j]=alp[v[i]];
	}
}
ll flag=1;

if(coll.size()>1)
{
	for(j=0;j<coll.size();j++)
	{
		for(k=coll[j];k<=n;k+=coll[j])
		s[k]=alp[2];
	}
}
////for(i=1;i<=n;i++)cout<<s[i];cout<<"\n";
for(i=1;i<=n;i++)
{if(s[i]=='?')flag=0;
}
if(!flag)cout<<"NO\n";
else
{cout<<"YES\n";
for(i=1;i<=n;i++)cout<<s[i];
cout<<"\n";
}

return 0;
}


#include <bits/stdc++.h>

#define F first
#define S second
#define llong long long
#define ullong unsigned long long
#define mp make_pair
#define pb push_back

using namespace std;

const int INF = (int)1e9 + 7;
const llong LINF = (llong)1e18 + 9;
const int MXN = (int)4e6 + 10;
const double EPS = (double)1e-9;

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

int n, m;
char ch[2001][2001];
bool used[2001][2001];
vector <pair <int, int> > order;
int deg[2001][2001];

bool check(int x, int y){
  return (x >= 0 && y >= 0 && x < n && x < m && ch[x][y] == '.');
}

int main(){
  #ifndef ONLINE_JUDGE
      freopen("input.txt", "r", stdin);
  #endif
  scanf("%d%d\n", &n, &m);
  for(int i = 0; i < n; ++i){
    scanf("%s\n", &ch[i]);
  }
  for(int i = 0; i < n; ++i){
    for(int j = 0; j < m; ++j){
      if(check(i, j)){
        bool boo = false;
        for(int k = 0; k < 4; ++k){
          int nx = i + dx[k];
          int ny = j + dy[k];
          if(check(nx, ny)){
            deg[nx][ny]++;
            deg[i][j]++;
            boo = true;
          }
        }
        if(!boo){
          printf("Not unique");
          return 0;
        }
      }
      else {
        used[i][j] = true;
      }
    }
  }
  for(int i = 0; i < n; ++i){
    for(int j = 0; j < m; ++j){
      if(check(i, j)){
        deg[i][j] /= 2;
        order.pb(mp(deg[i][j], i * m + j));
      }
    }
  }
  sort(order.begin(), order.end());
  for(int i = 0; i < order.size(); ++i){
    int x = order[i].S / m;
    int y = order[i].S % m;
    //cerr << x << " " << y << " " <<deg[x][y]<< "\n";
    if(!deg[x][y] || used[x][y]){
      continue;
    }
    if(deg[x][y] > 1){
      printf("Not unique");
      return 0;
    }
    for(int k = 0; k < 4; ++k){
      int nx = x + dx[k];
      int ny = y + dy[k];
      if(check(nx, ny)){
        used[x][y] = true;
        used[nx][ny] = true;
        for(int s = 0; s < 4; ++s){
          int nnx = nx + dx[s];
          int nny = ny + dy[s];
          if(!used[nnx][nny] && check(nnx, nny)){
            deg[nnx][nny]--;
          }
        }
        deg[nx][ny]--;
        deg[x][y]--;
        if(x == nx){
          ch[x][y] = (y < ny ? '<' : '>');
          ch[nx][ny] = (ny < y ? '<' : '>');
        }
        if(y == ny){
          ch[x][y] = (x < nx ? '^' : 'v');
          ch[nx][ny] = (nx < x ? '^' : 'v');
        }
        break;
      }
    }
  }
  for(int i = 0; i < n; ++i){
    printf("%s\n", ch[i]);
  }
  return 0;
}


#include <bits/stdc++.h>

#define F first
#define S second
#define llong long long
#define ullong unsigned long long
#define mp make_pair
#define pb push_back

using namespace std;

const int INF = (int)1e9 + 7;
const llong LINF = (llong)1e18 + 9;
const int MXN = (int)4e6 + 10;
const double EPS = (double)1e-9;

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

int n, m;
char ch[2001][2001];
bool used[2001][2001];
int deg[2001][2001];
queue <pair <int, int> > q;

bool check(int x, int y){
  return (x >= 0 && y >= 0 && x < n && y < m && ch[x][y] == '.');
}

int main(){
  #ifndef ONLINE_JUDGE
      freopen("input.txt", "r", stdin);
  #endif
  scanf("%d%d\n", &n, &m);
  for(int i = 0; i < n; ++i){
    scanf("%s\n", &ch[i]);
  }
  for(int i = 0; i < n; ++i){
    for(int j = 0; j < m; ++j){
      if(check(i, j)){
        bool boo = false;
        for(int k = 0; k < 4; ++k){
          int nx = i + dx[k];
          int ny = j + dy[k];
          if(check(nx, ny)){
            deg[nx][ny]++;
            deg[i][j]++;
            boo = true;
          }
        }
        if(!boo){
          printf("Not unique");
          return 0;
        }
      }
      else {
        used[i][j] = true;
      }
    }
  }

  for(int i = 0; i < n; ++i){
    for(int j = 0; j < m; ++j){
      if(check(i, j)){
        deg[i][j] /= 2;
        if(deg[i][j] == 1)
          q.push(mp(i, j));
      }
    }
  }
  while(!q.empty()){
    pair <int, int> v = q.front();
    q.pop();
    //cerr << v.F << " " << v.S << " " << deg[v.F][v.S] << "\n";
    if(used[v.F][v.S])
      continue;
    /*if(deg[v.F][v.S] != 1){
      printf("Not unique");
      return 0;
    }*/
    pair <int, int> nw;
    bool boo = false;
    for(int i = 0; i < 4; ++i){
      int nx = v.F + dx[i];
      int ny = v.S + dy[i];
      if(check(nx, ny) && !used[nx][ny]){
        nw = mp(nx, ny);
        boo = true;
        break;
      }
    }
    if(!boo){
      printf("Not unique");
      return 0;
    }
    used[v.F][v.S] = true;
    used[nw.F][nw.S] = true;
    deg[v.F][v.S] = 0;
    deg[nw.F][nw.S] = 0;
    if(nw.F == v.F){
      ch[v.F][min(v.S, nw.S)] = '<';
      ch[v.F][max(v.S, nw.S)] = '>';
    }
    if(nw.S == v.S){
      ch[min(v.F, nw.F)][v.S] = '^';
      ch[max(v.F, nw.F)][v.S] = 'v';
    }
    for(int i = 0; i < 4; ++i){
      int nx = nw.F + dx[i];
      int ny = nw.S + dy[i];
      if(check(nx, ny) && !used[nx][ny]){
        deg[nx][ny]--;
        //deg[nw.F][nw.S]--;
        if(deg[nx][ny] == 1)
          q.push(mp(nx, ny));
      }
    }
  }
  for(int i = 0; i < n; ++i){
    for(int j = 0; j < m; ++j){
      if(deg[i][j]){
        //printf("%d %d %d\n", i, j, deg[i][j]);
        printf("Not unique");
        return 0;
      }
    }
  }
  for(int i = 0; i < n; ++i){
    printf("%s\n", ch[i]);
  }
  return 0;
}


#include <bits/stdc++.h>

#define F first
#define S second
#define llong long long
#define ullong unsigned long long
#define mp make_pair
#define pb push_back

using namespace std;

const int INF = (int)1e9 + 7;
const llong LINF = (llong)1e18 + 9;
const int MXN = (int)4e6 + 10;
const double EPS = (double)1e-9;

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

int n, m;
char ch[2001][2001];
bool used[2001][2001];
int deg[2001][2001];
queue <pair <int, int> > q;

bool check(int x, int y){
  return (x >= 0 && y >= 0 && x < n && x < m && ch[x][y] == '.');
}

int main(){
  #ifndef ONLINE_JUDGE
      freopen("input.txt", "r", stdin);
  #endif
  scanf("%d%d\n", &n, &m);
  for(int i = 0; i < n; ++i){
    scanf("%s\n", &ch[i]);
  }
  int cnt = 0;
  for(int i = 0; i < n; ++i){
    for(int j = 0; j < m; ++j){
      if(check(i, j)){
        bool boo = false;
        for(int k = 0; k < 4; ++k){
          int nx = i + dx[k];
          int ny = j + dy[k];
          if(check(nx, ny)){
            deg[nx][ny]++;
            deg[i][j]++;
            boo = true;
          }
        }
        if(!boo){
          printf("Not unique");
          return 0;
        }
      }
      else {
        used[i][j] = true;
      }
    }
  }

  for(int i = 0; i < n; ++i){
    for(int j = 0; j < m; ++j){
      if(check(i, j)){
        deg[i][j] /= 2;
        if(deg[i][j] == 1)
          q.push(mp(i, j));
      }
    }
  }
  while(!q.empty()){
    pair <int, int> v = q.front();
    q.pop();
    if(used[v.F][v.S])
      continue;
    used[v.F][v.S] = true;
    pair <int, int> nw;
    for(int i = 0; i < 4; ++i){
      int nx = v.F + dx[i];
      int ny = v.S + dy[i];
      if(check(nx, ny) && !used[nx][ny]){
        nw = mp(nx, ny);
        break;
      }
    }
    deg[v.F][v.S] = 0;
    deg[nw.F][nw.S] = 0;
    if(nw.F == v.F){
      ch[v.F][min(v.S, nw.S)] = '<';
      ch[v.F][max(v.S, nw.S)] = '>';
    }
    if(nw.S == v.S){
      ch[min(v.F, nw.F)][v.S] = '^';
      ch[max(v.F, nw.F)][v.S] = 'v';
    }
    used[nw.F][nw.S] = true;
    for(int i = 0; i < 4; ++i){
      int nx = nw.F + dx[i];
      int ny = nw.S + dy[i];
      if(check(nx, ny) && !used[nx][ny]){
        deg[nx][ny]--;
        if(deg[nx][ny] == 1)
          q.push(mp(nx, ny));
      }
    }
  }
  for(int i = 0; i < n; ++i){
    for(int j = 0; j < m; ++j){
      if(deg[i][j]){
        //printf("%d %d %d\n", i, j, deg[i][j]);
        printf("Not unique");
        return 0;
      }
    }
  }
  for(int i = 0; i < n; ++i){
    printf("%s\n", ch[i]);
  }
  return 0;
}


#include <bits/stdc++.h>

#define F first
#define S second
#define llong long long
#define ullong unsigned long long
#define mp make_pair
#define pb push_back

using namespace std;

const int INF = (int)1e9 + 7;
const llong LINF = (llong)1e18 + 9;
const int MXN = (int)4e6 + 10;
const double EPS = (double)1e-9;

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

int n, m;
char ch[2001][2001];
bool used[2001][2001];
set <pair <int, int> > ss;
int deg[2001][2001];

bool check(int x, int y){
  return (x >= 0 && y >= 0 && x < n && x < m && ch[x][y] == '.');
}

int main(){
  #ifndef ONLINE_JUDGE
      freopen("input.txt", "r", stdin);
  #endif
  scanf("%d%d\n", &n, &m);
  for(int i = 0; i < n; ++i){
    scanf("%s\n", &ch[i]);
  }
  int cnt = 0;
  for(int i = 0; i < n; ++i){
    for(int j = 0; j < m; ++j){
      if(check(i, j)){
        bool boo = false;
        for(int k = 0; k < 4; ++k){
          int nx = i + dx[k];
          int ny = j + dy[k];
          if(check(nx, ny)){
            deg[nx][ny]++;
            deg[i][j]++;
            boo = true;
          }
        }
        if(!boo){
          printf("Not unique");
          return 0;
        }
      }
      else {
        used[i][j] = true;
      }
    }
  }
  for(int i = 0; i < n; ++i){
    for(int j = 0; j < m; ++j){
      if(check(i, j)){
        deg[i][j] /= 2;
        ss.insert(mp(deg[i][j], i * m + j));
      }
    }
  }
  while(ss.size()){
    pair <int, int> tmp = *(ss.begin());
    ss.erase(ss.begin());
    int x = tmp.S / m;
    int y = tmp.S % m;
    if(!deg[x][y] || used[x][y]){
      continue;
    }
    if(deg[x][y] > 1){
      printf("Not unique");
      return 0;
    }
    for(int k = 0; k < 4; ++k){
      int nx = x + dx[k];
      int ny = y + dy[k];
      if(check(nx, ny)){
        used[x][y] = true;
        used[nx][ny] = true;
        for(int s = 0; s < 4; ++s){
          int nnx = nx + dx[s];
          int nny = ny + dy[s];
          if(!used[nnx][nny] && check(nnx, nny)){
            ss.erase(mp(deg[nnx][nny], nnx * m + nny));
            deg[nnx][nny]--;
            if(deg[nnx][nny])
              ss.insert(mp(deg[nnx][nny], nnx * m + nny));
          }
        }
        ss.erase(mp(deg[nx][ny], nx * m + ny));
        deg[nx][ny]--;
        ss.erase(mp(deg[x][y], x * m + y));
        deg[x][y]--;
        if(x == nx){
          ch[x][y] = (y < ny ? '<' : '>');
          ch[nx][ny] = (ny < y ? '<' : '>');
        }
        if(y == ny){
          ch[x][y] = (x < nx ? '^' : 'v');
          ch[nx][ny] = (nx < x ? '^' : 'v');
        }
        break;
      }
    }
  }
  //for(int i = 0; i < n; ++i){
    //for(int j = 0; j < m; ++j){
      if(ss.size()){
        printf("Not unique");
        return 0;
      }
    //}
  //}
  for(int i = 0; i < n; ++i){
    printf("%s\n", ch[i]);
  }
  return 0;
}


#include <bits/stdc++.h>

#define F first
#define S second
#define llong long long
#define ullong unsigned long long
#define mp make_pair
#define pb push_back

using namespace std;

const int INF = (int)1e9 + 7;
const llong LINF = (llong)1e18 + 9;
const int MXN = (int)4e6 + 10;
const double EPS = (double)1e-9;

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

int n, m;
char ch[2001][2001];
bool used[2001][2001];
int deg[2001][2001];
queue <pair <int, int> > q;

bool check(int x, int y){
  return (x >= 0 && y >= 0 && x < n && x < m && ch[x][y] == '.');
}

int main(){
  #ifndef ONLINE_JUDGE
      freopen("input.txt", "r", stdin);
  #endif
  scanf("%d%d\n", &n, &m);
  for(int i = 0; i < n; ++i){
    scanf("%s\n", &ch[i]);
  }
  int cnt = 0;
  for(int i = 0; i < n; ++i){
    for(int j = 0; j < m; ++j){
      if(check(i, j)){
        bool boo = false;
        for(int k = 0; k < 4; ++k){
          int nx = i + dx[k];
          int ny = j + dy[k];
          if(check(nx, ny)){
            deg[nx][ny]++;
            deg[i][j]++;
            boo = true;
          }
        }
        if(!boo){
          printf("Not unique");
          return 0;
        }
      }
      else {
        used[i][j] = true;
      }
    }
  }

  for(int i = 0; i < n; ++i){
    for(int j = 0; j < m; ++j){
      if(check(i, j)){
        deg[i][j] /= 2;
        if(deg[i][j] == 1)
          q.push(mp(i, j));
      }
    }
  }
  while(!q.empty()){
    pair <int, int> v = q.front();
    q.pop();
    //cerr << v.F << " " << v.S << "\n";
    if(used[v.F][v.S])
      continue;
    /*if(deg[v.F][v.S] != 1){
      printf("Not unique");
      return 0;
    }*/
    pair <int, int> nw;
    bool boo = false;
    for(int i = 0; i < 4; ++i){
      int nx = v.F + dx[i];
      int ny = v.S + dy[i];
      if(check(nx, ny) && !used[nx][ny]){
        nw = mp(nx, ny);
        boo = true;
        break;
      }
    }
    if(!boo){
      printf("Not unique");
      return 0;
    }
    used[v.F][v.S] = true;
    used[nw.F][nw.S] = true;
    deg[v.F][v.S] = 0;
    deg[nw.F][nw.S] = 0;
    if(nw.F == v.F){
      ch[v.F][min(v.S, nw.S)] = '<';
      ch[v.F][max(v.S, nw.S)] = '>';
    }
    if(nw.S == v.S){
      ch[min(v.F, nw.F)][v.S] = '^';
      ch[max(v.F, nw.F)][v.S] = 'v';
    }
    used[nw.F][nw.S] = true;
    for(int i = 0; i < 4; ++i){
      int nx = nw.F + dx[i];
      int ny = nw.S + dy[i];
      if(check(nx, ny) && !used[nx][ny]){
        deg[nx][ny]--;
        if(deg[nx][ny] == 1)
          q.push(mp(nx, ny));
      }
    }
  }
  for(int i = 0; i < n; ++i){
    for(int j = 0; j < m; ++j){
      if(deg[i][j]){
        //printf("%d %d %d\n", i, j, deg[i][j]);
        printf("Not unique");
        return 0;
      }
    }
  }
  for(int i = 0; i < n; ++i){
    printf("%s\n", ch[i]);
  }
  return 0;
}


#include <bits/stdc++.h>

#define F first
#define S second
#define llong long long
#define ullong unsigned long long
#define mp make_pair
#define pb push_back

using namespace std;

const int INF = (int)1e9 + 7;
const llong LINF = (llong)1e18 + 9;
const int MXN = (int)4e6 + 10;
const double EPS = (double)1e-9;

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

int n, m;
char ch[2001][2001];
bool used[2001][2001];
set <pair <int, int> > ss;
int deg[2001][2001];

bool check(int x, int y){
  return (x >= 0 && y >= 0 && x < n && x < m && ch[x][y] == '.');
}

int main(){
  #ifndef ONLINE_JUDGE
      freopen("input.txt", "r", stdin);
  #endif
  scanf("%d%d\n", &n, &m);
  for(int i = 0; i < n; ++i){
    scanf("%s\n", &ch[i]);
  }
  int cnt = 0;
  for(int i = 0; i < n; ++i){
    for(int j = 0; j < m; ++j){
      if(check(i, j)){
        bool boo = false;
        for(int k = 0; k < 4; ++k){
          int nx = i + dx[k];
          int ny = j + dy[k];
          if(check(nx, ny)){
            deg[nx][ny]++;
            deg[i][j]++;
            boo = true;
          }
        }
        if(!boo){
          printf("Not unique");
          return 0;
        }
      }
      else {
        used[i][j] = true;
      }
    }
  }
  for(int i = 0; i < n; ++i){
    for(int j = 0; j < m; ++j){
      if(check(i, j)){
        deg[i][j] /= 2;
        ss.insert(mp(deg[i][j], i * m + j));
      }
    }
  }
  while(ss.size()){
    pair <int, int> tmp = *(ss.begin());
    ss.erase(ss.begin());
    int x = tmp.S / m;
    int y = tmp.S % m;
    if(deg[x][y] != 1){
      printf("Not unique");
      return 0;
    }
    for(int k = 0; k < 4; ++k){
      int nx = x + dx[k];
      int ny = y + dy[k];
      if(check(nx, ny)){
        used[x][y] = true;
        used[nx][ny] = true;
        for(int s = 0; s < 4; ++s){
          int nnx = nx + dx[s];
          int nny = ny + dy[s];
          if(!used[nnx][nny] && check(nnx, nny)){
            ss.erase(mp(deg[nnx][nny], nnx * m + nny));
            deg[nnx][nny]--;
            //if(deg[nnx][nny])
              ss.insert(mp(deg[nnx][nny], nnx * m + nny));
          }
        }
        ss.erase(mp(deg[nx][ny], nx * m + ny));
        deg[nx][ny]--;
        ss.erase(mp(deg[x][y], x * m + y));
        deg[x][y]--;
        if(x == nx){
          ch[x][y] = (y < ny ? '<' : '>');
          ch[nx][ny] = (ny < y ? '<' : '>');
        }
        if(y == ny){
          ch[x][y] = (x < nx ? '^' : 'v');
          ch[nx][ny] = (nx < x ? '^' : 'v');
        }
        break;
      }
    }
  }
  for(int i = 0; i < n; ++i){
    printf("%s\n", ch[i]);
  }
  return 0;
}


#include <bits/stdc++.h>

#define F first
#define S second
#define llong long long
#define ullong unsigned long long
#define mp make_pair
#define pb push_back

using namespace std;

const int INF = (int)1e9 + 7;
const llong LINF = (llong)1e18 + 9;
const int MXN = (int)4e6 + 10;
const double EPS = (double)1e-9;

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

int n, m;
char ch[2001][2001];
bool used[2001][2001];
int deg[2001][2001];
queue <pair <int, int> > q;

bool check(int x, int y){
  return (x >= 0 && y >= 0 && x < n && y < m && ch[x][y] == '.');
}

int main(){
  #ifndef ONLINE_JUDGE
      freopen("input.txt", "r", stdin);
  #endif
  scanf("%d%d\n", &n, &m);
  for(int i = 0; i < n; ++i){
    scanf("%s\n", &ch[i]);
  }
  for(int i = 0; i < n; ++i){
    for(int j = 0; j < m; ++j){
      if(check(i, j)){
        bool boo = false;
        for(int k = 0; k < 4; ++k){
          int nx = i + dx[k];
          int ny = j + dy[k];
          if(check(nx, ny)){
            deg[nx][ny]++;
            deg[i][j]++;
            boo = true;
          }
        }
        if(!boo){
          printf("Not unique");
          return 0;
        }
      }
      else {
        used[i][j] = true;
      }
    }
  }

  for(int i = 0; i < n; ++i){
    for(int j = 0; j < m; ++j){
      if(check(i, j)){
        deg[i][j] /= 2;
        if(deg[i][j] == 1)
          q.push(mp(i, j));
      }
    }
  }
  while(!q.empty()){
    pair <int, int> v = q.front();
    q.pop();
    //cerr << v.F << " " << v.S << "\n";
    //if(used[v.F][v.S])
    //  continue;
    /*if(deg[v.F][v.S] != 1){
      printf("Not unique");
      return 0;
    }*/
    pair <int, int> nw;
    bool boo = false;
    for(int i = 0; i < 4; ++i){
      int nx = v.F + dx[i];
      int ny = v.S + dy[i];
      if(check(nx, ny) && !used[nx][ny]){
        nw = mp(nx, ny);
        boo = true;
        break;
      }
    }
    if(!boo){
      printf("Not unique");
      return 0;
    }
    used[v.F][v.S] = true;
    used[nw.F][nw.S] = true;
    deg[v.F][v.S] = 0;
    deg[nw.F][nw.S] = 0;
    if(nw.F == v.F){
      ch[v.F][min(v.S, nw.S)] = '<';
      ch[v.F][max(v.S, nw.S)] = '>';
    }
    if(nw.S == v.S){
      ch[min(v.F, nw.F)][v.S] = '^';
      ch[max(v.F, nw.F)][v.S] = 'v';
    }
    for(int i = 0; i < 4; ++i){
      int nx = nw.F + dx[i];
      int ny = nw.S + dy[i];
      if(check(nx, ny) && !used[nx][ny]){
        deg[nx][ny]--;
        if(deg[nx][ny] == 1)
          q.push(mp(nx, ny));
      }
    }
  }
  for(int i = 0; i < n; ++i){
    for(int j = 0; j < m; ++j){
      if(deg[i][j]){
        //printf("%d %d %d\n", i, j, deg[i][j]);
        printf("Not unique");
        return 0;
      }
    }
  }
  for(int i = 0; i < n; ++i){
    printf("%s\n", ch[i]);
  }
  return 0;
}


#include <bits/stdc++.h>

#define F first
#define S second
#define llong long long
#define ullong unsigned long long
#define mp make_pair
#define pb push_back

using namespace std;

const int INF = (int)1e9 + 7;
const llong LINF = (llong)1e18 + 9;
const int MXN = (int)4e6 + 10;
const double EPS = (double)1e-9;

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

int n, m;
char ch[2001][2001];
bool used[2001][2001];
set <pair <int, int> > ss;
int deg[2001][2001];

bool check(int x, int y){
  return (x >= 0 && y >= 0 && x < n && x < m && ch[x][y] == '.');
}

int main(){
  #ifndef ONLINE_JUDGE
      freopen("input.txt", "r", stdin);
  #endif
  scanf("%d%d\n", &n, &m);
  for(int i = 0; i < n; ++i){
    scanf("%s\n", &ch[i]);
  }
  int cnt = 0;
  for(int i = 0; i < n; ++i){
    for(int j = 0; j < m; ++j){
      if(check(i, j)){
        bool boo = false;
        ++cnt;
        for(int k = 0; k < 4; ++k){
          int nx = i + dx[k];
          int ny = j + dy[k];
          if(check(nx, ny)){
            deg[nx][ny]++;
            deg[i][j]++;
            boo = true;
          }
        }
        if(!boo){
          printf("Not unique");
          return 0;
        }
      }
      else {
        used[i][j] = true;
      }
    }
  }
  if(cnt % 2){
    printf("Not unique");
    return 0;
  }
  for(int i = 0; i < n; ++i){
    for(int j = 0; j < m; ++j){
      if(check(i, j)){
        deg[i][j] /= 2;
        ss.insert(mp(deg[i][j], i * m + j));
      }
    }
  }
  for(set<pair <int, int> >::iterator it = ss.begin(); it != ss.end(); ++it){
    pair <int, int> tmp = *it;
    int x = tmp.S / m;
    int y = tmp.S % m;
    //cerr << x << " " << y << " " <<deg[x][y]<< "\n";
    if(!deg[x][y] || used[x][y]){
      continue;
    }
    if(deg[x][y] != 1){
      printf("Not unique");
      return 0;
    }
    for(int k = 0; k < 4; ++k){
      int nx = x + dx[k];
      int ny = y + dy[k];
      if(check(nx, ny)){
        used[x][y] = true;
        used[nx][ny] = true;
        for(int s = 0; s < 4; ++s){
          int nnx = nx + dx[s];
          int nny = ny + dy[s];
          if(!used[nnx][nny] && check(nnx, nny)){
            ss.erase(mp(deg[nnx][nny], nnx * m + nny));
            deg[nnx][nny]--;
            if(deg[nnx][nny])
              ss.insert(mp(deg[nnx][nny], nnx * m + nny));
          }
        }
        ss.erase(mp(deg[nx][ny], nx * m + ny));
        deg[nx][ny]--;
        if(deg[nx][ny])
          ss.insert(mp(deg[nx][ny], nx * m + ny));

        ss.erase(mp(deg[x][y], x * m + y));
        deg[x][y]--;
        if(deg[x][y])
          ss.insert(mp(deg[x][y], x * m + y));
        if(x == nx){
          ch[x][y] = (y < ny ? '<' : '>');
          ch[nx][ny] = (ny < y ? '<' : '>');
        }
        if(y == ny){
          ch[x][y] = (x < nx ? '^' : 'v');
          ch[nx][ny] = (nx < x ? '^' : 'v');
        }
        break;
      }
    }
  }
  for(int i = 0; i < n; ++i){
    for(int j = 0; j < m; ++j){
      if(deg[i][j]){
        printf("Not unique");
        return 0;
      }
    }
  }
  for(int i = 0; i < n; ++i){
    printf("%s\n", ch[i]);
  }
  return 0;
}


#include <bits/stdc++.h>

#define F first
#define S second
#define llong long long
#define ullong unsigned long long
#define mp make_pair
#define pb push_back

using namespace std;

const int INF = (int)1e9 + 7;
const llong LINF = (llong)1e18 + 9;
const int MXN = (int)4e6 + 10;
const double EPS = (double)1e-9;

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

int n, m;
char ch[2001][2001];
bool used[2001][2001];
set <pair <int, int> > ss;
int deg[2001][2001];

bool check(int x, int y){
  return (x >= 0 && y >= 0 && x < n && x < m && ch[x][y] == '.');
}

int main(){
  #ifndef ONLINE_JUDGE
      freopen("input.txt", "r", stdin);
  #endif
  scanf("%d%d\n", &n, &m);
  for(int i = 0; i < n; ++i){
    scanf("%s\n", &ch[i]);
  }
  int cnt = 0;
  for(int i = 0; i < n; ++i){
    for(int j = 0; j < m; ++j){
      if(check(i, j)){
        bool boo = false;
        for(int k = 0; k < 4; ++k){
          int nx = i + dx[k];
          int ny = j + dy[k];
          if(check(nx, ny)){
            deg[nx][ny]++;
            deg[i][j]++;
            boo = true;
          }
        }
        if(!boo){
          printf("Not unique");
          return 0;
        }
      }
      else {
        used[i][j] = true;
      }
    }
  }
  for(int i = 0; i < n; ++i){
    for(int j = 0; j < m; ++j){
      if(check(i, j)){
        deg[i][j] /= 2;
        ss.insert(mp(deg[i][j], i * m + j));
      }
    }
  }
  while(ss.size()){
    pair <int, int> tmp = *(ss.begin());
    ss.erase(ss.begin());
    int x = tmp.S / m;
    int y = tmp.S % m;
    if(!deg[x][y] || used[x][y]){
      continue;
    }
    if(deg[x][y] > 1){
      printf("Not unique");
      return 0;
    }
    for(int k = 0; k < 4; ++k){
      int nx = x + dx[k];
      int ny = y + dy[k];
      if(check(nx, ny)){
        used[x][y] = true;
        used[nx][ny] = true;
        for(int s = 0; s < 4; ++s){
          int nnx = nx + dx[s];
          int nny = ny + dy[s];
          if(!used[nnx][nny] && check(nnx, nny)){
            ss.erase(mp(deg[nnx][nny], nnx * m + nny));
            deg[nnx][nny]--;
            //if(deg[nnx][nny])
              ss.insert(mp(deg[nnx][nny], nnx * m + nny));
          }
        }
        ss.erase(mp(deg[nx][ny], nx * m + ny));
        deg[nx][ny]--;
        ss.erase(mp(deg[x][y], x * m + y));
        deg[x][y]--;
        if(x == nx){
          ch[x][y] = (y < ny ? '<' : '>');
          ch[nx][ny] = (ny < y ? '<' : '>');
        }
        if(y == ny){
          ch[x][y] = (x < nx ? '^' : 'v');
          ch[nx][ny] = (nx < x ? '^' : 'v');
        }
        break;
      }
    }
  }
  //for(int i = 0; i < n; ++i){
    //for(int j = 0; j < m; ++j){
      if(ss.size()){
        printf("Not unique");
        return 0;
      }
    //}
  //}
  for(int i = 0; i < n; ++i){
    printf("%s\n", ch[i]);
  }
  return 0;
}


#include <bits/stdc++.h>

#define F first
#define S second
#define llong long long
#define ullong unsigned long long
#define mp make_pair
#define pb push_back

using namespace std;

const int INF = (int)1e9 + 7;
const llong LINF = (llong)1e18 + 9;
const int MXN = (int)4e6 + 10;
const double EPS = (double)1e-9;

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

int n, m;
char ch[2001][2001];
bool used[2001][2001];
int deg[2001][2001];
queue <pair <int, int> > q;

bool check(int x, int y){
  return (x >= 0 && y >= 0 && x < n && x < m && ch[x][y] == '.');
}

int main(){
  #ifndef ONLINE_JUDGE
      freopen("input.txt", "r", stdin);
  #endif
  scanf("%d%d\n", &n, &m);
  for(int i = 0; i < n; ++i){
    scanf("%s\n", &ch[i]);
  }
  int cnt = 0;
  for(int i = 0; i < n; ++i){
    for(int j = 0; j < m; ++j){
      if(check(i, j)){
        bool boo = false;
        for(int k = 0; k < 4; ++k){
          int nx = i + dx[k];
          int ny = j + dy[k];
          if(check(nx, ny)){
            deg[nx][ny]++;
            deg[i][j]++;
            boo = true;
          }
        }
        if(!boo){
          printf("Not unique1");
          return 0;
        }
      }
      else {
        used[i][j] = true;
      }
    }
  }

  for(int i = 0; i < n; ++i){
    for(int j = 0; j < m; ++j){
      if(check(i, j)){
        deg[i][j] /= 2;
        if(deg[i][j] == 1)
          q.push(mp(i, j));
      }
    }
  }
  while(!q.empty()){
    pair <int, int> v = q.front();
    q.pop();
    if(used[v.F][v.S])
      continue;
    used[v.F][v.S] = true;
    pair <int, int> nw;
    for(int i = 0; i < 4; ++i){
      int nx = v.F + dx[i];
      int ny = v.S + dy[i];
      if(check(nx, ny) && !used[nx][ny]){
        nw = mp(nx, ny);
        break;
      }
    }
    deg[v.F][v.S] = 0;
    deg[nw.F][nw.S] = 0;
    if(nw.F == v.F){
      ch[v.F][min(v.S, nw.S)] = '<';
      ch[v.F][max(v.S, nw.S)] = '>';
    }
    if(nw.S == v.S){
      ch[min(v.F, nw.F)][v.S] = '^';
      ch[max(v.F, nw.F)][v.S] = 'v';
    }
    used[nw.F][nw.S] = true;
    for(int i = 0; i < 4; ++i){
      int nx = nw.F + dx[i];
      int ny = nw.S + dy[i];
      if(check(nx, ny) && !used[nx][ny]){
        deg[nx][ny]--;
        if(deg[nx][ny] == 1)
          q.push(mp(nx, ny));
      }
    }
  }
  for(int i = 0; i < n; ++i){
    for(int j = 0; j < m; ++j){
      if(deg[i][j]){
        //printf("%d %d %d\n", i, j, deg[i][j]);
        printf("Not unique");
        return 0;
      }
    }
  }
  for(int i = 0; i < n; ++i){
    printf("%s\n", ch[i]);
  }
  return 0;
}


#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<ctime>
#include<vector>
#include<queue>
#define maxn 2100+10
#define inf 1<<30
#define eps 1e-10
#define pi 3.141592653589793
using namespace std;

typedef long long LL;

int n,m;
int qx[4000005],qy[4000005];
char s[maxn][maxn];
bool inq[maxn][maxn]={0};
const int dx[]={0,1,0,-1};
const int dy[]={1,0,-1,0};

int work(int x,int y)
{
	int res=0;
	for(int i=0;i<4;i++)
	{
		int nowx=x+dx[i],nowy=y+dy[i];
		res+=s[nowx][nowy]=='.';
	}
	return res;
}

LL read()
{
	LL k=0;char x=getchar();
	while((x<'0'||x>'9')&&(x!='-')) x=getchar();
	bool f=false;
	if(x=='-') f=true,x=getchar();
	while(x>='0'&&x<='9')
	{
		k=k*10-48+x;
		x=getchar();
	}
	if(f) k=-k;
	return k;
}

int main()
{
//	freopen("515d.in","r",stdin);
//	freopen("515d.out","w",stdout);
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++)  scanf("%s",s[i]+1);
	for(int i=0;i<=m+1;i++)  s[0][i]=s[n+1][i]='*';
	for(int i=0;i<=n+1;i++)  s[i][0]=s[i][m+1]='*';
	int cnt=0;
	int front=0,rear=0;
	for(int i=1;i<=n;i++)  for(int j=1;j<=m;j++)  if(s[i][j]=='.')
	{
		cnt++;
		if(work(i,j)==1)  qx[rear]=i,qy[rear++]=j,inq[i][j]=true;
	}
	while(front!=rear)
	{
		int x=qx[front],y=qy[front++];
		if(s[x][y]!='.')  continue;
		int vx=-1,vy=-1,tmp;
		for(int i=0;i<4;i++)
		{
			int nowx=x+dx[i],nowy=y+dy[i];
			if(s[nowx][nowy]=='.')
			{
				tmp=i;vx=nowx;vy=nowy;break;
			}
		}
		if(vx==-1)
		{
			printf("Not unique\n");
			return 0;
		}
		if(tmp==0)
		{
			s[x][y+1]='>';
			s[x][y]='<';
		}
		else if(tmp==1)
		{
			s[x+1][y]='v';
			s[x][y]='^';
		}
		else if(tmp==2)
		{
			s[x][y-1]='<';
			s[x][y]='>';
		}
		else
		{
			s[x-1][y]='^';
			s[x][y]='v';
		}
		cnt-=2;
		for(int i=0;i<4;i++)
		{
			int nowx=vx+dx[i],nowy=vy+dy[i];
			if(s[nowx][nowy]=='.'&&!inq[nowx][nowy]&&work(nowx,nowy)==1)
			{
				qx[rear]=nowx;qy[rear++]=nowy;inq[nowx][nowy]=true;
			}
		}
	}
	if(cnt)
	{
		printf("Not unique\n");
		return 0;
	}
	else
	{
		for(int i=1;i<=n;i++)
		{
			for(int j=1;j<=m;j++)  printf("%c",s[i][j]);
			printf("\n");
		}
	}
//	printf("Time used =%.6lf\n",(double)clock()/CLOCKS_PER_SEC);
	return 0;
}


#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<ctime>
#include<vector>
#include<queue>
#define maxn 3000+10
#define inf 1<<30
#define eps 1e-10
#define pi 3.141592653589793
using namespace std;

typedef long long LL;

int n,m,cnt;
int qx[maxn*maxn],qy[maxn*maxn];
int d[maxn][maxn];
char s[maxn][maxn];
bool inq[maxn][maxn];
const int dx[]={0,1,0,-1};
const int dy[]={1,0,-1,0};

int work(int x,int y)
{
	int nowx,nowy,res=0;
	for(int i=0;i<4;i++)
	{
		nowx=x+dx[i];nowy=y+dy[i];
		res+=s[nowx][nowy]=='.';
	}
	return res;
}

LL read()
{
	LL k=0;char x=getchar();
	while((x<'0'||x>'9')&&(x!='-')) x=getchar();
	bool f=false;
	if(x=='-') f=true,x=getchar();
	while(x>='0'&&x<='9')
	{
		k=k*10-48+x;
		x=getchar();
	}
	if(f) k=-k;
	return k;
}

int main()
{
//	freopen("515d.in","r",stdin);
//	freopen("515d.out","w",stdout);
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++)  scanf("%s",s[i]+1);
	for(int i=0;i<=m+1;i++)  s[0][i]=s[n+1][i]='*';
	for(int i=0;i<=n+1;i++)  s[i][0]=s[i][m+1]='*';
	int front=0,rear=0;
	for(int i=1;i<=n;i++)  for(int j=1;j<=m;j++)
	{
		if(s[i][j]=='.')
		{
			cnt++;
			if(work(i,j)==1)  qx[rear]=i,qy[rear++]=j,inq[i][j]=true;
		}
	}
	while(front!=rear)
	{
		int x=qx[front],y=qy[front++];//inq[x][y]=false;
		if(s[x][y]!='.')  continue;
		int vx=-1,vy=-1,tmp;
		for(int i=0;i<4;i++)
		{
			int nowx=x+dx[i],nowy=y+dy[i];
			if(s[nowx][nowy]=='.')
			{
				tmp=i;vx=nowx;vy=nowy;break;
			}
		}
		if(vx==-1)
		{
			printf("Not unique\n");
			return 0;
		}
		if(tmp==0)
		{
			s[x][y+1]='>';s[x][y]='<';
		}
		else if(tmp==1)
		{
			s[x+1][y]='v';s[x][y]='^';
		}
		else if(tmp==2)
		{
			s[x][y-1]='<';s[x][y]='>';
		}
		else if(tmp==3)
		{
			s[x-1][y]='^';s[x][y]='v';
		}
		cnt-=2;
		for(int i=0;i<4;i++)
		{
			int nowx=vx+dx[i],nowy=vy+dy[i];
			if(s[nowx][nowy]=='.'&&!inq[nowx][nowy]&&work(nowx,nowy)==1)
			{
				qx[rear]=nowx;qy[rear++]=nowy;inq[nowx][nowy]=true;
			}
		}
	}
	if(cnt)
	{
		printf("Not unique");
		return 0;
	}
	else
	{
		for(int i=1;i<=n;i++)
		{
			for(int j=1;j<=m;j++)  printf("%c",s[i][j]);
			printf("\n");
		}
	}
//	printf("Time used =%.6lf\n",(double)clock()/CLOCKS_PER_SEC);
	return 0;
}


#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<ctime>
#include<vector>
#include<queue>
#define maxn 2000+10
#define inf 1<<30
#define eps 1e-10
#define pi 3.141592653589793
using namespace std;

typedef long long LL;

int n,m,cnt;
int qx[maxn*maxn],qy[maxn*maxn];
int d[maxn][maxn];
char s[maxn][maxn];
bool inq[maxn][maxn];
const int dx[]={0,1,0,-1};
const int dy[]={1,0,-1,0};

int work(int x,int y)
{
	int nowx,nowy,res=0;
	for(int i=0;i<4;i++)
	{
		nowx=x+dx[i];nowy=y+dy[i];
		res+=s[nowx][nowy]=='.';
	}
	return res;
}

LL read()
{
	LL k=0;char x=getchar();
	while((x<'0'||x>'9')&&(x!='-')) x=getchar();
	bool f=false;
	if(x=='-') f=true,x=getchar();
	while(x>='0'&&x<='9')
	{
		k=k*10-48+x;
		x=getchar();
	}
	if(f) k=-k;
	return k;
}

int main()
{
//	freopen("515d.in","r",stdin);
//	freopen("515d.out","w",stdout);
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++)  scanf("%s",s[i]+1);
	for(int i=0;i<=m+1;i++)  s[0][i]=s[n+1][i]='*';
	for(int i=0;i<=n+1;i++)  s[i][0]=s[i][m+1]='*';
	int front=0,rear=0;
	for(int i=1;i<=n;i++)  for(int j=1;j<=m;j++)
	{
		if(s[i][j]=='.')
		{
			cnt++;
			if(work(i,j)==1)  qx[rear]=i,qy[rear++]=j,inq[i][j]=true;
		}
	}
	while(front!=rear)
	{
		int x=qx[front],y=qy[front++];//inq[x][y]=false;
		if(s[x][y]!='.')  continue;
		int vx=-1,vy=-1,tmp;
		for(int i=0;i<4;i++)
		{
			int nowx=x+dx[i],nowy=y+dy[i];
			if(s[nowx][nowy]=='.')
			{
				tmp=i;vx=nowx;vy=nowy;break;
			}
		}
		if(vx==-1)
		{
			printf("Not unique\n");
			return 0;
		}
		if(tmp==0)
		{
			s[x][y+1]='>';s[x][y]='<';
		}
		else if(tmp==1)
		{
			s[x+1][y]='v';s[x][y]='^';
		}
		else if(tmp==2)
		{
			s[x][y-1]='<';s[x][y]='>';
		}
		else if(tmp==3)
		{
			s[x-1][y]='^';s[x][y]='v';
		}
		cnt-=2;
		for(int i=0;i<4;i++)
		{
			int nowx=vx+dx[i],nowy=vy+dy[i];
			if(s[nowx][nowy]=='.'&&!inq[nowx][nowy]&&work(nowx,nowy)==1)
			{
				qx[rear]=nowx;qy[rear++]=nowy;inq[nowx][nowy]=true;
			}
		}
	}
	if(cnt)
	{
		printf("Not unique");
		return 0;
	}
	else
	{
		for(int i=1;i<=n;i++)
		{
			for(int j=1;j<=m;j++)  printf("%c",s[i][j]);
			printf("\n");
		}
	}
//	printf("Time used =%.6lf\n",(double)clock()/CLOCKS_PER_SEC);
	return 0;
}


#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<ctime>
#include<vector>
#include<queue>
#define maxn 2100
#define inf 1<<30
#define eps 1e-10
#define pi 3.141592653589793
using namespace std;

typedef long long LL;

int n,m;
int qx[maxn*maxn],qy[maxn*maxn];
char s[maxn][maxn];
bool inq[maxn][maxn]={0};
const int dx[]={0,1,0,-1};
const int dy[]={1,0,-1,0};

int work(int x,int y)
{
	int res=0;
	for(int i=0;i<4;i++)
	{
		int nowx=x+dx[i],nowy=y+dy[i];
		res+=s[nowx][nowy]=='.';
	}
	return res;
}

LL read()
{
	LL k=0;char x=getchar();
	while((x<'0'||x>'9')&&(x!='-')) x=getchar();
	bool f=false;
	if(x=='-') f=true,x=getchar();
	while(x>='0'&&x<='9')
	{
		k=k*10-48+x;
		x=getchar();
	}
	if(f) k=-k;
	return k;
}

int main()
{
//	freopen("515d.in","r",stdin);
//	freopen("515d.out","w",stdout);
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++)  scanf("%s",s[i]+1);
	for(int i=0;i<=m+1;i++)  s[0][i]=s[n+1][i]='*';
	for(int i=0;i<=n+1;i++)  s[i][0]=s[i][m+1]='*';
	int cnt=0;
	int front=0,rear=0;
	for(int i=1;i<=n;i++)  for(int j=1;j<=m;j++)  if(s[i][j]=='.')
	{
		cnt++;
		if(work(i,j)==1)  qx[rear]=i,qy[rear++]=j,inq[i][j]=true;
	}
	while(front!=rear)
	{
		int x=qx[front],y=qy[front++];
		if(s[x][y]!='.')  continue;
		int vx=-1,vy=-1,tmp;
		for(int i=0;i<4;i++)
		{
			int nowx=x+dx[i],nowy=y+dy[i];
			if(s[nowx][nowy]=='.')
			{
				tmp=i;vx=nowx;vy=nowy;break;
			}
		}
		if(vx==-1)
		{
			printf("Not unique\n");
			return 0;
		}
		if(tmp==0)
		{
			s[x][y+1]='>';
			s[x][y]='<';
		}
		else if(tmp==1)
		{
			s[x+1][y]='v';
			s[x][y]='^';
		}
		else if(tmp==2)
		{
			s[x][y-1]='<';
			s[x][y]='>';
		}
		else
		{
			s[x-1][y]='^';
			s[x][y]='v';
		}
		cnt-=2;
		for(int i=0;i<4;i++)
		{
			int nowx=vx+dx[i],nowy=vy+dy[i];
			if(s[nowx][nowy]=='.'&&!inq[nowx][nowy]&&work(nowx,nowy)==1)
			{
				qx[rear]=nowx;qy[rear++]=nowy;inq[nowx][nowy]=true;
			}
		}
	}
	if(cnt)
	{
		printf("Not unique\n");
		return 0;
	}
	else
	{
		for(int i=1;i<=n;i++)
		{
			for(int j=1;j<=m;j++)  printf("%c",s[i][j]);
			printf("\n");
		}
	}
//	printf("Time used =%.6lf\n",(double)clock()/CLOCKS_PER_SEC);
	return 0;
}


#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<ctime>
#include<vector>
#include<queue>
#define maxn 2100+10
#define inf 1<<30
#define eps 1e-10
#define pi 3.141592653589793
using namespace std;

typedef long long LL;

int n,m,cnt;
int qx[maxn*maxn],qy[maxn*maxn];
int d[maxn][maxn];
char s[maxn][maxn];
bool inq[maxn][maxn];
const int dx[]={0,1,0,-1};
const int dy[]={1,0,-1,0};

int work(int x,int y)
{
	int nowx,nowy,res=0;
	for(int i=0;i<4;i++)
	{
		nowx=x+dx[i];nowy=y+dy[i];
		res+=s[nowx][nowy]=='.';
	}
	return res;
}

LL read()
{
	LL k=0;char x=getchar();
	while((x<'0'||x>'9')&&(x!='-')) x=getchar();
	bool f=false;
	if(x=='-') f=true,x=getchar();
	while(x>='0'&&x<='9')
	{
		k=k*10-48+x;
		x=getchar();
	}
	if(f) k=-k;
	return k;
}

int main()
{
//	freopen("515d.in","r",stdin);
//	freopen("515d.out","w",stdout);
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++)  scanf("%s",s[i]+1);
	for(int i=0;i<=m+1;i++)  s[0][i]=s[n+1][i]='*';
	for(int i=0;i<=n+1;i++)  s[i][0]=s[i][m+1]='*';
	int front=0,rear=0;
	for(int i=1;i<=n;i++)  for(int j=1;j<=m;j++)
	{
		if(s[i][j]=='.')
		{
			cnt++;
			if(work(i,j)==1)  qx[rear]=i,qy[rear++]=j,inq[i][j]=true;
		}
	}
	while(front!=rear)
	{
		int x=qx[front],y=qy[front++];//inq[x][y]=false;
		if(s[x][y]!='.')  continue;
		int vx=-1,vy=-1,tmp;
		for(int i=0;i<4;i++)
		{
			int nowx=x+dx[i],nowy=y+dy[i];
			if(s[nowx][nowy]=='.')
			{
				tmp=i;vx=nowx;vy=nowy;break;
			}
		}
		if(vx==-1)
		{
			printf("Not unique\n");
			return 0;
		}
		if(tmp==0)
		{
			s[x][y+1]='>';s[x][y]='<';
		}
		else if(tmp==1)
		{
			s[x+1][y]='v';s[x][y]='^';
		}
		else if(tmp==2)
		{
			s[x][y-1]='<';s[x][y]='>';
		}
		else if(tmp==3)
		{
			s[x-1][y]='^';s[x][y]='v';
		}
		cnt-=2;
		for(int i=0;i<4;i++)
		{
			int nowx=vx+dx[i],nowy=vy+dy[i];
			if(s[nowx][nowy]=='.'&&!inq[nowx][nowy]&&work(nowx,nowy)==1)
			{
				qx[rear]=nowx;qy[rear++]=nowy;inq[nowx][nowy]=true;
			}
		}
	}
	if(cnt)
	{
		printf("Not unique");
		return 0;
	}
	else
	{
		for(int i=1;i<=n;i++)
		{
			for(int j=1;j<=m;j++)  printf("%c",s[i][j]);
			printf("\n");
		}
	}
//	printf("Time used =%.6lf\n",(double)clock()/CLOCKS_PER_SEC);
	return 0;
}


#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<ctime>
#include<vector>
#include<queue>
#define maxn 2100+10
#define inf 1<<30
#define eps 1e-10
#define pi 3.141592653589793
using namespace std;

typedef long long LL;

int n,m;
int qx[maxn*maxn],qy[maxn*maxn];
char s[maxn][maxn];
bool inq[maxn][maxn]={0};
const int dx[]={0,1,0,-1};
const int dy[]={1,0,-1,0};

int work(int x,int y)
{
	int res=0;
	for(int i=0;i<4;i++)
	{
		int nowx=x+dx[i],nowy=y+dy[i];
		res+=s[nowx][nowy]=='.';
	}
	return res;
}

LL read()
{
	LL k=0;char x=getchar();
	while((x<'0'||x>'9')&&(x!='-')) x=getchar();
	bool f=false;
	if(x=='-') f=true,x=getchar();
	while(x>='0'&&x<='9')
	{
		k=k*10-48+x;
		x=getchar();
	}
	if(f) k=-k;
	return k;
}

int main()
{
//	freopen("515d.in","r",stdin);
//	freopen("515d.out","w",stdout);
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++)  scanf("%s",s[i]+1);
	for(int i=0;i<=m+1;i++)  s[0][i]=s[n+1][i]='*';
	for(int i=0;i<=n+1;i++)  s[i][0]=s[i][m+1]='*';
	int cnt=0;
	int front=0,rear=0;
	for(int i=1;i<=n;i++)  for(int j=1;j<=m;j++)  if(s[i][j]=='.')
	{
		cnt++;
		if(work(i,j)==1)  qx[rear]=i,qy[rear++]=j,inq[i][j]=true;
	}
	while(front!=rear)
	{
		int x=qx[front],y=qy[front++];
		if(s[x][y]!='.')  continue;
		int vx=-1,vy=-1,tmp;
		for(int i=0;i<4;i++)
		{
			int nowx=x+dx[i],nowy=y+dy[i];
			if(s[nowx][nowy]=='.')
			{
				tmp=i;vx=nowx;vy=nowy;break;
			}
		}
		if(vx==-1)
		{
			printf("Not unique\n");
			return 0;
		}
		if(tmp==0)
		{
			s[x][y+1]='>';
			s[x][y]='<';
		}
		else if(tmp==1)
		{
			s[x+1][y]='v';
			s[x][y]='^';
		}
		else if(tmp==2)
		{
			s[x][y-1]='<';
			s[x][y]='>';
		}
		else
		{
			s[x-1][y]='^';
			s[x][y]='v';
		}
		cnt-=2;
		for(int i=0;i<4;i++)
		{
			int nowx=vx+dx[i],nowy=vy+dy[i];
			if(s[nowx][nowy]=='.'&&!inq[nowx][nowy]&&work(nowx,nowy)==1)
			{
				qx[rear]=nowx;qy[rear++]=nowy;inq[nowx][nowy]=true;
			}
		}
	}
	if(cnt)
	{
		printf("Not unique\n");
		return 0;
	}
	else
	{
		for(int i=1;i<=n;i++)
		{
			for(int j=1;j<=m;j++)  printf("%c",s[i][j]);
			printf("\n");
		}
	}
//	printf("Time used =%.6lf\n",(double)clock()/CLOCKS_PER_SEC);
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
const int maxn=2005;
typedef pair<int,int> pii;
#define x first
#define y second
#define mp make_pair

int dx[4]={0,0,-1,1};
int dy[4]={-1,1,0,0};
char ch[2][8]={"><v^","<>^v"};
char s[maxn][maxn];
pii bfs[maxn*maxn];
int n,m;
int deg[maxn][maxn];
int main()
{
//    freopen("in","r",stdin);
    int ll=0,rr=0;
    cin>>n>>m;
    for(int i=1;i<=n;i++)scanf("%s",s[i]+1);
    for(int i=1;i<=n;i++)
    for(int j=1;j<=m;j++){
        for(int k=0;k<4;k++){
            int nx=i+dx[k];
            int ny=j+dy[k];
            if(s[nx][ny]=='.')deg[i][j]++;
        }
        if(s[i][j]=='.'&&deg[i][j]==1)bfs[rr++]=mp(i,j);
    }
    while(ll<rr){
        pii now=bfs[ll++];
        int x=now.x,y=now.y;
        int nx,ny;
        int id;
        if(s[x][y]=='.'){
            bool suc=0;
            for(int k=0;k<4;k++){
                nx=x+dx[k];
                ny=y+dy[k];
                if(s[nx][ny]=='.'){
                    id=k;
                    suc=1;
                    break;
                }
            }
            if(!suc){
                puts("Not unique");
                return 0;
            }
            s[x][y]=ch[0][id];
            s[nx][ny]=ch[1][id];
            deg[x][y]=0;
            deg[nx][ny]=0;
            for(int k=0;k<4;k++){
                int nnx=nx+dx[k];
                int nny=ny+dy[k];
                deg[nnx][nny]--;
                if(deg[nnx][nny]==1)bfs[rr++]=mp(nnx,nny);
            }
        }
    }
    for(int i=1;i<=n;i++)
    for(int j=1;j<=n;j++){
        if(s[i][j]=='.'){
            puts("Not unique");
            return 0;
        }
    }
    for(int i=1;i<=n;i++)puts(s[i]+1);
    return 0;
}