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);

        int N = sc.nextInt();
        int W = sc.nextInt();
        long[] maxSum = 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);
            for (int curr = 1; curr <= L; curr++) {
                int rem = W - curr;
                int lo, hi;
                if (rem <= L - 1) {
                    lo = L - rem;
                } else {
                    lo = 1;
                }
                if (curr <= L - 1) {
                    hi = curr;
                } else {
                    hi = 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);
                }
                maxSum[curr] += val;
                if (curr + 1 <= W) {
                    maxSum[curr + 1] -= val;
                }
            }
            int l = L + 1; // outside of the forced left zone
            int r = W - L + 1;
            if (l <= r) {
                // if there's an area with no overlap, then by definition
                // this area can escape a very negative slider. so we can pick 0!
                int val = Math.max(0, rmq.query(1, L));
                maxSum[l] += val;
                if (r + 1 <= W) {
                    maxSum[r + 1] -= val; // everything from L to W - L + 1 is updated
                }
            }
            // don't want to double add the overlap, so restart at L if it overlaps
            for (int curr = Math.max(L + 1, r + 1); curr <= W; curr++) {
                int rem = W - curr;
                int lo, hi;
                if (rem <= L - 1) {
                    lo = L - rem;
                } else {
                    lo = 1;
                }
                if (curr <= L - 1) {
                    hi = curr;
                } else {
                    hi = L;
                }
                // we've escaped the negative zone!
                int val = Math.max(0, rmq.query(lo, hi));
                maxSum[curr] += val;
                if (curr + 1 <= W) {
                    maxSum[curr + 1] -= val;
                }
            }
        }
        StringJoiner sj = new StringJoiner(" ");
        for (int v = 1; v <= W; v++) {
            maxSum[v] += maxSum[v - 1];
            sj.add(Long.toString(maxSum[v]));
        }
        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);
    }
}