#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, K;
  cin >> N >> K;
  cout << (6 * N - 1) * K << "\n";
  for (int i = 0; i < N; ++i) {
    int b = 6 * i;
    cout << (b + 1) * K << " " << (b + 2) * K << " " << (b + 3) * K << " "
         << (b + 5) * K << "\n";
  }
  return 0;
}
