#include <bits/stdc++.h>
using namespace std;
long long power(long long b, long long e) {
  long long p = 1;
  while (e > 0) {
    if (e & 1) {
      p = (p * b) % 1000000007;
    }
    e = e >> 1;
    b = (b * b) % 1000000007;
  }
  return p;
}
int main() {
  long long n, m, k, i;
  scanf("%lld", &n);
  scanf("%lld", &k);
  printf("%lld\n", (6 * n - 1) * k);
  for (i = 0; i < n; i++) {
    printf("%lld ", k * (6 * i + 1));
    printf("%lld ", k * (6 * i + 2));
    printf("%lld ", k * (6 * i + 3));
    printf("%lld\n", k * (6 * i + 5));
  }
  return 0;
}
