#include <bits/stdc++.h>
using namespace std;
int n, k, x = 1;
int a[10005][5];
int main() {
  scanf("%d%d", &n, &k);
  for (int i = 1; i <= n; i++) {
    a[i][1] = x * k;
    a[i][2] = (x + 1) * k;
    a[i][3] = (x + 2) * k;
    a[i][4] = (x + 4) * k;
    x += 6;
  }
  printf("%d\n", a[n][4]);
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= 4; j++) printf("%d ", a[i][j]);
    printf("\n");
  }
  return 0;
}
