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