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