#include <bits/stdc++.h>
using namespace std;
int n, k;
void readln(int &I) {
  char C = getchar();
  I = 0;
  while (!isdigit(C)) C = getchar();
  while (isdigit(C)) I = I * 10 + C - '0', C = getchar();
}
int main() {
  readln(n), readln(k), printf("%d\n", k * (n * 6 - 1));
  for (register int i = 1; i <= n; i++)
    printf("%d %d %d %d\n", (6 * i - 5) * k, (6 * i - 4) * k, (6 * i - 3) * k,
           (6 * i - 1) * k);
}
