You are given n non-decreasing arrays of non-negative numbers. 

Vasya repeats the following operation k times: 

  * Selects a non-empty array. 
  * Puts the first element of the selected array in his pocket. 
  * Removes the first element from the selected array. 



Vasya wants to maximize the sum of the elements in his pocket.

Input

The first line contains two integers n and k (1 ≤ n, k ≤ 3 000): the number of arrays and operations.

Each of the next n lines contain an array. The first integer in each line is t_i (1 ≤ t_i ≤ 10^6): the size of the i-th array. The following t_i integers a_{i, j} (0 ≤ a_{i, 1} ≤ … ≤ a_{i, t_i} ≤ 10^8) are the elements of the i-th array.

It is guaranteed that k ≤ ∑_{i=1}^n t_i ≤ 10^6.

Output

Print one integer: the maximum possible sum of all elements in Vasya's pocket after k operations.

Example

Input


3 3
2 5 10
3 1 2 3
2 1 20


Output


26
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.Arrays;
import java.util.Collection;
import java.io.IOException;
import java.util.Deque;
import java.io.UncheckedIOException;
import java.io.Closeable;
import java.io.Writer;
import java.io.OutputStreamWriter;
import java.util.ArrayDeque;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) throws Exception {
        Thread thread = new Thread(null, new TaskAdapter(), "", 1 << 29);
        thread.start();
        thread.join();
    }

    static class TaskAdapter implements Runnable {
        @Override
        public void run() {
            InputStream inputStream = System.in;
            OutputStream outputStream = System.out;
            FastInput in = new FastInput(inputStream);
            FastOutput out = new FastOutput(outputStream);
            DSum solver = new DSum();
            solver.solve(1, in, out);
            out.close();
        }
    }

    static class DSum {
        public void solve(int testNumber, FastInput in, FastOutput out) {
            int n = in.readInt();
            int k = in.readInt();
            int[][] a = new int[n][];
            long[] sum = new long[n];
            for (int i = 0; i < n; i++) {
                int t = in.readInt();
                a[i] = new int[t];
                for (int j = 0; j < t; j++) {
                    a[i][j] = in.readInt();
                    sum[i] += a[i][j];
                }
            }

            UndoKnapsack knapsack = new UndoKnapsack(k);
            UndoQueue queue = new UndoQueue(n);
            for (int i = 1; i < n; i++) {
                queue.add(knapsack.add(a[i].length, sum[i]));
            }
            long ans = 0;
            for (int i = 0; i < n; i++) {
                if (i > 0) {
                    queue.add(knapsack.add(a[i - 1].length, sum[i - 1]));
                    queue.remove();
                }

                long local = knapsack.dp[k];
                long ps = 0;
                for (int j = 0; j < a[i].length && j < k; j++) {
                    ps += a[i][j];
                    local = Math.max(local, ps + knapsack.dp[k - 1 - j]);
                }
                ans = Math.max(local, ans);
            }

            out.println(ans);
        }

    }

    static class UndoQueue {
        private Deque<CommutativeUndoOperation> dq;
        private Deque<CommutativeUndoOperation> bufA;
        private Deque<CommutativeUndoOperation> bufB;

        public UndoQueue(int size) {
            dq = new ArrayDeque<>(size);
            bufA = new ArrayDeque<>(size);
            bufB = new ArrayDeque<>(size);
        }

        public void add(CommutativeUndoOperation op) {
            pushAndDo(op);
        }

        private void pushAndDo(CommutativeUndoOperation op) {
            dq.addLast(op);
            op.apply();
        }

        private void popAndUndo() {
            CommutativeUndoOperation ans = dq.removeLast();
            ans.undo();
            if (ans.flag) {
                bufA.addLast(ans);
            } else {
                bufB.addLast(ans);
            }
        }

        public void remove() {
            if (!dq.peekLast().flag) {
                popAndUndo();
                while (!dq.isEmpty() && bufB.size() != bufA.size()) {
                    popAndUndo();
                }
                if (dq.isEmpty()) {
                    while (!bufB.isEmpty()) {
                        CommutativeUndoOperation ans = bufB.removeFirst();
                        ans.flag = true;
                        pushAndDo(ans);
                    }
                } else {
                    while (!bufB.isEmpty()) {
                        CommutativeUndoOperation ans = bufB.removeLast();
                        pushAndDo(ans);
                    }
                }
                while (!bufA.isEmpty()) {
                    pushAndDo(bufA.removeLast());
                }
            }

            dq.removeLast().undo();
        }

    }

    static class FastInput {
        private final InputStream is;
        private byte[] buf = new byte[1 << 13];
        private int bufLen;
        private int bufOffset;
        private int next;

        public FastInput(InputStream is) {
            this.is = is;
        }

        private int read() {
            while (bufLen == bufOffset) {
                bufOffset = 0;
                try {
                    bufLen = is.read(buf);
                } catch (IOException e) {
                    bufLen = -1;
                }
                if (bufLen == -1) {
                    return -1;
                }
            }
            return buf[bufOffset++];
        }

        public void skipBlank() {
            while (next >= 0 && next <= 32) {
                next = read();
            }
        }

        public int readInt() {
            int sign = 1;

            skipBlank();
            if (next == '+' || next == '-') {
                sign = next == '+' ? 1 : -1;
                next = read();
            }

            int val = 0;
            if (sign == 1) {
                while (next >= '0' && next <= '9') {
                    val = val * 10 + next - '0';
                    next = read();
                }
            } else {
                while (next >= '0' && next <= '9') {
                    val = val * 10 - next + '0';
                    next = read();
                }
            }

            return val;
        }

    }

    static abstract class CommutativeUndoOperation implements UndoOperation {
        boolean flag;

    }

    static interface UndoOperation {
        void apply();

        void undo();

    }

    static class UndoKnapsack {
        public long[] dp;
        public static final long INF = (long) 2e18;

        public UndoKnapsack(int size) {
            dp = new long[size + 1];
            Arrays.fill(dp, -INF);
            dp[0] = 0;
        }

        public CommutativeUndoOperation add(int weight, long value) {
            return new CommutativeUndoOperation() {
                long[] next = new long[dp.length];


                public void apply() {
                    for (int i = 0; i < dp.length; i++) {
                        next[i] = dp[i];
                        if (i >= weight) {
                            next[i] = Math.max(next[i], dp[i - weight] + value);
                        }
                    }

                    swap();
                }

                void swap() {
                    long[] tmp = dp;
                    dp = next;
                    next = tmp;
                }


                public void undo() {
                    swap();
                }
            };
        }

    }

    static class FastOutput implements AutoCloseable, Closeable, Appendable {
        private static final int THRESHOLD = 1 << 13;
        private final Writer os;
        private StringBuilder cache = new StringBuilder(THRESHOLD * 2);

        public FastOutput append(CharSequence csq) {
            cache.append(csq);
            return this;
        }

        public FastOutput append(CharSequence csq, int start, int end) {
            cache.append(csq, start, end);
            return this;
        }

        private void afterWrite() {
            if (cache.length() < THRESHOLD) {
                return;
            }
            flush();
        }

        public FastOutput(Writer os) {
            this.os = os;
        }

        public FastOutput(OutputStream os) {
            this(new OutputStreamWriter(os));
        }

        public FastOutput append(char c) {
            cache.append(c);
            afterWrite();
            return this;
        }

        public FastOutput append(long c) {
            cache.append(c);
            afterWrite();
            return this;
        }

        public FastOutput append(String c) {
            cache.append(c);
            afterWrite();
            return this;
        }

        public FastOutput println(long c) {
            return append(c).println();
        }

        public FastOutput println() {
            return append(System.lineSeparator());
        }

        public FastOutput flush() {
            try {
                os.append(cache);
                os.flush();
                cache.setLength(0);
            } catch (IOException e) {
                throw new UncheckedIOException(e);
            }
            return this;
        }

        public void close() {
            flush();
            try {
                os.close();
            } catch (IOException e) {
                throw new UncheckedIOException(e);
            }
        }

        public String toString() {
            return cache.toString();
        }

    }
}

