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