#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, k, i, j, ans;
  cin >> n >> k;
  printf("%lld\n", (6 * n - 1) * k);
  for (i = 0; i < n; i++) {
    printf("%lld %lld %lld %lld\n", (6 * i + 1) * k, (6 * i + 2) * k,
           (6 * i + 3) * k, (6 * i + 5) * k);
  }
}
