#include <bits/stdc++.h>
using namespace std;
template <typename T>
T sqr(T x) {
  return x * x;
}
template <typename T>
T abs(T x) {
  return x < 0 ? -x : x;
}
template <typename T>
T gcd(T a, T b) {
  return b ? gcd(b, a % b) : a;
}
int n, k;
int main() {
  ios_base ::sync_with_stdio(false);
  cin >> n >> k;
  cout << (6 * n - 1) * k << endl;
  for (int i = 0; i < n; i++) {
    cout << (6 * i + 1) * k << " " << (6 * i + 2) * k << " " << (6 * i + 3) * k
         << " ";
    cout << (6 * i + 5) * k << endl;
  }
}
