#include <bits/stdc++.h>
using namespace std;
vector<vector<int> > ans;
void gen(int n) {
  for (int e = 0; e < n; e++)
    ans.push_back({6 * e + 1, 6 * e + 2, 6 * e + 3, 6 * e + 5});
}
int main() {
  int n, k;
  cin >> n >> k;
  cout << k * (6 * n - 1) << endl;
  gen(n);
  for (auto &it : ans)
    for (int e = 0; e < 4; e++) cout << k * it[e] << " \n"[e == 3];
  return 0;
}
