#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1E6 + 10;
int a[MAXN];
struct range {
  int bg, ed, step;
  range(int a, int b, int c) {
    bg = a;
    ed = b;
    step = c;
  }
  int next() { bg += step; }
  int end() { return bg > ed; }
  int now() { return bg; }
};
int getAns(long long n, long long k) {
  printf("%lld\n", (6 * n - 1) * k);
  for (long long i = 1; i <= n; ++i) {
    printf("%lld %lld %lld %lld\n", (6 * i - 5) * k, (6 * i - 4) * k,
           (6 * i - 3) * k, (6 * i - 1) * k);
  }
  return 0;
}
int main() {
  int n;
  int k;
  scanf("%d%d", &n, &k);
  getAns(n, k);
  return 0;
}
