#include <bits/stdc++.h>
using namespace std;
int sgn(double x) { return (x > 1e-8) - (x < -1e-8); }
int count_bit(int x) { return x == 0 ? 0 : count_bit(x >> 1) + (x & 1); }
template <class T>
inline void ckmin(T &a, const T b) {
  if (b < a) a = b;
}
template <class T>
inline void ckmax(T &a, const T b) {
  if (b > a) a = b;
}
int main() {
  int n, k;
  while (scanf("%d%d", &n, &k) != EOF) {
    printf("%d\n", k * (6 * (n - 1) + 5));
    for (int 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;
}
