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