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