#include <bits/stdc++.h>
using namespace std;
class TaskD {
 public:
  void solve(std::istream& in, std::ostream& out) {
    int n, k;
    in >> n >> k;
    out << (6 * n - 1) * k << endl;
    for (int i = 0; i < n; i++) {
      out << (6 * i + 1) * k << " " << (6 * i + 2) * k << " " << (6 * i + 3) * k
          << " " << (6 * i + 5) * k << endl;
    }
  }
};
int main() {
  TaskD solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}
