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