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