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