#include <bits/stdc++.h>
using namespace std;
const int Len = 10005;
long long mm[Len][4];
void f() {
  long long k = 1;
  for (int i = 0; i < 10000; i++) {
    mm[i][0] = k++;
    mm[i][1] = k++;
    mm[i][2] = k++;
    mm[i][3] = ++k;
    k += 2;
  }
}
int main() {
  f();
  int n, m;
  cin >> n >> m;
  cout << mm[n - 1][3] * m << endl;
  for (int i = 0; i < n; i++) {
    cout << mm[i][0] * m << ' ' << mm[i][1] * m << " " << mm[i][2] * m << " ";
    cout << mm[i][3] * m << endl;
  }
  return 0;
}
