#include <bits/stdc++.h>
using namespace std;
int main() {
  int i, n, k, m;
  scanf("%d%d", &n, &k);
  m = (6 * n - 1) * k;
  printf("%d\n", m);
  for (i = 0; i < n; 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;
}
