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:
//package com.company;

import java.io.*;
import java.util.*;

public class Main {
    static long TIME_START, TIME_END;
    public static void main(String[] args) throws IOException {
        Scanner sc = new Scanner(System.in);
//        Scanner sc = new Scanner(new FileInputStream("Test.in"));
        PrintWriter pw = new PrintWriter(System.out);
//        PrintWriter pw = new PrintWriter(new FileOutputStream("Test.out"));
//        PrintWriter pw = new PrintWriter(new FileOutputStream("Test.in"));

        Runtime runtime = Runtime.getRuntime();
        long usedMemoryBefore = runtime.totalMemory() - runtime.freeMemory();
        TIME_START = System.currentTimeMillis();
        Task t = new Task();
        t.solve(sc, pw);
        TIME_END = System.currentTimeMillis();
        long usedMemoryAfter = runtime.totalMemory() - runtime.freeMemory();
        pw.close();
//        System.out.println("Memory increased:" + (usedMemoryAfter-usedMemoryBefore) / 1000000 );
//        System.out.println("Time used: " + (TIME_END - TIME_START) + ".");


    }

    public static class Task {

        public int gcd(int a, int b){
            while (b != 0) {
                a %= b;
                if (a == 0) return b;
                b %= a;
            }
            return a;
        }

        public void solve(Scanner sc, PrintWriter pw) throws IOException {
//            for (int i = 0; i < 300; i++) {
//                int a = i* 6 + 1;
//                int b = i * 6 + 3;
//                int c = i * 6 + 5;
//                int d = i * 6 + 2;
//                boolean ab = gcd(a, b) == 1;
//                boolean ac = gcd(a, c) == 1;
//                boolean bc = gcd(b, c) == 1;
//                boolean ad = gcd(a, d) == 1;
//                boolean bd = gcd(b, d) == 1;
//                boolean cd = gcd(c, d) == 1;
//                if (!ab || ! ac || !bc || !ad || !bd || !cd){
//                    pw.println(a + " " + b + " " + c);
//                }
//            }
            int n = sc.nextInt();
            int k = sc.nextInt();
            int[][] ret = getList(n);
            int m= 0;
            for (int i = 0; i < n; i++) {
                for (int j = 0; j < 4; j++) {
                    ret[i][j] *= k;
                    m = Math.max(m, ret[i][j]);
                }
            }
            pw.println(m);
            for (int i = 0; i < n; i++) {
                for (int j = 0; j < 4; j++) {
                    pw.print(ret[i][j] + " ");
                }
                pw.println();
            }

        }
        public int[][] getList(int k){
            int[][] ret = new int[k][4];
            for (int i = 0; i < k; i++) {
                ret[i][0] = i * 6 + 1;
                ret[i][1] = i * 6 + 2;
                ret[i][2] = i * 6 + 3;
                ret[i][3] = i * 6 + 5;
            }
            return ret;
        }

    }

    static class Scanner {
        StringTokenizer st;
        BufferedReader br;

        public Scanner(InputStream s){  br = new BufferedReader(new InputStreamReader(s));}

        public Scanner(FileReader s) throws FileNotFoundException {br = new BufferedReader(s);}

        public String next() throws IOException
        {
            while (st == null || !st.hasMoreTokens())
                st = new StringTokenizer(br.readLine());
            return st.nextToken();
        }

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

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

        public String nextLine() throws IOException {return br.readLine();}

        public double nextDouble() throws IOException { return Double.parseDouble(next()); }

        public boolean ready() throws IOException {return br.ready();}
    }
}