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