#include <bits/stdc++.h>
using namespace std;
void fastStream() {
  cin.tie(0);
  std::ios_base::sync_with_stdio(0);
}
int N, K;
int main() {
  fastStream();
  cin >> N >> K;
  cout << ((N - 1) * 6 + 5) * K << 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) << endl;
  }
  return 0;
}
