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