#include <bits/stdc++.h>
using namespace std;
int main(int argc, const char **argv) {
  if (argc >= 2) {
    freopen(argv[1], "r", stdin);
  }
  int n, k;
  cin >> n >> k;
  cout << (6 * (n - 1) + 5) * k << endl;
  int a[] = {1, 2, 3, 5};
  for (int i = 0; i < n; i++) {
    for (auto v : a) {
      cout << (6 * i + v) * k << " ";
    }
    cout << endl;
  }
}
