Problem: You are given n arrays that can have different sizes. You also have a table with w columns and n rows. The i-th array is placed horizontally in the i-th row. You can slide each array within its row as long as it occupies several consecutive cells and lies completely inside the table.

You need to find the maximum sum of the integers in the j-th column for each j from 1 to w independently.

<image> Optimal placements for columns 1, 2 and 3 are shown on the pictures from left to right.

Note that you can exclude any array out of a column provided it remains in the window. In this case its value is considered to be zero.

Input

The first line contains two integers n (1 ≤ n ≤ 10^{6}) and w (1 ≤ w ≤ 10^{6}) — the number of arrays and the width of the table.

Each of the next n lines consists of an integer l_{i} (1 ≤ l_{i} ≤ w), the length of the i-th array, followed by l_{i} integers a_{i1}, a_{i2}, …, a_{il_i} (-10^{9} ≤ a_{ij} ≤ 10^{9}) — the elements of the array.

The total length of the arrays does no exceed 10^{6}.

Output

Print w integers, the i-th of them should be the maximum sum for column i.

Examples

Input


3 3
3 2 4 8
2 2 5
2 6 3


Output


10 15 16 


Input


2 2
2 7 8
1 -8


Output


7 8 

Note

Illustration for the first example is in the statement.

Solution (in JAVA):

Solution:
import java.io.*;
import java.util.Arrays;
import java.util.StringJoiner;
import java.util.StringTokenizer;
import java.util.function.Function;

public class Main {

    static int N, W;
    static int[][] A;

    public static void main(String[] args) {
        FastScanner sc = new FastScanner(System.in);
        N = sc.nextInt();
        W = sc.nextInt();
        A = new int[N][];
        for (int i = 0; i < N; i++) {
            int n = sc.nextInt();
            A[i] = sc.nextIntArray(n);
        }

        PrintWriter pw = new PrintWriter(System.out);
        solve(pw);
        pw.flush();
    }

    static void solve(PrintWriter pw) {
        long[] imos = new long[W+1];
        long[] ans = new long[W];
        for (int[] R : A) {
            int n = R.length;
            if( W > n*2 ) {
                // abcccccde -> ab + c*? + de
                // 0, n)[n, W-n)[W-n, W)
                int max = Integer.MIN_VALUE;
                for (int i = 0; i < n; i++) {
                    max = Math.max(max, R[i]);
                    if( max > 0 ) {
                        ans[i] += max;
                    }
                }
                max = Integer.MIN_VALUE;
                for (int i = n-1; i >= 0; i--) {
                    max = Math.max(max, R[i]);
                    if( max > 0 ) {
                        ans[W-n+i] += max;
                    }
                }

                if( max > 0 ) {
                    imos[n] += max;
                    imos[W-n] -= max;
                }

            } else {
                IntSlideMin slide = new IntSlideMin(R, false);
                int band = W - n + 1;

                for (int i = 0; i < W; i++) {
                    if( slide.r < n ) {
                        slide.rsucc();
                    }
                    if( i >= band ) {
                        slide.lsucc();
                    }
//                    debug(i, slide.l, slide.r);
//                    debug(Arrays.copyOfRange(slide.deq, slide.u, slide.v));

                    int v = slide.get();
                    if( i < W-n || n <= i ) {
                        v = Math.max(0, v);
                    }
                    ans[i] += v;
                }
            }
        }

        for (int i = 0; i < W; i++) {
            imos[i+1] += imos[i];
        }
        for (int i = 0; i < W; i++) {
            ans[i] += imos[i];

            if( i != 0 ) {
                pw.print(" ");
            }
            pw.print(ans[i]);
        }
        pw.println();
    }

    static String mkString(long[] arr) {
        StringJoiner j = new StringJoiner(" ");
        for (long a : arr) {
            j.add(String.valueOf(a));
        }
        return j.toString();
    }

    static class IntSlideMin {

        private int[] values;
        private boolean min; // min/max
        private int l, r; // [l, r)

        private int[] deq;
        private int u, v;

        IntSlideMin(int[] values, boolean min) {
            this.values = values;
            this.min = min;
            deq = new int[values.length];
            u = 0; v = 0;
            l = 0; r = 0;
        }

        void rsucc() {
            // 次のrに負けるdeqの中身を削る
            while(u != v) {
                boolean lose;
                if( min ) {
                    lose = values[r] < values[deq[v-1]];
                } else {
                    lose = values[r] > values[deq[v-1]];
                }
                if( lose ) {
                    v--;
                } else {
                    break;
                }
            }
            deq[v++] = r++;
        }

        void lsucc() {
            l++;
            while(u != v && deq[u] < l ) {
                u++;
            }
        }

        int get() {
            if( u != v ) {
                return values[deq[u]];
            } else {
                throw new RuntimeException("empty");
            }
        }
    }

    @SuppressWarnings("unused")
    static class FastScanner {
        private BufferedReader reader;
        private StringTokenizer tokenizer;

        FastScanner(InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in));
            tokenizer = null;
        }

        String next() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        String nextLine() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    return reader.readLine();
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken("\n");
        }

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

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

        int[] nextIntArray(int n) {
            int[] a = new int[n];
            for (int i = 0; i < n; i++)
                a[i] = nextInt();
            return a;
        }

        int[] nextIntArray(int n, int delta) {
            int[] a = new int[n];
            for (int i = 0; i < n; i++)
                a[i] = nextInt() + delta;
            return a;
        }

        long[] nextLongArray(int n) {
            long[] a = new long[n];
            for (int i = 0; i < n; i++)
                a[i] = nextLong();
            return a;
        }
    }

    static <A> void writeLines(A[] as, Function<A, String> f) {
        PrintWriter pw = new PrintWriter(System.out);
        for (A a : as) {
            pw.println(f.apply(a));
        }
        pw.flush();
    }

    static void writeLines(int[] as) {
        PrintWriter pw = new PrintWriter(System.out);
        for (int a : as) pw.println(a);
        pw.flush();
    }

    static void writeLines(long[] as) {
        PrintWriter pw = new PrintWriter(System.out);
        for (long a : as) pw.println(a);
        pw.flush();
    }

    static int max(int... as) {
        int max = Integer.MIN_VALUE;
        for (int a : as) max = Math.max(a, max);
        return max;
    }

    static int min(int... as) {
        int min = Integer.MAX_VALUE;
        for (int a : as) min = Math.min(a, min);
        return min;
    }

    static void debug(Object... args) {
        StringJoiner j = new StringJoiner(" ");
        for (Object arg : args) {
            if (arg instanceof int[]) j.add(Arrays.toString((int[]) arg));
            else if (arg instanceof long[]) j.add(Arrays.toString((long[]) arg));
            else if (arg instanceof double[]) j.add(Arrays.toString((double[]) arg));
            else if (arg instanceof Object[]) j.add(Arrays.toString((Object[]) arg));
            else j.add(arg.toString());
        }
        System.err.println(j.toString());
    }
}