#include <bits/stdc++.h>
using namespace std;
const long long N = 100005;
const long long HS = 26;
int32_t main() {
  long long n, k;
  cin >> n >> k;
  cout << (6 * (n - 1) + 5) * k << endl;
  for (long long i = 0; i < n; i++) {
    cout << k * (6 * i + 1) << " " << k * (6 * i + 2) << " " << k * (6 * i + 3)
         << " " << k * (6 * i + 5) << endl;
  }
}
