Skip to content

477B

Solution

#include <cstdio>
using namespace std;

int f[] = {1, 2, 3, 5};
int n, k;

void input()
{
    scanf("%d%d", &n, &k);
}

void output()
{
    printf("%d\n", (f[3] + (n - 1) * 6) * k);
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < 4; j++)
        {
            if (j != 0)
            {
                putchar(' ');
            }
            printf("%d", (f[j] + i * 6) * k);
        }
        puts("");
    }
}

int main()
{
    input();
    output();
    return 0;
}