Problem: 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

Solution (in JAVA):

Solution:
/*
12 * Remember a 6.0 student can know more than a 10.0 student.
 * Grades don't determine intelligence, they test obedience. 
 * I Never Give Up.
 * I will become Candidate Master.
 * I will defeat Saurabh Anand.
 * Skills are Cheap,Passion is Priceless.
 */
import java.util.*;
import java.util.Map.Entry;
import java.io.*;

import static java.lang.System.out;
import static java.util.Arrays.*;
import static java.lang.Math.*;

public class ContestMain{
	private static Reader in=new Reader();
	private static StringBuilder ans=new StringBuilder();
	private static long MOD=1000000000+7;// 1e9+7
	private static final int N=1000000+7; 
//    private static final double EPS=1e-9;
//    private static final int LIM=26;
//    private static final double PI=3.1415;
    private static ArrayList<Integer> v[]=new ArrayList[N];
//    private static int color[]=new int[N];
	  private static boolean mark[]=new boolean[N];
//    private static BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
//    private static ArrayList<Pair> v[]=new ArrayList[N];
	private static long powmod(long x,long n){
		if(n==0||x==0)
			return 1;
		else if(n%2==0)
			return(powmod((x*x)%MOD,n/2));
		else
			return (x*(powmod((x*x)%MOD,(n-1)/2)))%MOD;
	}

	private static void shuffle(long[] arr){
		for(int i=arr.length-1;i>=2;i--){
			int x=new Random().nextInt(i-1);
			long temp=arr[x];
			arr[x]=arr[i];
			arr[i]=temp;
		}
	}

    private static long gcd(long a, long b){
        if(b==0)return a;
        return gcd(b,a%b);
    }
//    private static boolean check(int x,int y){
//        if((x>=0&&x<n)&&(y>=0&&y<m)&&mat[x][y]!='X'&&!visited[x][y])return true;
//        return false;
//    }
	public static void main(String[] args) throws IOException{
		int n=in.nextInt();
		int k=in.nextInt();
		TreeSet<Integer> set=new TreeSet();
		for(int i=1;i<=n*n;i++)
			set.add(i);
		int matrix[][]=new int[n][n];
		int row=n-1,cnt=0;
		int col=n-1;
		for(int i=n*n;i>=1;i--){
			if(row==-1)break;
			matrix[row][col]=i;
			cnt++;
			col--;
			set.remove(i);
			if(cnt>n-k){
				row--;
				col=n-1;
				cnt=0;
			}
		}
		int remain[]=new int[set.size()];
		int ind=0;
		for(int a:set){
			remain[ind++]=a;
		}
		ind=0;
		for(int i=0;i<n;i++){
			for(int j=0;j<n;j++){
				if(matrix[i][j]==0){
					matrix[i][j]=remain[ind++];
				}
			}
		}
		long total=0;
		for(int i=0;i<n;i++){
			for(int j=0;j<n;j++){
				if(j==k-1)total+=matrix[i][j];
				ans.append(matrix[i][j]+" ");
			}
			ans.append("\n");
		}
		out.println(total+"\n"+ans);
	}
	static class Pair<T> implements Comparable<Pair>{
		long l;
		long r;

		Pair(){
			l=0;
			r=0;
		}

		Pair(long k,long v){
			l=k;
			r=v;
		}

		@Override
		public int compareTo(Pair o){
			if(o.l!=l)
				return (int)-(l-o.l);
			else
				return (int)(r-o.r);
		}
		// Fenwick tree question comparator
//        @Override
//        public int compareTo(Pair o) {
//            if(o.r!=r)return (int) (r-o.r);
//            else return (int)(l-o.l);
//        }
	}

	static class Reader{
		BufferedReader br;
		StringTokenizer st;

		public Reader(){
			br=new BufferedReader(new InputStreamReader(System.in));
		}

		String next(){
			while(st==null||!st.hasMoreElements()){
				try{

					st=new StringTokenizer(br.readLine());
				}catch(IOException e){
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}
		
		int nextInt(){
			return Integer.parseInt(next());
		}

		long nextLong(){
			return Long.parseLong(next());
		}

		double nextDouble(){
			return Double.parseDouble(next());
		}

		String nextLine(){
			String str="";
			try{
				str=br.readLine();
			}catch(IOException e){
				e.printStackTrace();
			}
			return str;
		}
	}
}