#include <bits/stdc++.h>
using namespace std;
int const maxn = 1e5 + 10;
int main(void) {
  long long n, k;
  cin >> n >> k;
  int s = 1;
  cout << (6LL * (n)-1) * k << endl;
  for (int i = 1; i <= n; i++) {
    printf("%lld %lld %lld %lld\n", s * k, (s + 1) * k, (s + 2) * k,
           (s + 4) * k);
    s += 6;
  }
  return 0;
}
