#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 100;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n, k;
  cin >> n >> k;
  cout << k * (6 * (n - 1) + 5) << endl;
  for (int i = 0; i < n; i++) {
    cout << k * (6 * i + 1) << " " << k * (6 * i + 2) << " " << k * (6 * i + 3)
         << " " << k * (6 * i + 5) << "\n";
  }
  return 0;
}
