#include <bits/stdc++.h>
using namespace std;
int n, k;
int read() {
  int X = 0, F = 1;
  char C = getchar();
  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;
}
int main() {
  n = read();
  k = read();
  printf("%d\n", (6 * n - 1) * k);
  for (int i = 1; i <= n; i = -~i)
    printf("%d %d %d %d\n", ((i - 1) * 6 + 1) * k, ((i - 1) * 6 + 2) * k,
           ((i - 1) * 6 + 3) * k, ((i - 1) * 6 + 5) * k);
  return 0;
}
