People do many crazy things to stand out in a crowd. Some of them dance, some learn by heart rules of Russian language, some try to become an outstanding competitive programmers, while others collect funny math objects.

Alis is among these collectors. Right now she wants to get one of k-special tables. In case you forget, the table n × n is called k-special if the following three conditions are satisfied:

  * every integer from 1 to n2 appears in the table exactly once; 
  * in each row numbers are situated in increasing order; 
  * the sum of numbers in the k-th column is maximum possible. 



Your goal is to help Alice and find at least one k-special table of size n × n. Both rows and columns are numbered from 1 to n, with rows numbered from top to bottom and columns numbered from left to right.

Input

The first line of the input contains two integers n and k (1 ≤ n ≤ 500, 1 ≤ k ≤ n) — the size of the table Alice is looking for and the column that should have maximum possible sum.

Output

First print the sum of the integers in the k-th column of the required table.

Next n lines should contain the description of the table itself: first line should contains n elements of the first row, second line should contain n elements of the second row and so on.

If there are multiple suitable table, you are allowed to print any.

Examples

Input

4 1


Output

28
1 2 3 4
5 6 7 8
9 10 11 12
13 14 15 16


Input

5 3


Output

85
5 6 17 18 19
9 10 23 24 25
7 8 20 21 22
3 4 14 15 16
1 2 11 12 13


import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.io.Writer;
import java.lang.reflect.Array;
import java.util.InputMismatchException;
import java.util.Scanner;

/**
 *
 * @author DANIYAR
 */
public class Main {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here
        InputStream inputStream = System.in;
	OutputStream outputStream = System.out;
	InputReader in = new InputReader(inputStream);
	OutputWriter out = new OutputWriter(outputStream);
	TaskB solver = new TaskB();
	solver.solve(1, in, out);
	out.close();
	
    }
    static class TaskB {
        private void solve(int TestNumber, InputReader in, OutputWriter out) {
            int n = in.readInt();
            int k = in.readInt();
            int[][] a = new int[501][501];
            int result = 0,i=0,j, x = n*n,t = n-k;
            result = x - t;
            x-=t;
            t++;
            i = 1;
            while (i < n) {
                x -= t;
                result+=x;
                ++i;
            }
            out.printnl();
            x = 0;
            for (i = n; i >= 1; --i)
            for (j = 1; j < k; ++j)
                a[i][j] = ++x;
            for (i = 1; i <= n; ++i)
            for (j = k; j <= n; ++j)
                a[i][j] = ++x;
            out.print(result);
            out.printnl();
            for (i = 1; i <= n; ++i) {
            for (j = 1; j <= n; ++j){
                out.print(a[i][j]);
                out.printspace();
            }
                out.printnl();
            }
        out.close();
            
        }
        
        
    } 
    
    static class OutputWriter {
		private final PrintWriter writer;

		public OutputWriter(OutputStream outputStream) {
			writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream)));
		}

		public OutputWriter(Writer writer) {
			this.writer = new PrintWriter(writer);
		}

		public void close() {
			writer.close();
		}

		public void print(long i) {
			writer.print(i);
		}
                public void printspace() {
                    writer.print(' ');
                }
                public void printnl() {
                    writer.print('\n');
                }
                
        
	}

	static class InputReader {
		private InputStream stream;
		private byte[] buf = new byte[1024];
		private int curChar;
		private int numChars;
		private SpaceCharFilter filter;

		public InputReader(InputStream stream) {
			this.stream = stream;
		}

		public int read() {
			if (numChars == -1)
				throw new InputMismatchException();
			if (curChar >= numChars) {
				curChar = 0;
				try {
					numChars = stream.read(buf);
				} catch (IOException e) {
					throw new InputMismatchException();
				}
				if (numChars <= 0)
					return -1;
			}
			return buf[curChar++];
		}

		public int readInt() {
			int c = read();
			while (isSpaceChar(c))
				c = read();
			int sgn = 1;
			if (c == '-') {
				sgn = -1;
				c = read();
			}
			int res = 0;
			do {
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res *= 10;
				res += c - '0';
				c = read();
			} while (!isSpaceChar(c));
			return res * sgn;
		}

		public boolean isSpaceChar(int c) {
			if (filter != null)
				return filter.isSpaceChar(c);
			return isWhitespace(c);
		}

		public static boolean isWhitespace(int c) {
			return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
		}

		public interface SpaceCharFilter {
			public boolean isSpaceChar(int ch);

		}

	}
    
}
