#include <bits/stdc++.h>
using namespace std;
inline long long read() {
  char c = getchar();
  long long x = 0, f = 1;
  while (c < '0' || c > '9') {
    if (c == '-') f = -1;
    c = getchar();
  }
  while (c >= '0' && c <= '9') {
    x = x * 10 + c - '0';
    c = getchar();
  }
  return x * f;
}
long long n, k;
int main() {
  n = read();
  k = read();
  printf("%lld\n", ((n - 1) * 6 + 5) * k);
  for (int i = 0; i < n; ++i)
    printf("%lld %lld %lld %lld\n", k * (6 * i + 1), k * (6 * i + 2),
           k * (6 * i + 3), k * (6 * i + 5));
  return 0;
}
