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
#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:2000000")
#pragma comment(linker, "/HEAP:2000000")
using namespace std;
void print_width(long long x) {
  std::cout << std::fixed;
  std::cout << std::setprecision(x);
}
long long power(long long x, long long y, long long p = 1000000007) {
  long long res = 1;
  x = x % p;
  while (y > 0) {
    if (y & 1) res = (res * x) % p;
    y = y >> 1;
    x = (x * x) % p;
  }
  return res;
}
void printArr(long long a[], long long n) {
  for (long long i = 0; i < n; i++) cout << a[i] << " ";
  cout << '\n';
}
void printVector(std::vector<long long> v) {
  for (long long i = 0; i < v.size(); i++) cout << v[i] << " ";
  cout << '\n';
}
void printVectorPair(std::vector<pair<long long, long long>> v) {
  for (long long i = 0; i < v.size(); i++)
    cout << v[i].first << " " << v[i].second << '\n';
  ;
  cout << '\n';
}
long long Min(long long a, long long b, long long c) {
  if (a < b and a < c) return a;
  if (b < c) return b;
  return c;
}
void initialize(long long arr[], long long n) {
  for (long long i = 0; i <= n; i++) arr[i] = i;
}
long long root(long long arr[], long long i) {
  while (arr[i] != i) {
    arr[i] = arr[arr[i]];
    i = arr[i];
  }
  return i;
}
void Union(long long arr[], long long a, long long b) {
  long long root_a = root(arr, a);
  long long root_b = root(arr, b);
  arr[root_a] = root_b;
}
long long gcd(long long a, long long b) {
  if (b == 0)
    return a;
  else
    return gcd(b, a % b);
}
long long power_wm(long long x, long long y) {
  long long res = 1;
  while (y > 0) {
    if (y & 1) res = (res * x);
    y = y >> 1;
    x = (x * x);
  }
  return res;
}
long double dpower(long double x, long long y) {
  long double res = 1;
  while (y > 0) {
    if (y & 1) res = (res * x);
    y = y >> 1;
    x = (x * x);
  }
  return res;
}
std::vector<long long> vsum(std::vector<long long> a) {
  std::vector<long long> s(a.size());
  s[0] = a[0];
  for (long long i = 1; i <= a.size() - 1; i++) {
    s[i] = s[i - 1] + a[i];
  }
  return s;
}
std::vector<long double> vsumld(std::vector<long double> a) {
  std::vector<long double> s(a.size());
  s[0] = a[0];
  for (long long i = 1; i <= a.size() - 1; i++) {
    s[i] = s[i - 1] + a[i];
  }
  return s;
}
bool comp(pair<long long, long long> a, pair<long long, long long> b) {
  long long x = a.second * b.first;
  long long y = a.first * b.second;
  if (x <= y)
    return false;
  else
    return true;
}
bool is_cap(char a) {
  if (a <= 'Z' and a >= 'A')
    return true;
  else
    return false;
}
bool is_small(char a) {
  if (a <= 'z' and a >= 'a')
    return true;
  else
    return false;
}
string addition(string str1, string str2) {
  string str = "";
  if (str1.size() > str2.size()) {
    swap(str1, str2);
  }
  int n1 = str1.size(), n2 = str2.size();
  reverse(str1.begin(), str1.end());
  reverse(str2.begin(), str2.end());
  int carry;
  carry = 0;
  for (int i = 0; i < n1; i++) {
    int sum;
    sum = ((str1[i] - '0') + (str2[i] - '0') + carry);
    str.push_back(sum % 10 + '0');
    carry = sum / 10;
  }
  for (int i = n1; i < n2; i++) {
    int sum;
    sum = ((str2[i] - '0') + carry);
    str.push_back(sum % 10 + '0');
    carry = sum / 10;
  }
  if (carry) str.push_back(carry + '0');
  reverse(str.begin(), str.end());
  return str;
}
bool mcomp(long long a, long long b, long long c, long long d) {
  if (a == b and b == c and c == d)
    return true;
  else
    return false;
}
long long modInverse(long long n, long long p) { return power(n, p - 2, p); }
long long nCr(long long n, long long r, long long p) {
  if (r == 0) return 1;
  long long fac[n + 1];
  fac[0] = 1;
  for (long long i = 1; i <= n; i++) fac[i] = fac[i - 1] * i % p;
  return (fac[n] * modInverse(fac[r], p) % p * modInverse(fac[n - r], p) % p) %
         p;
}
long long c2(long long n) { return (n * (n - 1)) / 2; }
void time() {}
string multiply(string num1, string num2) {
  int n1 = num1.size();
  int n2 = num2.size();
  if (n1 == 0 || n2 == 0) return "0";
  vector<int> result(n1 + n2, 0);
  int i_n1 = 0;
  int i_n2 = 0;
  for (int i = n1 - 1; i >= 0; i--) {
    int carry = 0;
    int n1 = num1[i] - '0';
    i_n2 = 0;
    for (int j = n2 - 1; j >= 0; j--) {
      int n2 = num2[j] - '0';
      int sum = n1 * n2 + result[i_n1 + i_n2] + carry;
      carry = sum / 10;
      result[i_n1 + i_n2] = sum % 10;
      i_n2++;
    }
    if (carry > 0) result[i_n1 + i_n2] += carry;
    i_n1++;
  }
  int i = result.size() - 1;
  while (i >= 0 && result[i] == 0) i--;
  if (i == -1) return "0";
  string s = "";
  while (i >= 0) s += std::to_string(result[i--]);
  return s;
}
long long sti(string s) {
  long long ans = 0;
  long long p = 1;
  for (long long i = s.size() - 1; i >= 0; i--) {
    ans = (ans + ((long long)(s[i] - '0') * p) % 998244353) % 998244353;
    p = (p * 10) % 998244353;
  }
  return ans;
}
int lps(char *seq, int i, int j) {
  if (i == j) return 1;
  if (seq[i] == seq[j] && i + 1 == j) return 2;
  if (seq[i] == seq[j]) return lps(seq, i + 1, j - 1) + 2;
  return max(lps(seq, i, j - 1), lps(seq, i + 1, j));
}
bitset<64> left_child(bitset<64> node) {
  for (long long i = 0; i < 64; i++) {
    if (node[i] == 1) {
      if (i == 0) break;
      node[i] = 0;
      node[i - 1] = 1;
      break;
    }
  }
  return node;
}
bitset<64> right_child(bitset<64> node) {
  for (long long i = 0; i < 64; i++) {
    if (node[i] == 1) {
      if (i == 0) break;
      node[i - 1] = 1;
      break;
    }
  }
  return node;
}
bitset<64> parent(bitset<64> node, bitset<64> root) {
  if (node == root) return node;
  for (long long i = 0; i < 64; i++) {
    if (node[i] == 1) {
      if (node[i + 1] == 0) {
        node[i + 1] = 1;
        node[i] = 0;
        break;
      } else if (node.count() > 1) {
        node[i] = 0;
        break;
      }
      break;
    }
  }
  return node;
}
auto seed = chrono::high_resolution_clock::now().time_since_epoch().count();
std::mt19937 mt(seed);
int myrand(int mo) { return mt() % mo; }
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  print_width(15);
  long long n, k;
  cin >> n >> k;
  long long mat[n][n];
  long long p = 1;
  for (long long i = 0; i <= n - 1; i++) {
    for (long long j = 0; j <= k - 2; j++) {
      mat[i][j] = p;
      p++;
    }
  }
  long long sum = 0;
  for (long long i = 0; i <= n - 1; i++) {
    for (long long j = k - 1; j <= n - 1; j++) {
      if (j == k - 1) sum += p;
      mat[i][j] = p;
      p++;
    }
  }
  cout << sum << '\n';
  ;
  for (long long i = 0; i <= n - 1; i++) {
    for (long long j = 0; j <= n - 1; j++) {
      cout << mat[i][j] << " ";
    }
    cout << '\n';
  }
  return 0;
}
