#include <bits/stdc++.h>
using namespace std;
const int INF = 1 << 29;
double tick() {
  static clock_t oldticks;
  clock_t newticks = clock();
  double diff = 1.0 * (newticks - oldticks) / CLOCKS_PER_SEC;
  oldticks = newticks;
  return diff;
}
int n, k;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n >> k;
  cout << (6 * n - 1) * k << 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;
}
