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