#include <bits/stdc++.h>
using namespace std;
const int MAX = 2e5 + 3;
const long long MOD = 1e9 + 7;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n, k;
  cin >> n >> k;
  int a[4] = {1, 2, 3, 5};
  cout << k * (6 * (n - 1) + 5) << "\n";
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < 4; j++) {
      cout << k * (6 * i + a[j]) << " ";
    }
    cout << "\n";
  }
}
