#include <bits/stdc++.h>
using namespace std;
template <class T>
T gcd(T a, T b) {
  T r;
  while (b != 0) {
    r = a % b;
    a = b;
    b = r;
  }
  return a;
}
template <class T>
T lcm(T a, T b) {
  return a / gcd(a, b) * b;
}
template <class T>
int getbit(T s, int i) {
  return (s >> i) & 1;
}
template <class T>
T onbit(T s, int i) {
  return s | (T(1) << i);
}
template <class T>
T offbit(T s, int i) {
  return s & (~(T(1) << i));
}
const double PI = 2 * acos(0.0);
const double eps = 1e-6;
const int infi = 1e9;
const long long Linfi = (long long)1e15;
const long long MOD = 1000000007;
const int c1 = 11;
const int c2 = 37;
int n, k, cnt = 0;
void solve() {
  cout << (6 * n - 1) * k << endl;
  for (int i = 0; i <= n - 1; i++) {
    cout << (6 * i + 1) * k << " " << (6 * i + 2) * k << " " << (6 * i + 3) * k
         << " " << (6 * i + 5) * k << endl;
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin >> n >> k;
  solve();
  return 0;
}
