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:
/**
 * BaZ :D
 */
import java.lang.reflect.Array;
import java.util.*;
import java.io.*;
import static java.lang.Math.*;
public class ACMIND
{
    static FastReader scan;
    static PrintWriter pw;
    static long MOD = 1_000_000_007;
    static long INF = 1_000_000_000_000_000_000L;
    static long inf = 2_000_000_000;
    public static void main(String[] args) {
        new Thread(null,null,"BaZ",1<<25)
        {
            public void run()
            {
                try
                {
                    solve();
                }
                catch(Exception e)
                {
                    e.printStackTrace();
                    System.exit(1);
                }
            }
        }.start();
    }

    static int w,n,L;
    static long tree[], lazy[];
    static long temp_tree[], arr[];
    static void solve() throws IOException
    {
        //initIo(true);
        //initIo(false);
        scan = new FastReader();
        pw = new PrintWriter(System.out, true);
        StringBuilder sb = new StringBuilder();
        n = ni();
        w = ni();
        int sz = (int)pow(2, ceil(log(w)/log(2))+1);
        tree = new long[sz];
        lazy = new long[sz];
        for(int i=0;i<n;++i) {
            // pl("i: "+i);
            L = ni();
            sz = (int)pow(2, ceil(log(L)/log(2))+1);
            temp_tree = new long[sz];
            Arrays.fill(temp_tree, Integer.MIN_VALUE);
            arr = new long[L];
            for(int j=0;j<L;++j) {
                arr[j] = nl();
            }
            build(1, 0, L-1);
            if(w-L >= L) {
                rangeUpdate(L, w-L, max(0, query_temp(0, L-1)));
                //pl("updated ["+L+","+(w-L)+"] with : "+query_temp(0, L-1));
            }
            for(int j=0;j<L;++j) {
                int min_index = j-(w-L);
                int max_index = j;
                long val = Long.MIN_VALUE;
                if(min_index<0 || max_index>=L) {
                    val = 0;
                }
                val = max(val, query_temp(max(0, min_index), min(L-1, max_index)));
                rangeUpdate(j,j,val);
                //pl("updated "+j+" with : "+val);
            }
            for(int j=max(w-L+1, L);j<w;++j) {
                int min_index = j-(w-L);
                int max_index = j;
                long val = Long.MIN_VALUE;
                if(min_index<0 || max_index>=L) {
                    val = 0;
                }
                val = max(val, query_temp(max(0, min_index), min(L-1, max_index)));
                rangeUpdate(j,j,val);
                //pl("updated "+j+" with : "+val);
            }
        }
        for(int i=0;i<w;++i) {
            sb.append(query(i,i));
            sb.append(" ");
        }
        pl(sb);
        pw.flush();
        pw.close();
    }
    static void rangeUpdate(int l,int r,long val)
    {
        rangeUpdate(1,0,w-1,l,r,val);
    }
    static long query(int l,int r)
    {
        return query(1,0,w-1,l,r);
    }
    static long query_temp(int l,int r)
    {
        return query_temp(1,0,L-1,l,r);
    }
    static void build(int treein,int low,int high)
    {
        if(low==high)
            temp_tree[treein] = arr[low];
        else
        {
            int mid = (low+high)>>1;
            build(2*treein,low,mid);
            build(2*treein+1,mid+1,high);
            temp_tree[treein] = max(temp_tree[2*treein],temp_tree[2*treein+1]);
        }
    }
    static long query_temp(int treein,int low,int high,int l,int r)
    {
        if(l<=low && high<=r)
            return temp_tree[treein];
        if(low>r || high<l)
            return Integer.MIN_VALUE;
        int mid = (low+high)>>1;
        return max(query_temp(2*treein,low,mid,l,r),query_temp(2*treein+1,mid+1,high,l,r));
    }
    static void rangeUpdate(int treein,int low,int high,int l,int r,long val)
    {
        if(lazy[treein]!=0)
        {
            tree[treein]+=lazy[treein]*(high-low+1);
            if(low!=high)
            {
                lazy[2*treein]+=lazy[treein];
                lazy[2*treein+1]+=lazy[treein];
            }
            lazy[treein] = 0;
        }
        if(l<=low && high<=r)
        {
            tree[treein]+=1L*(high-low+1)*val;
            if(low!=high)
            {
                lazy[2*treein]+=val;
                lazy[2*treein+1]+=val;
            }
            return;
        }
        if(low>r || high<l)
            return;
        int mid = (low+high)>>1;
        rangeUpdate(2*treein,low,mid,l,r,val);
        rangeUpdate(2*treein+1,mid+1,high,l,r,val);
        tree[treein] = tree[2*treein]+tree[2*treein+1];
    }
    static long query(int treein,int low,int high,int l,int r)
    {
        if(lazy[treein]!=0)
        {
            tree[treein]+=lazy[treein]*(high-low+1);
            if(low!=high)
            {
                lazy[2*treein]+=lazy[treein];
                lazy[2*treein+1]+=lazy[treein];
            }
            lazy[treein] = 0;
        }
        if(l<=low && high<=r)
            return tree[treein];
        if(low>r || high<l)
            return 0;
        int mid = (low+high)>>1;
        return query(2*treein+1,mid+1,high,l,r)+query(2*treein,low,mid,l,r);
    }

    static int ni() throws IOException
    {
        return scan.nextInt();
    }
    static long nl() throws IOException
    {
        return scan.nextLong();
    }
    static double nd() throws IOException
    {
        return scan.nextDouble();
    }
    static void pl()
    {
        pw.println();
    }
    static void p(Object o)
    {
        pw.print(o+" ");
    }
    static void pl(Object o)
    {
        pw.println(o);
    }
    static void psb(StringBuilder sb)
    {
        pw.print(sb);
    }
    static void pa(String arrayName, Object arr[])
    {
        pl(arrayName+" : ");
        for(Object o : arr)
            p(o);
        pl();
    }
    static void pa(String arrayName, int arr[])
    {
        pl(arrayName+" : ");
        for(int o : arr)
            p(o);
        pl();
    }
    static void pa(String arrayName, long arr[])
    {
        pl(arrayName+" : ");
        for(long o : arr)
            p(o);
        pl();
    }
    static void pa(String arrayName, double arr[])
    {
        pl(arrayName+" : ");
        for(double o : arr)
            p(o);
        pl();
    }
    static void pa(String arrayName, char arr[])
    {
        pl(arrayName+" : ");
        for(char o : arr)
            p(o);
        pl();
    }
    static void pa(String listName, List list)
    {
        pl(listName+" : ");
        for(Object o : list)
            p(o);
        pl();
    }
    static void pa(String arrayName, Object[][] arr) {
        pl(arrayName+" : ");
        for(int i=0;i<arr.length;++i) {
            for(Object o : arr[i])
                p(o);
            pl();
        }
    }
    static void pa(String arrayName, int[][] arr) {
        pl(arrayName+" : ");
        for(int i=0;i<arr.length;++i) {
            for(int o : arr[i])
                p(o);
            pl();
        }
    }
    static void pa(String arrayName, long[][] arr) {
        pl(arrayName+" : ");
        for(int i=0;i<arr.length;++i) {
            for(long o : arr[i])
                p(o);
            pl();
        }
    }
    static void pa(String arrayName, char[][] arr) {
        pl(arrayName+" : ");
        for(int i=0;i<arr.length;++i) {
            for(char o : arr[i])
                p(o);
            pl();
        }
    }
    static void pa(String arrayName, double[][] arr) {
        pl(arrayName+" : ");
        for(int i=0;i<arr.length;++i) {
            for(double o : arr[i])
                p(o);
            pl();
        }
    }
    static class FastReader {
        final private int BUFFER_SIZE = 1 << 16;
        private DataInputStream din;
        private byte[] buffer;
        private int bufferPointer, bytesRead;

        public FastReader() {
            din = new DataInputStream(System.in);
            buffer = new byte[BUFFER_SIZE];
            bufferPointer = bytesRead = 0;
        }

        public FastReader(String file_name) throws IOException {
            din = new DataInputStream(new FileInputStream(file_name));
            buffer = new byte[BUFFER_SIZE];
            bufferPointer = bytesRead = 0;
        }

        public String readLine() throws IOException {
            byte[] buf = new byte[1000000];
            int cnt = 0, c;
            while ((c = read()) != -1) {
                if (c == '\n') break;
                buf[cnt++] = (byte) c;
            }
            return new String(buf, 0, cnt);
        }

        public int nextInt() throws IOException {
            int ret = 0;
            byte c = read();
            while (c <= ' ') c = read();
            boolean neg = (c == '-');
            if (neg) c = read();
            do {
                ret = ret * 10 + c - '0';
            } while ((c = read()) >= '0' && c <= '9');
            if (neg) return -ret;
            return ret;
        }

        public long nextLong() throws IOException {
            long ret = 0;
            byte c = read();
            while (c <= ' ') c = read();
            boolean neg = (c == '-');
            if (neg) c = read();
            do {
                ret = ret * 10 + c - '0';
            } while ((c = read()) >= '0' && c <= '9');
            if (neg) return -ret;
            return ret;
        }

        public double nextDouble() throws IOException {
            double ret = 0, div = 1;
            byte c = read();
            while (c <= ' ') c = read();
            boolean neg = (c == '-');
            if (neg) c = read();
            do {
                ret = ret * 10 + c - '0';
            } while ((c = read()) >= '0' && c <= '9');
            if (c == '.') while ((c = read()) >= '0' && c <= '9') ret += (c - '0') / (div *= 10);
            if (neg) return -ret;
            return ret;
        }

        private void fillBuffer() throws IOException {
            bytesRead = din.read(buffer, bufferPointer = 0, BUFFER_SIZE);
            if (bytesRead == -1) buffer[0] = -1;
        }

        private byte read() throws IOException {
            if (bufferPointer == bytesRead) fillBuffer();
            return buffer[bufferPointer++];
        }

        public void close() throws IOException {
            if (din == null) return;
            din.close();
        }
    }
}