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