#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k;
  while (~scanf("%d%d", &n, &k)) {
    printf("%d\n", (6 * n - 1) * k);
    for (int i = 1; i <= n; i++) {
      printf("%d ", (6 * i - 5) * k);
      printf("%d ", (6 * i - 4) * k);
      printf("%d ", (6 * i - 3) * k);
      printf("%d\n", (6 * i - 1) * k);
    }
  }
  return 0;
}
