#include #include #include using namespace std; map ha[35]; int vis[35]; int n,v,k; int flag; int constraint; int g[35][35]; struct node { int w; int cons; }t[35],s[35]; void dfs(int y,int x,int cur) { if(y>k) return; else if(x==constraint) ha[y][cur]=1; else { int tt=0; if(s[x].cons!=-1) { for(int i=0;ik) return; else if(x==n) { if(ha[k-y][v-cur]==1) { flag=1; return; } } else if(!flag) { dfs2(y+1,x+1,cur+s[x].w); dfs2(y,x+1,cur); } } int main() { int i,j; int T; int m; int mark[35]; scanf("%d",&T); while(T--) { scanf("%d%d%d%d",&n,&m,&k,&v); for(i=0;in/2) constraint=cnt; else constraint=n/2+1; for(i=0;i