Description
INPUT
OUTPUT
SAMPLE INPUT
SAMPLE OUTPUT
HINT
#include<iostream>
using namespace std;
struct node
{
int v;
int w;
}p[21];
int n,W,k,s;
void dps(int v,int w,int num,int j)
{
int i;
if(w>W)
return;
if(num>k)
return;
if(s<v)
s=v;
for(i=j;i<n;i++)
dps(v+p[i].v,w+p[i].w,num+1,i+1);
}
int main()
{
int t,i;
cin>>t;
while(t--)
{
s=0;
cin>>n>>k;
for(i=0;i<n;i++)
cin>>p[i].v>>p[i].w;
cin>>W;
dps(0,0,0,0);
cout<<s<<endl;
}
}