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