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