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:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;

import java.util.*;


public class Soly
{
    static ArrayList<Integer>[] adjList;
    static boolean[] visited;
    static  int[] dis,par;
    static int V;

    static int h(int []a,int v){
        int s=0,e=a.length-1,ans=-1,mid=0;
        while (s<=e){
            mid=(s+e)>>1;
            if (a[mid]>=v){
                ans=mid;
                e=mid-1;
            }else s=mid+1;
        }
        return ans;
    }
    static void bfs(int s)
    {
        Queue<Integer> q = new LinkedList<Integer>();
        q.add(s);
        visited[s] = true;
        //dis[s]=0;
        par[s]=0;
        while(!q.isEmpty())
        {
            int u = q.remove();

            for(int v: adjList[u])
                if(!visited[v])
                {
                    visited[v] = true;
                    //dis[v]=dis[u]+1;
                    par[v]=u;
                    q.add(v);
                }
        }
    }
    static final int INF = Integer.MAX_VALUE;

    static void mergeSort(int[] a,int [] c, int b, int e)
    {
        if(b < e)
        {
            int q = (b + e) >>1;
            mergeSort(a,c, b, q);
            mergeSort(a, c,q + 1, e);
            merge(a,c, b, q, e);
        }
    }


    static void merge(int[] a,int[]c, int b, int mid, int e)
    {
        int n1 = mid - b + 1;
        int n2 = e - mid;
        int[] L = new int[n1+1], R = new int[n2+1];
        int[] L1 = new int[n1+1], R1 = new int[n2+1];

        for(int i = 0; i < n1; i++) {
            L[i] = a[b + i];
            L1[i] = c[b + i];
        }
        for(int i = 0; i < n2; i++)  {
            R[i] = a[mid + 1 + i];
            R1[i] = c[mid + 1 + i];
        }
        L[n1] = R[n2] = INF;

        for(int k = b, i = 0, j = 0; k <= e; k++)
            if(L[i] <= R[j]){
                a[k] = L[i];
                c[k] = L1[i++];
            }

            else
            {
                a[k] = R[j];
                c[k] = R1[j++];
            }
    }

    public static void main(String[] args) throws IOException {
        Scanner in = new Scanner(System.in);
        try (PrintWriter or = new PrintWriter(System.out)) {
                  int n = in.nextInt(),k=in.nextInt()-1;
                  int[][] ans= new int[n][n];
                  long sum=0;
                  int p=1;
                  boolean [] a = new boolean[n*n+1];

                  ans[0][k]=n*n-((n-k-1));

                  sum+=ans[0][k];
            for (int i = 1; i <n; i++) {
                ans[i][k]=ans[i-1][k]-(n-k);
                a[ans[i][k]]=true;
                sum+=ans[i][k];
            }
                  a[n*n-((n-k))]=true;
            for (int i = 0; i < n; i++,p++) {
                for (int j = k+1; j <n ; j++) {
                   ans[i][j]=ans[i][j-1]+1;

                    a[ans[i][j]]=true;
                }
            }

            ArrayList<Integer> y= new ArrayList<>();
            for (int i = 1; i < a.length; i++) {
                if (!a[i])y.add(i);
            }
            int u=0;
            for (int i = 0; i < n; i++) {
                for (int j = 0; j < n; j++) {
                    if (ans[i][j]==0)if(u<y.size())ans[i][j]=y.get(u++);
                }
            }
            or.println(sum);

            for (int i = 0; i < n; i++) {
                for (int j = 0; j < n; j++) {
                    or.print(ans[i][j]+" ");
                }or.println();
            }







        }




    }
    static class Scanner {

        StringTokenizer st;
        BufferedReader br;

        public Scanner(InputStream s) {
            br = new BufferedReader(new InputStreamReader(s));
        }

        public String next() throws IOException {
            while (st == null || !st.hasMoreTokens()) {
                st = new StringTokenizer(br.readLine());
            }
            return st.nextToken();
        }

        public int nextInt() throws IOException {
            return Integer.parseInt(next());
        }

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

        public String nextLine() throws IOException {
            return br.readLine();
        }

        public double nextDouble() throws IOException {
            String x = next();
            StringBuilder sb = new StringBuilder("0");
            double res = 0, f = 1;
            boolean dec = false, neg = false;
            int start = 0;
            if (x.charAt(0) == '-') {
                neg = true;
                start++;
            }
            for (int i = start; i < x.length(); i++) {
                if (x.charAt(i) == '.') {
                    res = Long.parseLong(sb.toString());
                    sb = new StringBuilder("0");
                    dec = true;
                } else {
                    sb.append(x.charAt(i));
                    if (dec) {
                        f *= 10;
                    }
                }
            }
            res += Long.parseLong(sb.toString()) / f;
            return res * (neg ? -1 : 1);
        }

        public boolean ready() throws IOException {
            return br.ready();
        }

    }



}
class coooo implements Comparable<coooo>{
    int index;
    String s;


    public coooo(String string, int index) {
        this.s = string;
        this.index = index;
    }

    @Override
    public int compareTo(coooo o) {
        if (this.s.length()==o.s.length())
            return (this.s+o).compareTo(o+this.s);
        return this.s.length()-o.s.length();
    }
}