#include <bits/stdc++.h>
int main() {
  int n, k;
  std::cin >> n >> k;
  std::cout << k * (6 * n - 1) << std::endl;
  for (int i = 1; i <= n; i++) {
    std::cout << ((6 * i - 4) * k) << " " << (k * (6 * i - 5)) << " "
              << (k * (6 * i - 3)) << " " << (k * (6 * i - 1)) << std::endl;
  }
}
