#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0), cout.tie(0);
  int n, k;
  cin >> n >> k;
  cout << (6 * n - 1) * k << "\n";
  int x = 1;
  for (int i = 0; i < n; i++) {
    cout << k * x << " " << k * (x + 1) << " " << k * (x + 2) << " "
         << k * (x + 4) << "\n";
    x += 6;
  }
}
