#include <bits/stdc++.h>
using namespace std;
template <typename T>
using minpq = priority_queue<T, vector<T>, greater<T>>;
long long n, k;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n >> k;
  cout << k * (5 + (n - 1) * 6) << '\n';
  for (long long i = 1; i < 1 + 6 * n; i += 6) {
    cout << i * k << ' ' << (i + 1) * k << ' ' << (i + 2) * k << ' '
         << (i + 4) * k << '\n';
  }
}
