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 
//package math_codet;
//My best Codeforces problem which I thought was DP and left it during the contest ... shittt
import java.io.*;
import java.util.*;

public class lets_do {
    public static void main(String[] args)
    {
        InputReader in=new InputReader(System.in);
        StringBuffer str=new StringBuffer();
        int n=in.nextInt();
        int m=in.nextInt();
        int[] arr=new int[n];
        int[] count=new int[m];
        int i=0;
        int target=n/m;
        TreeMap<Integer,Integer> extra=new TreeMap<Integer,Integer>();
        TreeMap<Integer,Integer> less=new TreeMap<Integer,Integer>();
        TreeMap<Integer,Integer> less1=new TreeMap<Integer,Integer>();
        PriorityQueue<Integer> pq[]=new PriorityQueue[m];
        for(i=0;i<m;i++)
            pq[i]=new PriorityQueue<Integer>();
        for(i=0;i<n;i++){
            arr[i]=in.nextInt();
            if(count[arr[i]%m] == target){
            	Integer c=extra.get(arr[i]%m);
                if(!(c==null)){
                    int cnt=c;
                    c++;
                    extra.put(arr[i]%m,c);
                    pq[arr[i]%m].add(i);
                }
                else {
                    extra.put(arr[i]%m,1);
                    pq[arr[i]%m].add(i);
                }
            }
            else
                count[arr[i]%m]++;
        }
        for(i=0;i<m;i++){
            if(count[i]!=target) {
                less.put(i,target-count[i]);
                less1.put(i,target-count[i]);
            }
        }
        for(Map.Entry<Integer,Integer> entry : extra.entrySet()){
        	int x=entry.getKey();
            int y=entry.getValue();
        }
        long ans=0;
        for(Map.Entry<Integer,Integer> entry : less.entrySet()){
            int x=entry.getKey();
            int y=entry.getValue();
            for(i=0;i<y;i++){
                if(extra.lowerKey(x)==null)
                    break;
                else{
                    Integer id=(int)extra.lowerKey(x);
                    int cnt1=extra.get(id);
                    Integer ind1=pq[(int)id].poll();
                    if(ind1!=null) {
                    	arr[(int)ind1]+=x-id;
                    	ans+=x-id;
                    	if(cnt1==1)
                    		extra.remove(id);
                    	else
                    		extra.put(id,cnt1-1);
                    }
                    else
                    	break;
                }
            }
            if(i==y)
                less1.remove(x);
            else
                less1.put(x,y-i);
        }
        for(Map.Entry<Integer,Integer> entry : less1.entrySet()){
            int x=entry.getKey();
            int y=entry.getValue();
            for(i=0;i<y;i++){
                if(extra.lowerKey(m)==null)
                    break;
                else{
                	Integer id=(int)extra.lowerKey(m);
                    int cnt1=extra.get(id);
                    Integer ind1=pq[(int)id].poll();
                    if(ind1!=null) {
                    	arr[(int)ind1]+=m-id+x;
                    	ans+=m-id+x;
                    	if(cnt1==1)
                    		extra.remove(id);
                    	else
                    		extra.put(id,cnt1-1);
                    }
                    else
                    	break;
                }
            }
        }
        System.out.println(ans);
        for(i=0;i<n;i++)
            System.out.print(arr[i]+" ");
    }
    static class InputReader{
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
 
        public InputReader(InputStream stream) {
            this.stream = stream;
        }
 
        public int read() {
            if (numChars == -1)
                throw new UnknownError();
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new UnknownError();
                }
                if (numChars <= 0)
                    return -1;
            }
            return buf[curChar++];
        }
 
        public int peek() {
            if (numChars == -1)
                return -1;
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    return -1;
                }
                if (numChars <= 0)
                    return -1;
            }
            return buf[curChar];
        }
 
        public void skip(int x) {
            while (x-- > 0)
                read();
        }
 
        public int nextInt() {
            return Integer.parseInt(next());
        }
 
        public long nextLong() {
            return Long.parseLong(next());
        }
 
        public String nextString() {
            return next();
        }
 
        public String next() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            StringBuffer res = new StringBuffer();
            do {
                res.appendCodePoint(c);
                c = read();
            } while (!isSpaceChar(c));
 
            return res.toString();
        }
 
        public String nextLine() {
            StringBuffer buf = new StringBuffer();
            int c = read();
            while (c != '\n' && c != -1) {
                if (c != '\r')
                    buf.appendCodePoint(c);
                c = read();
            }
            return buf.toString();
        }
 
        public double nextDouble() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            double res = 0;
            while (!isSpaceChar(c) && c != '.') {
                if (c == 'e' || c == 'E')
                    return res * Math.pow(10, nextInt());
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = read();
            }
            if (c == '.') {
                c = read();
                double m = 1;
                while (!isSpaceChar(c)) {
                    if (c == 'e' || c == 'E')
                        return res * Math.pow(10, nextInt());
                    if (c < '0' || c > '9')
                        throw new InputMismatchException();
                    m /= 10;
                    res += (c - '0') * m;
                    c = read();
                }
            }
            return res * sgn;
        }
 
        public boolean hasNext() {
            int value;
            while (isSpaceChar(value = peek()) && value != -1)
                read();
            return value != -1;
        }
 
        private boolean isSpaceChar(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }
    }
} 