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