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.*;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.StringTokenizer;
import java.util.List;
 import java.util.*;
 public class realfast implements Runnable 
  {
    private static final int INF = (int) 1e9;
    long in= 998244353;
    long fac[]= new long[3000];
    int n ;
    int k ;
    long sum[]=new long[3010];
    long pre[][]=new long [3010][3010];
    int len[]=new int[3010];
    public  void solve() throws IOException 
    {

       n = readInt();
       k =readInt();

       for(int i =0;i<n;i++)
       {
         //int t = readInt();
         len[i]=readInt();
         for(int j =1;j<=Math.min(len[i],k);j++)
         {
                pre[i][j]= readInt();
                sum[i]= sum[i]+pre[i][j];
                
                pre[i][j]= pre[i][j]+pre[i][j-1];
                //out.println(pre[i][j]);
         }
         for(int j =k+1;j<=len[i];j++)
         {
             int a= readInt();
         }
         len[i]=Math.min(len[i],k);
       }
       long knap[]=new long[k+1];
       long val = divide(knap,0,n-1);
       out.println(val);
    }
    public long divide(long knap[],int l , int r )
    {
               if(l==r)
               {
                 //out.println(l);
                
                 long max =0;
                 for(int i =0;i<=len[l];i++)
                 {
                     max=Math.max(max,pre[l][i]+knap[k-i]);
                    
                 } 
                 return max;   
               }
               long max =0;
               int mid = l+(r-l)/2;
               long left[]=new long[k+1];

               for(int i =0;i<=k;i++)
                left[i]= knap[i];

               for(int i =mid+1;i<=r;i++)
               {
                 add(left,len[i],sum[i]);
               }
               
               max=divide(left,l,mid);
               long right[]=new long[k+1];
               for(int i =0;i<=k;i++)
                right[i]= knap[i];
               for(int i =l;i<=mid;i++)
               {
                 add(right,len[i],sum[i]);
               }

               long max1 = divide(right,mid+1,r);
               return Math.max(max,max1);

    }
    public void add(long knap[], int l, long cost)
    {
              for(int i= k-l;i>=0;i--)
              {
                knap[i+l]=Math.max(knap[i+l],knap[i]+cost);
              }

    }
    
    public int value (int seg[], int left , int right ,int index, int l, int r)
    {
            
            if(left>right)
            {
              return -100000000;
            }
            if(right<l||left>r)
                return -100000000;
            if(left>=l&&right<=r)
                return seg[index];
            int mid = left+(right-left)/2;
            int val = value(seg,left,mid,2*index+1,l,r);
            int val2 = value(seg,mid+1,right,2*index+2,l,r);
            return Math.max(val,val2);

    }
   
    public int gcd(int a , int b )
    {
      if(a<b)
      {
        int t =a;
        a=b;
        b=t;
      }
      if(a%b==0)
        return b ;
      return gcd(b,a%b);
    }
    public long pow(long n , long p,long m)
    {
         if(p==0)
            return 1;
        long val = pow(n,p/2,m);;
        val= (val*val)%m;
        if(p%2==0)
            return val;
        else
            return (val*n)%m;
    }
    
    
    ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    public static void main(String[] args) {
        new Thread(null, new realfast(), "", 128 * (1L << 20)).start();
    }
 
    private static final boolean ONLINE_JUDGE = System.getProperty("ONLINE_JUDGE") != null;
    private BufferedReader reader;
    private StringTokenizer tokenizer;
    private PrintWriter out;
 
    @Override
    public void run() {
        try {
            if (ONLINE_JUDGE || !new File("input.txt").exists()) {
                reader = new BufferedReader(new InputStreamReader(System.in));
                out = new PrintWriter(System.out);
            } else {
                reader = new BufferedReader(new FileReader("input.txt"));
                out = new PrintWriter("output.txt");
            }
            solve();
        } catch (IOException e) {
            throw new RuntimeException(e);
        } finally {
            try {
                reader.close();
            } catch (IOException e) {
                // nothing
            }
            out.close();
        }
    }
 
    private String readString() throws IOException {
        while (tokenizer == null || !tokenizer.hasMoreTokens()) {
            tokenizer = new StringTokenizer(reader.readLine());
        }
        return tokenizer.nextToken();
    }
 
    @SuppressWarnings("unused")
    private int readInt() throws IOException {
        return Integer.parseInt(readString());
    }
 
    @SuppressWarnings("unused")
    private long readLong() throws IOException {
        return Long.parseLong(readString());
    }
 
    @SuppressWarnings("unused")
    private double readDouble() throws IOException {
        return Double.parseDouble(readString());
    }
}
class edge implements Comparable<edge>{
    int u ;
    int v;
    
    edge(int u, int v)
    {
       this.u=u;
       this.v=v;
    }
    public int compareTo(edge e)
    {
        return this.v-e.v;
    }
}