#include <bits/stdc++.h>
using namespace std;
void err(istream_iterator<string> it) { cout << "NEXT\n"; }
template <typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
  cerr << *it << " = " << a << ", ";
  err(++it, args...);
}
template <typename... T>
void rd(T&... args) {
  ((cin >> args), ...);
}
template <typename... T>
void ps(T... args) {
  ((cout << args << ' '), ...);
  cout << '\n';
}
const long long MOD = 1e9 + 7, MOD1 = 998244353LL, MAX = 2e5 + 5;
const char nl = '\n';
const int INF = 1e9 + 5;
int n, k;
void solve() {
  cin >> n >> k;
  cout << (n * 6 - 1) * k << '\n';
  for (int i = 0; i < n; i++) {
    cout << (i * 6 + 1) * k << ' ' << (i * 6 + 3) * k << ' ' << (i * 6 + 4) * k
         << ' ' << (i * 6 + 5) * k << '\n';
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int __ = 1;
  while (__--) {
    solve();
  }
  return 0;
}
