#include <bits/stdc++.h>
int main() {
  long long a, b;
  scanf("%I64d %I64d", &a, &b);
  printf("%I64d\n", (6LL * a - 1LL) * b);
  for (long long i = 1; i <= a; i++) {
    printf("%I64d %I64d %I64d %I64d\n", (6LL * i - 5LL) * b,
           (6LL * i - 4LL) * b, (6LL * i - 3LL) * b, (6LL * i - 1LL) * b);
  }
  return 0;
}
