#include <bits/stdc++.h>
using namespace std;
const int MOD = 1000000007;
const double eps = 1e-8;
const int nm = 300005;
int n, k, m, t;
long long res;
int a[nm];
bool check[nm];
long long Pow(int x, int mu) {
  if (mu == 0) return 1ll;
  long long res = Pow(x, mu >> 1);
  res = res * res % MOD;
  if (mu & 1) res = res * x % MOD;
  return res;
}
int sl[500000];
int tmp[50], ntmp;
vector<int> V[500000];
int ans[10005][5];
int main() {
  int i, j, x, y, z, w;
  scanf("%d%d", &n, &k);
  m = n * 4;
  cout << (6 * n - 1) * k << endl;
  for (i = 0; i < n; i++)
    printf("%d %d %d %d\n", (6 * i + 1) * k, (6 * i + 2) * k, (6 * i + 3) * k,
           (6 * i + 5) * k);
  return 0;
}
