#include <bits/stdc++.h>
using namespace std;
void open() {
  freopen("sets.in", "r", stdin);
  freopen("sets.out", "w", stdout);
}
class diary {
 public:
  int n, m, k;
  void work() {
    cin >> n >> k;
    aliez();
  }

 private:
  void aliez() {
    printf("%d\n", (n * 6 - 1) * k);
    for (int i = 1; i <= n; ++i)
      printf("%d %d %d %d\n", ((i - 1) * 6 + 1) * k, ((i - 1) * 6 + 2) * k,
             ((i - 1) * 6 + 3) * k, ((i - 1) * 6 + 5) * k);
  }
} gasai;
int main() {
  gasai.work();
  return 0;
}
