#include <bits/stdc++.h>
using namespace std;
inline int in() {
  int x;
  scanf("%d", &x);
  return x;
}
const long double EPS = 1e-12;
const int INF = 1e9 + 10;
const long long LINF = 1000ll * 1000 * 1000 * 1000 * 1000 * 1000 + 100;
int main() {
  ios_base ::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  int n, k;
  cin >> n >> k;
  cout << 1ll * k * (6 * (n - 1) + 5) << '\n';
  for (int i = 0; i < n; ++i) {
    cout << k * (i * 6 + 1) << ' ' << k * (i * 6 + 2) << ' ' << k * (i * 6 + 3)
         << ' ' << k * (i * 6 + 5) << '\n';
  }
  return 0;
}
