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 F first
#define S second
typedef long long LL;
const LL INF = 0x3f3f3f3f3f3f3f3fLL;
typedef pair<LL, LL> pLL;
// LatexBegin
struct MCMF { LL flow, cost;
  struct Node : vector<int> { int p, inq; LL a, d; };
  struct Edge { int u, v; LL c, co; };
  vector<Node> N; vector<Edge> E;
  void init(int n) {
    N.clear(); N.resize(n); E.clear(); flow = cost = 0;
  }
  void addEdge(int u, int v, LL c, LL co) {
    int m = E.size();
    E.push_back({u, v, c,  co}); N[u].push_back(m++); 
    E.push_back({v, u, 0, -co}); N[v].push_back(m++);
  }
  void run(int s, int t) {
    while (SPFA(s, t)) {
      flow += N[t].a; cost += N[t].d * N[t].a;
      for (int u = t ; u != s ; u = E[N[u].p].u) {
        E[N[u].p    ].c -= N[t].a;
        E[N[u].p ^ 1].c += N[t].a;
      }
    }
  }
  bool SPFA(int s, int t) {
    for (auto &v : N) v.d = INF, v.inq = false;
    queue<int> q; q.push(s); N[s].inq = true;
    N[s].d = 0, N[s].p = -1, N[s].a = INF;
    while (q.size()) {
      int u = q.front(); q.pop(); N[u].inq = false;
      for (auto &e : N[u]) { int v = E[e].v;
        if (!E[e].c || N[v].d <= N[u].d + E[e].co)
          continue;
        N[v].d = N[u].d + E[e].co;
        N[v].p = e; N[v].a = min(N[u].a, E[e].c);
        if (!N[v].inq) q.push(v), N[v].inq = true;
      }
    }
    return N[t].d != INF;
  }
} solver;
// LatexEnd
int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    int n, k; cin >> n >> k;
    solver.init(1 + 2 * n + 1);
    for (int i = 0 ; i < n ; i++) {
        solver.addEdge(0, 1 + i, k, 0);
        solver.addEdge(1 + n + i, 1 + n + n, k, 0);
        solver.addEdge(1 + i, 1 + n + n, INF, 0);
    }
    for (int i = 0 ; i < n ; i++) {
        for (int j = 0 ; j < n ; j++) {
            LL v; cin >> v;
            solver.addEdge(1 + i, 1 + n + j, 1, -v);
        }
    }
    solver.run(0, 1 + n + n);
    cout << -solver.cost << '\n';
    auto E = solver.E;
    vector<vector<char>> G(n, vector<char>(n, '.'));
    for (int i = 0 ; i < (int)E.size() ; i += 2) {
        int u = E[i].u, v = E[i].v;
        if (u == 0 || v == 1 + n + n)
            continue;
        if (E[i].c) continue;
        u--, v--, v -= n;
        G[u][v] = 'X';
    }
    for (int i = 0 ; i < n ; i++) {
        for (int j = 0 ; j < n ; j++)
            cout << G[i][j];
        cout << '\n';
    }
}