You are given a grid of N rows and M columns. The square at the i-th row and j-th column will be denoted as (i,j). A nonnegative integer A_{i,j} is written for each square (i,j).

You choose some of the squares so that each row and column contains at most K chosen squares. Under this constraint, calculate the maximum value of the sum of the integers written on the chosen squares. Additionally, calculate a way to choose squares that acheives the maximum.

Constraints

* 1 \leq N \leq 50
* 1 \leq K \leq N
* 0 \leq A_{i,j} \leq 10^9
* All values in Input are integer.

Input

Input is given from Standard Input in the following format:


N K
A_{1,1} A_{1,2} \cdots A_{1,N}
A_{2,1} A_{2,2} \cdots A_{2,N}
\vdots
A_{N,1} A_{N,2} \cdots A_{N,N}


Output

On the first line, print the maximum value of the sum of the integers written on the chosen squares.

On the next N lines, print a way that achieves the maximum.

Precisely, output the strings t_1,t_2,\cdots,t_N, that satisfies t_{i,j}=`X` if you choose (i,j) and t_{i,j}=`.` otherwise.

You may print any way to choose squares that maximizes the sum.

Examples

Input

3 1
5 3 2
1 4 8
7 6 9


Output

19
X..
..X
.X.


Input

3 2
10 10 1
10 10 1
1 1 10


Output

50
XX.
XX.
..X
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp(x) fixed << setprecision(x)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
using ll = long long;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const int MOD = 1000000007;
//const int MOD = 998244353;
const int inf = (1<<30)-1;
const ll INF = (1LL<<60)-1;
const double pi = acos(-1.0);
const double EPS = 1e-10;
template<typename T> bool chmax(T &x, const T &y) {return (x < y)? (x = y, true) : false;};
template<typename T> bool chmin(T &x, const T &y) {return (x > y)? (x = y, true) : false;};

template<typename T>
struct Min_Cost_Flow{
    struct edge{
        int to; T cap, cost; int rev;
        edge(int to, T cap, T cost, int rev) : to(to), cap(cap), cost(cost), rev(rev) {} 
    };

    vector<vector<edge>> es;
    vector<T> d;
    vector<int> pre_v, pre_e;
    const T INF_T;
    const int n;

    Min_Cost_Flow(int n) : INF_T(numeric_limits<T>::max()), n(n){
        es.resize(n), d.resize(n), pre_v.resize(n), pre_e.resize(n);
    }

    void add_edge(int from, int to, T cap, T cost){
        es[from].eb(to, cap, cost, sz(es[to]));
        es[to].eb(from, 0, -cost, sz(es[from])-1);
    }

    void bellman_ford(int s){
        fill(all(d), INF_T);
        d[s] = 0;
        while(true){
            bool update = false;
            rep(i, n){
                if(d[i] == INF_T) continue;
                rep(j, sz(es[i])){
                    edge &e = es[i][j];
                    if(e.cap > 0 && chmin(d[e.to], d[i]+e.cost)){
                        pre_v[e.to] = i, pre_e[e.to] = j;
                        update = true;
                    }
                }
            }
            if(!update) break;
        }
    }

    T min_cost_flow(int s, int t, T flow){
        T ret = 0;
        while(flow > 0){
            bellman_ford(s);
            if(d[t] == INF_T) return -1;
            T f = flow;
            for(int now = t; now != s; now = pre_v[now]){
                chmin(f, es[pre_v[now]][pre_e[now]].cap);
            }
            ret += f*d[t], flow -= f;
            for(int now = t; now != s; now = pre_v[now]){
                edge &e = es[pre_v[now]][pre_e[now]];
                e.cap -= f, es[now][e.rev].cap += f;
            }
        }
        return ret;
    }
};

int main(){
    int N, K;
    cin >> N >> K;
    Min_Cost_Flow<ll> G(2*N+2);
    int s = 2*N, t = 2*N+1;
    rep(i, N){
        G.add_edge(s, i, K, 0), G.add_edge(N+i, t, K, 0);
        rep(j, N){
            ll A; cin >> A;
            G.add_edge(i, N+j, 1, -A);
        }
    }
    G.add_edge(s, t, K*N, 0);
    cout << -G.min_cost_flow(s, t, K*N) << endl;
    char ans[N][N];
    rep(i, N){
        for(auto &e: G.es[i]){
            if(e.to == s) continue;
            ans[i][e.to-N] = (e.cap == 0? 'X' : '.');
        }
    }
    rep(i, N){
        rep(j, N) cout << ans[i][j];
        cout << endl;
    }
}