#include <bits/stdc++.h>
using namespace std;
struct data {
  int a, b, c, d;
  data() {}
  data(int a, int b, int c, int d) : a(a), b(b), c(c), d(d) {}
};
const int MAX = 100500;
data info[MAX];
int main() {
  std::ios_base::sync_with_stdio(false);
  int n, k;
  cin >> n >> k;
  info[0] = data(1, 2, 3, 5);
  int mx;
  for (int i = 1; i < n; i++) {
    info[i] = data(info[i - 1].a + 6, info[i - 1].b + 6, info[i - 1].c + 6,
                   info[i - 1].d + 6);
  }
  mx = info[n - 1].d * k;
  cout << mx << "\n";
  for (int i = 0; i < n; i++) {
    cout << info[i].a * k << " " << info[i].b * k << " " << info[i].c * k << " "
         << info[i].d * k << "\n";
  }
  return 0;
}
