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.nio.CharBuffer;
import java.util.Deque;
import java.util.LinkedList;
import java.util.NoSuchElementException;

public class P1208E_2 {

    public static void main(String[] args) {
        SimpleScanner scanner = new SimpleScanner(System.in);
        PrintWriter writer = new PrintWriter(System.out);

        int n = scanner.nextInt();
        int w = scanner.nextInt();
        long[] x = new long[w];
        long[] event = new long[w];
        for (int k = 0; k < n; ++k) {
            int l = scanner.nextInt();
            int[] a = new int[l];
            int max = 0;
            for (int i = 0; i < l; ++i) {
                a[i] = scanner.nextInt();
                max = Math.max(max, a[i]);
            }
            Deque<int[]> monotoneQueue = new LinkedList<>();
            monotoneQueue.add(new int[]{0, -1});
            for (int i = 0; i < l; ++i) {
                if (!monotoneQueue.isEmpty() && i - monotoneQueue.peekFirst()[1] > w - l)
                    monotoneQueue.pollFirst();
                while (!monotoneQueue.isEmpty() && monotoneQueue.peekLast()[0] <= a[i])
                    monotoneQueue.pollLast();
                monotoneQueue.offerLast(new int[]{a[i], i});
                x[i] += monotoneQueue.peekFirst()[0];
            }
            monotoneQueue.clear();
            monotoneQueue.add(new int[]{0, w});
            for (int i = w - 1; i >= Math.max(w - l, l); --i) {
                if (!monotoneQueue.isEmpty() && monotoneQueue.peekFirst()[1] - i > w - l)
                    monotoneQueue.pollFirst();
                while (!monotoneQueue.isEmpty() && monotoneQueue.peekLast()[0] <= a[i - w + l])
                    monotoneQueue.pollLast();
                monotoneQueue.offerLast(new int[]{a[i - w + l], i});
                x[i] += monotoneQueue.peekFirst()[0];
            }
            if (w - l > l) {
                event[l] += max;
                event[w - l] -= max;
            }
        }
        long eventSum = 0;
        for (int i = 0; i < w; ++i) {
            eventSum += event[i];
            writer.print(x[i] + eventSum + " ");
        }
        writer.println();

        writer.close();
    }

    private static class SimpleScanner {

        private static final int BUFFER_SIZE = 10240;

        private Readable in;
        private CharBuffer buffer;
        private boolean eof;

        SimpleScanner(InputStream in) {
            this.in = new BufferedReader(new InputStreamReader(in));
            buffer = CharBuffer.allocate(BUFFER_SIZE);
            buffer.limit(0);
            eof = false;
        }


        private char read() {
            if (!buffer.hasRemaining()) {
                buffer.clear();
                int n;
                try {
                    n = in.read(buffer);
                } catch (IOException e) {
                    n = -1;
                }
                if (n <= 0) {
                    eof = true;
                    return '\0';
                }
                buffer.flip();
            }
            return buffer.get();
        }

        void checkEof() {
            if (eof)
                throw new NoSuchElementException();
        }

        char nextChar() {
            checkEof();
            char b = read();
            checkEof();
            return b;
        }

        String next() {
            char b;
            do {
                b = read();
                checkEof();
            } while (Character.isWhitespace(b));
            StringBuilder sb = new StringBuilder();
            do {
                sb.append(b);
                b = read();
            } while (!eof && !Character.isWhitespace(b));
            return sb.toString();
        }

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

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

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