Problem: Dreamoon likes to play with sets, integers and <image>. <image> is defined as the largest positive integer that divides both a and b.

Let S be a set of exactly four distinct integers greater than 0. Define S to be of rank k if and only if for all pairs of distinct elements si, sj from S, <image>.

Given k and n, Dreamoon wants to make up n sets of rank k using integers from 1 to m such that no integer is used in two different sets (of course you can leave some integers without use). Calculate the minimum m that makes it possible and print one possible solution.

Input

The single line of the input contains two space separated integers n, k (1 ≤ n ≤ 10 000, 1 ≤ k ≤ 100).

Output

On the first line print a single integer — the minimal possible m. 

On each of the next n lines print four space separated integers representing the i-th set.

Neither the order of the sets nor the order of integers within a set is important. If there are multiple possible solutions with minimal m, print any one of them.

Examples

Input

1 1


Output

5
1 2 3 5


Input

2 2


Output

22
2 4 6 22
14 18 10 16

Note

For the first example it's easy to see that set {1, 2, 3, 4} isn't a valid set of rank 1 since <image>.

Solution (in JAVA):

Solution:
import java.util.*;

import java.io.*;

public class Main {
    public static void main(String[] args) throws IOException {
        FastScanner in = new FastScanner(System.in);
        PrintWriter out = new PrintWriter(System.out);
        new Main().run(in, out);
        out.close();
    }

    public static long mod = 17352642619633L;


    long gcd(long a, long b) {
        if (a == 0) return b;
        return gcd(b%a, a);
    }
    void run(FastScanner in, PrintWriter out) {

        int N = in.nextInt();
        int K = in.nextInt();



        long[][] sets = new long[10_001][5];
        int[] index = new int[10_001];
        int n = 0;
        int printed = 0;


        List<long[]> l = new ArrayList<>();

        long i = 1;
        // for (; printed < N; i++) {
        //     if (i == 2 || i == 6 || i == 8) continue;

        //     boolean added = false;
        //     for (int j = 0; j < n; j++) {
        //         if (gcd(i, sets[j][0]) == 1) {
        //             sets[j][index[j]++] = i;
        //             sets[j][0] *= i;
        //             if (index[j] == 5) {
        //                 l.add(Arrays.copyOf(sets[j], 5));
        //                 swap(sets, j, n-1);
        //                 swap(index, j, n-1);
        //                 n--;
        //                 printed++;
        //             }
        //             added = true;
        //             break;
        //         }
        //     }

        //     if (!added && n < N) {
        //         sets[n][0] = sets[n][1] = i;
        //         index[n] = 2;
        //         n++;
        //     }
        // }

        long[] curr = new long[5];
        curr[0] = 1;
        int ci = 1;
        for (; printed < N; i++) {
            if (gcd(curr[0], i) != 1) continue;
            if (ci == 1 && i%2 == 0) continue;
            curr[ci] = i;
            curr[0] *= i;
            ci++;
            if (ci == 5) {
                l.add(Arrays.copyOfRange(curr, 0, 5));
                ci = 1;
                curr[0] = 1;
                printed++;
            }
        }

        System.out.println(K*(i-1));
        for (long[] ll : l) {
            for (int j = 1; j < 5; j++) {
                System.out.print(K*ll[j] + " ");
                // System.out.print(ll[j] + " ");
            }
            System.out.println();
        }

    }

    void swap(int[] index, int a, int b) {
        int temp = index[a];
        index[a] = index[b];
        index[b] = temp;
    }
    void swap(long[][] sets, int a, int b) {
        long[] temp = sets[a];
        sets[a] = sets[b];
        sets[b] = temp;
    }

    void t() {
        int[] x = {287,7,21,28,35,49,63,70,77,91,105,112,119,133,147,154,161,175,189,196,203,217,231,238,245,259,273,280,287};
        int[] xx = Arrays.stream(x).map(t -> t/7).toArray();
        System.out.println();

        for (int i = 1; i < 4*7;) {
            for (int j = 0; j < 4; i++, j++) {
                System.out.print(xx[i] + " " );
            }
            System.out.println();
        }
    }


    static class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        public FastScanner(InputStream in) {
            br = new BufferedReader(new InputStreamReader(in));
            st = null;
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }
    }
}