Description
INPUT
OUTPUT
SAMPLE INPUT
SAMPLE OUTPUT
HINT
#include<stdio.h>
struct node
{
int v,w;
}p[21];
int t,n,k,W,sum;
void dps(int v,int w,int num,int j)
{
int i;
if(w>W)
return ;
if(num>k)
return ;
if(sum<v)
sum=v;
for(i=j;i<n;i++)
dps(v+p[i].v,w+p[i].w,num+1,i+1);
}
int main()
{
int i;
scanf("%d",&t);
while(t--)
{
sum=0;
scanf("%d%d",&n,&k);
for(i=0;i<n;i++)
scanf("%d%d",&p[i].v,&p[i].w);
scanf("%d",&W);
dps(0,0,0,0);
printf("%d\n",sum);
}
}