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