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