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