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:
/**
 * @author derrick20
 */

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

public class LetThemSlideREDO {
    public static void main(String[] args) throws Exception {
        FastScanner sc = new FastScanner();
        PrintWriter out = new PrintWriter(System.out);
/*
2 6
3 1 2 3
3 -4 -3 -4
 */
/*
Basically, there are three important zones:
first L
last L
intersection, if it exists.
By using difference arrays, we know that it only changes during these 3
regions, which may potentially overlap.

So, we sweep through each section. During the first L, we consider if
it's in the overlap region (>= W - L + 1), or not. if it's not, then
it's capable of being zero. else, it will be forced to be whatever the
maximum of the interval we found it to be is.

The behavior over the interval is a piecewise function for lo and for hi.
Lo will look like: 1 1 1 1 2 3 4 5
Hi will look like: 1 2 3 4 5 5 5 5
We can write out a formula for that, save some thinking time by doing
it for the Lo direction then manipulating it by symmetry for Hi
 */
        int N = sc.nextInt();
        int W = sc.nextInt();
        long[] diffs = new long[W + 1];
        for (int i = 0; i < N; i++) {
            int L = sc.nextInt();
            int[] slide = new int[L + 1];
            for (int j = 1; j <= L; j++) {
                slide[j] = sc.nextInt();
            }
            RMQMax rmq = new RMQMax(slide);
            long prev = 0;
            for (int curr = 1, currOpp = W; curr <= L; curr++, currOpp--) {
                int lo = Math.max(1, L + 1 - currOpp);
                int hi = Math.min(curr, L);
                int val = rmq.query(lo, hi);
                if (curr < W - L + 1) {
                    // if we're outside overlap, we can be 0!
                    val = Math.max(0, val);
                }
                long next = val;
                diffs[curr] += next - prev;
                prev = next;
            }
            int l = L + 1; // outside of the forced left zone
            int r = W - L + 1;
            // don't want to double add the overlap, so restart at L if it overlaps
            for (int curr = Math.max(L + 1, r + 1), currOpp = W - curr + 1; curr <= W; curr++, currOpp--) {
                int lo = Math.max(1, L + 1 - currOpp);
                int hi = Math.min(curr, L);
                // we've escaped the negative zone!
                long next = Math.max(0, rmq.query(lo, hi));
                diffs[curr] += next - prev;
                prev = next;
            }
        }
        StringJoiner sj = new StringJoiner(" ");
        long integral = 0;
        for (int v = 1; v <= W; v++) {
            integral += diffs[v];
            sj.add(Long.toString(integral));
        }
        out.println(sj);
        out.close();
    }

    static class RMQMax {
        int[][] table;
        int[] a;
        int IDENTITY = (int) -1e9;
        public RMQMax(int[] a) {
            int k = log(a.length);
            table = new int[k + 1][a.length];
            table[0] = a;
            for (int p = 1; p <= k; p++) {
                for (int i = 0; i < a.length; i++) {
                    int shifted = Math.min(a.length - 1, i + (1 << (p - 1)));
                    table[p][i] = Math.max(table[p - 1][i], table[p - 1][shifted]);
                }
            }
        }
        public int log(int len) {
            int k = -1;
            while (1 << (k + 1) <= len) {
                k++;
            }
            return k;
        }
        public int query(int i, int j) {
            if (j < i) return IDENTITY;
            int k = log(j - i + 1);
            int shifted = Math.max(0, j - (1 << k) + 1);
            return Math.max(table[k][i], table[k][shifted]);
        }
    }

    static class FastScanner {
        private int BS = 1 << 16;
        private char NC = (char) 0;
        private byte[] buf = new byte[BS];
        private int bId = 0, size = 0;
        private char c = NC;
        private double cnt = 1;
        private BufferedInputStream in;

        public FastScanner() {
            in = new BufferedInputStream(System.in, BS);
        }

        public FastScanner(String s) {
            try {
                in = new BufferedInputStream(new FileInputStream(new File(s)), BS);
            } catch (Exception e) {
                in = new BufferedInputStream(System.in, BS);
            }
        }

        private char getChar() {
            while (bId == size) {
                try {
                    size = in.read(buf);
                } catch (Exception e) {
                    return NC;
                }
                if (size == -1) return NC;
                bId = 0;
            }
            return (char) buf[bId++];
        }

        public int nextInt() {
            return (int) nextLong();
        }

        public int[] nextInts(int N) {
            int[] res = new int[N];
            for (int i = 0; i < N; i++) {
                res[i] = (int) nextLong();
            }
            return res;
        }

        public long[] nextLongs(int N) {
            long[] res = new long[N];
            for (int i = 0; i < N; i++) {
                res[i] = nextLong();
            }
            return res;
        }

        public long nextLong() {
            cnt = 1;
            boolean neg = false;
            if (c == NC) c = getChar();
            for (; (c < '0' || c > '9'); c = getChar()) {
                if (c == '-') neg = true;
            }
            long res = 0;
            for (; c >= '0' && c <= '9'; c = getChar()) {
                res = (res << 3) + (res << 1) + c - '0';
                cnt *= 10;
            }
            return neg ? -res : res;
        }

        public double nextDouble() {
            double cur = nextLong();
            return c != '.' ? cur : cur + nextLong() / cnt;
        }

        public double[] nextDoubles(int N) {
            double[] res = new double[N];
            for (int i = 0; i < N; i++) {
                res[i] = nextDouble();
            }
            return res;
        }

        public String next() {
            StringBuilder res = new StringBuilder();
            while (c <= 32) c = getChar();
            while (c > 32) {
                res.append(c);
                c = getChar();
            }
            return res.toString();
        }

        public String nextLine() {
            StringBuilder res = new StringBuilder();
            while (c <= 32) c = getChar();
            while (c != '\n') {
                res.append(c);
                c = getChar();
            }
            return res.toString();
        }

        public boolean hasNext() {
            if (c > 32) return true;
            while (true) {
                c = getChar();
                if (c == NC) return false;
                else if (c > 32) return true;
            }
        }
    }

    static void ASSERT(boolean assertion, String message) {
        if (!assertion) throw new AssertionError(message);
    }
}