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