#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  long long i, j, k, n, m, x, y, f;
  cin >> n >> k;
  cout << (k * (6 * (n - 1) + 5)) << endl;
  for (i = 0; i <= n - 1; i++) {
    cout << (k * (6 * i + 1)) << " ";
    cout << (k * (6 * i + 4)) << " ";
    cout << (k * (6 * i + 3)) << " ";
    cout << (k * (6 * i + 5)) << " ";
    cout << endl;
  }
  return 0;
}
