#include <bits/stdc++.h>
using namespace std;
int n, k;
int main() {
  ios_base::sync_with_stdio(false);
  cout.tie(0), cin.tie(0);
  cin >> n >> k;
  cout << (6 * n - 1) * k << endl;
  for (int i = 1; i <= n; ++i)
    cout << (6 * i - 5) * k << ' ' << (6 * i - 2) * k << ' ' << (6 * i - 3) * k
         << ' ' << (6 * i - 1) * k << endl;
  return 0;
}
