You are given an array consisting of n integers a_1, a_2, ..., a_n, and a positive integer m. It is guaranteed that m is a divisor of n.

In a single move, you can choose any position i between 1 and n and increase a_i by 1.

Let's calculate c_r (0 ≤ r ≤ m-1) — the number of elements having remainder r when divided by m. In other words, for each remainder, let's find the number of corresponding elements in a with that remainder.

Your task is to change the array in such a way that c_0 = c_1 = ... = c_{m-1} = n/m.

Find the minimum number of moves to satisfy the above requirement.

Input

The first line of input contains two integers n and m (1 ≤ n ≤ 2 ⋅ 10^5, 1 ≤ m ≤ n). It is guaranteed that m is a divisor of n.

The second line of input contains n integers a_1, a_2, ..., a_n (0 ≤ a_i ≤ 10^9), the elements of the array.

Output

In the first line, print a single integer — the minimum number of moves required to satisfy the following condition: for each remainder from 0 to m - 1, the number of elements of the array having this remainder equals n/m.

In the second line, print any array satisfying the condition and can be obtained from the given array with the minimum number of moves. The values of the elements of the resulting array must not exceed 10^{18}.

Examples

Input

6 3
3 2 0 6 10 12


Output

3
3 2 0 7 10 14 


Input

4 2
0 1 2 3


Output

0
0 1 2 3 
import org.omg.CORBA.INTERNAL;

import java.io.*;
import java.lang.reflect.Array;
import java.util.*;

/*
9 5
8 1 3 6 4 2 9 7 5
4 9 7 1 2 3 6 5 8
index:1 5 2 4 8 3 7 0 6
power:1 2 3 4 5 6 7 8 9
coins:9 3 7 2 8 1 5 4 6

30 5
3 0 4 3 1 3 2 4 1 2 3 1 0 3 0 4 0 1 1 3 1 0 3 1 1 3 4 3 3 4
*/
public class CodeForces {
    static class Side{
        int x;
        int y;
    }
    static class Graph{
        int vertices;
        boolean directed;
        ArrayList<ArrayList<Integer>> list;
        Graph(int vertices){
            this.vertices=vertices;
            this.directed=false;
            list=new ArrayList<>();
            for(int i=0;i<vertices;i++){
                list.add(new ArrayList<>());
            }
        }
        Graph(int vertices,boolean directed){
            this.vertices=vertices;
            this.directed=directed;
            list=new ArrayList<>();
            for(int i=0;i<vertices;i++){
                list.add(new ArrayList<>());
            }
        }
        void addEge(int u,int v){
            list.get(u).add(v);
            if(!directed){
                list.get(v).add(u);
            }
        }
        Node DFS(int v,Node node)
        {
            if(node.visited[v]){
                return node;
            }
            // Mark the current node as visited and print it
            node.visited[v] = true;
            node.count++;

            // Recur for all the vertices adjacent to this vertex
            Iterator<Integer> i = list.get(v).listIterator();
            while (i.hasNext())
            {
                int n = i.next();
                if (!node.visited[n])
                    DFS(n,node);
            }
            return node;
        }
    }
    public static void reverse(char[] arr,int n){
        for(int i=0,j=n-1;i<j;i++,j--){
            char temp=arr[i];
            arr[i]=arr[j];
            arr[j]=temp;
        }

    }
    static class Node{
        boolean[] visited;
        int count=0;
        Node(int n){
            visited=new boolean[n];
        }
    }
    static class Nod{
        int value;
        int timing;
        int modulus;
        Nod(int value,int timing,int modulus){
            this.value=value;
            this.timing=timing;
            this.modulus=modulus;
        }
    }
    public static void main(String[] args) {
        FastReader s=new FastReader(System.in);
        int n = s.nextInt();
        int m = s.nextInt();
        int[] arr = new int[n];
        for(int i=0;i<n;i++){
            arr[i]=s.nextInt();
        }
        ArrayList<LinkedList<Integer>> modulus = new ArrayList<>();
        for (int i = 0; i < m; i++) {
            modulus.add(new LinkedList<>());
        }
        for (int i = 0; i < n; i++) {
            modulus.get(arr[i] % m).add(i);
        }
        int nm = n / m;
        long action = 0;
        int missingIndex = 0;
        int dist = 0;
        for (int i = 0; i < m; i++) {
            if (missingIndex == i) {
                missingIndex = (missingIndex + 1) % m;
                dist++;
            }
            while (modulus.get(i).size() > nm) {
                int x = modulus.get(i).poll();
                while (modulus.get(missingIndex).size() >= nm) {
                    missingIndex = (missingIndex + 1) % m;
                    dist++;
                }
                arr[x] += dist;
                action += dist;
                modulus.get(missingIndex).add(x);
            }
            dist--;
        }
        System.out.println(action);
        for (int i = 0; i < n; i++) {
            System.out.print(arr[i] + " ");
        }
        System.out.println();


//        int n=s.nextInt();
//        int m=s.nextInt();
//        int index=s.nextInt()-1;
//        Graph graph=new Graph(n,true);
//        for(int i=0;i<m;i++){
//            graph.addEge(s.nextInt()-1,s.nextInt()-1);
//        }
//        Node node=new Node(n);
//        graph.DFS(index,node);
//        int count=0;
//        for(int i=0;i<n;i++){
//            if(!node.visited[i]) {
//                graph.addEge(index,i);
//                graph.DFS(i, node);
//                count++;
//            }
//        }
//        System.out.println(count);


    }
    static class FastReader {
        InputStream is;
        private byte[] inbuf = new byte[1024];
        private int lenbuf = 0, ptrbuf = 0;
        static final int ints[] = new int[128];

        public FastReader(InputStream is) {
            for (int i = '0'; i <= '9'; i++) ints[i] = i - '0';
            this.is = is;
        }

        public int readByte() {
            if (lenbuf == -1) throw new InputMismatchException();
            if (ptrbuf >= lenbuf) {
                ptrbuf = 0;
                try {
                    lenbuf = is.read(inbuf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (lenbuf <= 0) return -1;
            }
            return inbuf[ptrbuf++];
        }

        public boolean isSpaceChar(int c) {
            return !(c >= 33 && c <= 126);
        }

        public int skip() {
            int b;
            while ((b = readByte()) != -1 && isSpaceChar(b)) ;
            return b;
        }

        public String next() {
            int b = skip();
            StringBuilder sb = new StringBuilder();
            while (!(isSpaceChar(b))) { // when nextLine, (isSpaceChar(b) && b != ' ')
                sb.appendCodePoint(b);
                b = readByte();
            }
            return sb.toString();
        }

        public int nextInt() {
            int num = 0, b;
            boolean minus = false;
            while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-')) ;
            if (b == '-') {
                minus = true;
                b = readByte();
            }

            while (true) {
                if (b >= '0' && b <= '9') {
                    num = (num << 3) + (num << 1) + ints[b];
                } else {
                    return minus ? -num : num;
                }
                b = readByte();
            }
        }

        public long nextLong() {
            long num = 0;
            int b;
            boolean minus = false;
            while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-')) ;
            if (b == '-') {
                minus = true;
                b = readByte();
            }

            while (true) {
                if (b >= '0' && b <= '9') {
                    num = (num << 3) + (num << 1) + ints[b];
                } else {
                    return minus ? -num : num;
                }
                b = readByte();
            }
        }

        public double nextDouble() {
            return Double.parseDouble(next());
        }
       /* public char nextChar() {
            return (char)skip();
        }*/

        public char[] next(int n) {
            char[] buf = new char[n];
            int b = skip(), p = 0;
            while (p < n && !(isSpaceChar(b))) {
                buf[p++] = (char) b;
                b = readByte();
            }
            return n == p ? buf : Arrays.copyOf(buf, p);
        }

        /*private char buff[] = new char[1005];
        public char[] nextCharArray(){
            int b = skip(), p = 0;
            while(!(isSpaceChar(b))){
                buff[p++] = (char)b;
                b = readByte();
            }
            return Arrays.copyOf(buff, p);
        }*/
    }
}
//
//    Side[] square1=new Side[4];
//    Side[] square2=new Side[4];
//        for(int i=0;i<4;i++){
//        square1[i]=new Side();
//        square1[i].x=s.nextInt();
//        square1[i].y=s.nextInt();
//        }
//        for(int i=0;i<4;i++){
//        square2[i]=new Side();
//        square2[i].x=s.nextInt();
//        square2[i].y=s.nextInt();
//        }
//        Arrays.sort(square1, new Comparator<Side>() {
//@Override
//public int compare(Side o1, Side o2) {
//        return o1.x-o2.x;
//        }
//        });
//        Arrays.sort(square2, new Comparator<Side>() {
//@Override
//public int compare(Side o1, Side o2) {
//        return o1.x-o2.x;
//        }
//        });
//        double midX1=(square1[0].x+square1[2].x)/2.0;
//        double midY1=(square1[0].y+square1[2].y)/2.0;
//
//        double midX2=(square2[0].x+square2[2].x)/2.0;
//        double midY2=(square2[0].y+square2[2].y)/2.0;

