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