#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e4 + 10;
const int MOD = 1e9 + 7;
const int INF = 0x3f3f3f3f;
long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }
long long ans[maxn << 2];
int main() {
  long long n, k, m;
  scanf("%lld%lld", &n, &k);
  m = (n * 6 - 1) * k;
  printf("%lld\n", m);
  for (int i = 1; i <= n; i++) {
    long long tmp = 6 * (i - 1);
    printf("%lld %lld %lld %lld\n", (tmp + 1LL) * k, (tmp + 2LL) * k,
           (tmp + 3LL) * k, (tmp + 5LL) * k);
  }
  return 0;
}
