#include <bits/stdc++.h>
int gcd(int x, int y) { return y ? gcd(y, x % y) : x; }
int a[10];
int main() {
  int k, n;
  scanf("%d%d", &n, &k);
  printf("%d\n", k * (6 * n - 1));
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < 3; j++) a[j] = k * (6 * i + 2 * j + 1);
    int x = k * (6 * i + 2);
    int j;
    printf("%d %d %d %d\n", a[0], a[1], a[2], x);
  }
  return 0;
}
