#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k;
  cin >> n >> k;
  vector<vector<int> > T(n);
  int q = 1;
  for (int i(0); i < n; ++i) {
    T[i].push_back(q);
    T[i].push_back(q + 1);
    T[i].push_back(q + 2);
    T[i].push_back(q + 4);
    q += 6;
  }
  cout << k * T[T.size() - 1][3] << endl;
  for (int i(0); i < T.size(); ++i) {
    for (int j(0); j < 4; ++j) {
      cout << k * T[i][j] << " ";
    }
    cout << endl;
  }
  return 0;
}
