#include<cstdio>
#include<ctime>
#include<cstdlib>
#include<cstring>
#define sz 10000
using namespace std;
int p[200],cnt,now,ZH,DA,vis[sz+10],b[sz];
int C;
char s[sz+10][5];
void make(int x){
	int tmp=x;
	int cnt=0;
	for(int i=0;i<4;i++){
		s[tmp][cnt++]=x%10+'0';
		x/=10;
	}
}
bool check(int x){
	memset(p,0,sizeof(p));
	int zh=0,da=0;
	for(int i=0;i<4;i++){
		p[s[x][i]]++;
		if(p[s[x][i]]>1) return false;
	}
	for(int i=0;i<4;i++){
		if(p[s[now][i]]) da++;
	}
	for(int i=0;i<4;i++)
		if(s[now][i]==s[x][i]) zh++,da--;
	return da==DA&&ZH==zh;
}
bool check1(int x){
	memset(p,0,sizeof(p));
	for(int i=0;i<4;i++){
		p[s[x][i]]++;
		if(p[s[x][i]]>1) return false;
	}
}
int main(){
	srand(time(0));
	for(int i=0;i<sz;i++) make(i);
	cnt=0;
	for(int i=0;i<sz;i++)
		if(!vis[i]){
			if(check1(i)) b[cnt++]=i;
			else vis[i]=1;
		}
	now=rand()*rand()%cnt;
	now=b[now];
	for(int i=0;i<4;i++)//
		printf("%c",s[now][i]);
	printf("\n");
	fflush(stdout);
	while(scanf("%d%d",&ZH,&DA)&&ZH!=4){
		C++;
		cnt=0;
		for(int i=0;i<sz;i++)
		if(!vis[i]){
			if(check(i)) b[cnt++]=i;
			else vis[i]=1;
		}
		now=rand()*rand()%cnt;
		now=b[now];
		for(int i=0;i<4;i++)
		printf("%c",s[now][i]);
		printf("\n");
		fflush(stdout);
	}
}


#include<cstdio>
#include<ctime>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#define sz 10000
using namespace std;
int p[200],cnt,now,ZH,DA,vis[sz+10],b[sz],C;
char s[sz+10][5];
struct he{
	int zh,da,p;
}c[sz];
void make(int x){
	int tmp=x;
	int cnt=0;
	for(int i=0;i<4;i++){
		s[tmp][3-cnt]=x%10+'0';
		cnt++;
		x/=10;
	}
}
bool check(int x){
	memset(p,0,sizeof(p));
	int zh=0,da=0;
	for(int i=0;i<4;i++){
		p[s[x][i]]++;
		if(p[s[x][i]]>1) return false;
	}
	for(int i=0;i<4;i++){
		if(p[s[now][i]]) da++;
	}
	for(int i=0;i<4;i++)
		if(s[now][i]==s[x][i]) zh++,da--;
	return da==DA&&ZH==zh;
}
bool check1(int x){
	memset(p,0,sizeof(p));
	for(int i=0;i<4;i++){
		p[s[x][i]]++;
		if(p[s[x][i]]>1) return false;
	}
}
void work1(int p1,int p2,int now,int x){
	memset(p,0,sizeof(p));
	int zh=0,da=0;
	for(int i=0;i<4;i++){
		p[s[x][i]]++;
	}
	for(int i=0;i<4;i++){
		if(p[s[now][i]]) da++;
	}
	for(int i=0;i<4;i++)
		if(s[now][i]==s[x][i]) zh++,da--;
	c[p1].zh+=zh;c[p2].da+=da;
}
bool cmp(he a,he b){
	if(a.zh+a.da==b.zh+b.da){
		return a.zh>b.zh;
	}
	return a.zh+a.da>b.zh+b.da;
}
void work(){
	for(int i=0;i<cnt;i++) c[i].zh=c[i].da=0,c[i].p=i;
	for(int i=0;i<cnt;i++){
		for(int j=0;j<cnt;j++)
			work1(i,j,b[i],b[j]);
	}
	sort(c,c+cnt,cmp);
//	for(int i=0;i<cnt;i++) printf("%d %d %d\n",c[i].zh,c[i].da,b[c[i].p]);
	now=b[c[0].p];
//	printf("%d\n",now);
}
int main(){
	srand(time(0));
	for(int i=0;i<sz;i++) make(i);
	cnt=0;
//	printf("\n\n");
	for(int i=0;i<sz;i++)
		if(!vis[i]){
			if(check1(i)) b[cnt++]=i;
			else vis[i]=1;
		}
	now=rand()*rand()%cnt;
	now=b[now];
//	printf("%d\n",now);
	for(int i=0;i<4;i++)
		printf("%c",s[now][i]);
	vis[now]=1;
	printf("\n");
	fflush(stdout);
	while(scanf("%d%d",&ZH,&DA)&&ZH!=4){
		C++;
		cnt=0;
		for(int i=0;i<sz;i++)
		if(!vis[i]){
			if(check(i)) {
				b[cnt++]=i;
	//			printf("%d ",i);
			}
			else vis[i]=1;
		}
		if(C>=2)work();
		else{
			now=rand()*rand()%cnt;
			now=b[now];
		}//
	//	printf("\n\n");
		for(int i=0;i<4;i++)
		printf("%c",s[now][i]);
		vis[now]=1;
		printf("\n");
		fflush(stdout);
	}
}


#include<cstdio>
#include<ctime>
#include<cstdlib>
#include<cstring>
#define sz 10000
using namespace std;
int p[200],cnt,now,ZH,DA,vis[sz+10],b[sz];
int C;
char s[sz+10][5];
void make(int x){
	int tmp=x;
	int cnt=0;
	for(int i=0;i<4;i++){
		s[tmp][cnt++]=x%10+'0';
		x/=10;
	}
}
bool check(int x){
	memset(p,0,sizeof(p));
	int zh=0,da=0;
	for(int i=0;i<4;i++){
		p[s[x][i]]++;
		if(p[s[x][i]]>1) return false;
	}
	for(int i=0;i<4;i++){
		if(p[s[now][i]]) da++;
	}
	for(int i=0;i<4;i++)
		if(s[now][i]==s[x][i]) zh++,da--;
	return da==DA&&ZH==zh;
}
bool check1(int x){
	memset(p,0,sizeof(p));
	for(int i=0;i<4;i++){
		p[s[x][i]]++;
		if(p[s[x][i]]>1) return false;
	}
}
int main(){
	srand(time(0));
	for(int i=0;i<sz;i++) make(i);
	cnt=0;
	for(int i=0;i<sz;i++)
		if(!vis[i]){
			if(check1(i)) b[cnt++]=i;
			else vis[i]=1;
		}
	now=rand()*rand()%cnt;
	now=b[now];
	now=6483;
	for(int i=0;i<4;i++)
		printf("%c",s[now][i]);
	printf("\n");
	fflush(stdout);
	while(scanf("%d%d",&ZH,&DA)&&ZH!=4){
		C++;
		cnt=0;
		for(int i=0;i<sz;i++)
		if(!vis[i]){
			if(check(i)) b[cnt++]=i;
			else vis[i]=1;
		}
		printf("%d\n",cnt);
		now=rand()*rand()%cnt;
		now=b[now];
		for(int i=0;i<4;i++)
		printf("%c",s[now][i]);
		printf("\n");
		fflush(stdout);
	}
}


#include<cstdio>
#include<ctime>
#include<cstdlib>
#include<cstring>
#define sz 10000
using namespace std;
int p[200],cnt,now,ZH,DA,vis[sz+10],b[sz],Da;
int C;
char s[sz+10][5];
void make(int x){
	int tmp=x;
	int cnt=0;
	for(int i=0;i<4;i++){
		s[tmp][cnt++]=x%10+'0';
		x/=10;
	}
}
bool check(int x){
	memset(p,0,sizeof(p));
	int zh=0,da=0;
	for(int i=0;i<4;i++){
		p[s[x][i]]++;
		if(p[s[x][i]]>1) return false;
	}
	for(int i=0;i<4;i++){
		if(p[s[now][i]]) da++;
	}
	for(int i=0;i<4;i++)
		if(s[now][i]==s[x][i]) zh++,da--;
	return da==DA&&ZH==zh;
}
bool check1(int x){
	memset(p,0,sizeof(p));
	for(int i=0;i<4;i++){
		p[s[x][i]]++;
		if(p[s[x][i]]>1) return false;
	}
}
int main(){
	srand(time(0));
	for(int i=0;i<sz;i++) make(i);
	cnt=0;
	for(int i=0;i<sz;i++)
		if(!vis[i]){
			if(check1(i)) b[cnt++]=i;
			else vis[i]=1;
		}
	now=rand()*rand()%cnt;
	now=b[now];
	now=1234;
	for(int i=0;i<4;i++)
		printf("%c",s[now][i]);
	printf("\n");
	fflush(stdout);
	while(scanf("%d%d",&ZH,&DA)&&ZH!=4){
		C++;
		cnt=0;
		for(int i=0;i<sz;i++)//
		if(!vis[i]){
			if(check(i)) b[cnt++]=i;
			else vis[i]=1;
		}
		now=rand()*rand()%cnt;
		now=b[now];Da+=DA;
		if(C==1&&DA<=1)now=8567;
		if(C==2&&Da<=3)now=3690;
		for(int i=0;i<4;i++)
		printf("%c",s[now][i]);
		printf("\n");
		fflush(stdout);
	}
}


#include<cstdio>
#include<ctime>
#include<cstdlib>
#include<cstring>
#define sz 10000
using namespace std;
int p[200],cnt,now,ZH,DA,vis[sz+10],b[sz];
int C;
char s[sz+10][5];
void make(int x){
	int tmp=x;
	int cnt=0;
	for(int i=0;i<4;i++){
		s[tmp][cnt++]=x%10+'0';
		x/=10;
	}
}
bool check(int x){
	memset(p,0,sizeof(p));
	int zh=0,da=0;
	for(int i=0;i<4;i++){
		p[s[x][i]]++;
		if(p[s[x][i]]>1) return false;
	}
	for(int i=0;i<4;i++){
		if(p[s[now][i]]) da++;
	}
	for(int i=0;i<4;i++)
		if(s[now][i]==s[x][i]) zh++,da--;
	return da==DA&&ZH==zh;
}
bool check1(int x){
	memset(p,0,sizeof(p));
	for(int i=0;i<4;i++){
		p[s[x][i]]++;
		if(p[s[x][i]]>1) return false;
	}
}
int main(){
	srand(time(0));
	for(int i=0;i<sz;i++) make(i);
	cnt=0;
	for(int i=0;i<sz;i++)
		if(!vis[i]){
			if(check1(i)) b[cnt++]=i;////
			else vis[i]=1;
		}
	now=rand()*rand()%cnt;
	now=b[now];
	for(int i=0;i<4;i++)
		printf("%c",s[now][i]);
	printf("\n");
	fflush(stdout);
	while(scanf("%d%d",&ZH,&DA)&&ZH!=4){
		C++;
		cnt=0;
		for(int i=0;i<sz;i++)
		if(!vis[i]){
			if(check(i)) b[cnt++]=i;
			else vis[i]=1;
		}
		now=rand()*rand()%cnt;
		now=b[now];
		for(int i=0;i<4;i++)
		printf("%c",s[now][i]);
		printf("\n");
		fflush(stdout);
	}
}


#include<cstdio>
#include<ctime>
#include<cstdlib>
#include<cstring>
#define sz 10000
using namespace std;
int p[200],cnt,now,ZH,DA,vis[sz+10],b[sz];
int C;
char s[sz+10][5];
void make(int x){
	int tmp=x;
	int cnt=0;
	for(int i=0;i<4;i++){
		s[tmp][cnt++]=x%10+'0';
		x/=10;
	}
}
bool check(int x){
	memset(p,0,sizeof(p));
	int zh=0,da=0;
	for(int i=0;i<4;i++){
		p[s[x][i]]++;
		if(p[s[x][i]]>1) return false;
	}
	for(int i=0;i<4;i++){
		if(p[s[now][i]]) da++;
	}
	for(int i=0;i<4;i++)
		if(s[now][i]==s[x][i]) zh++,da--;
	return da==DA&&ZH==zh;
}
bool check1(int x){
	memset(p,0,sizeof(p));
	for(int i=0;i<4;i++){
		p[s[x][i]]++;
		if(p[s[x][i]]>1) return false;
	}
}
int main(){
	srand(time(0));
	for(int i=0;i<sz;i++) make(i);
	cnt=0;
	for(int i=0;i<sz;i++)
		if(!vis[i]){
			if(check1(i)) b[cnt++]=i;
			else vis[i]=1;
		}
	now=rand()*rand()%cnt;
	now=b[now];
	for(int i=0;i<4;i++)
		printf("%c",s[now][i]);
	printf("\n");////
	fflush(stdout);
	while(scanf("%d%d",&ZH,&DA)&&ZH!=4){
		C++;
		cnt=0;
		for(int i=0;i<sz;i++)
		if(!vis[i]){
			if(check(i)) b[cnt++]=i;
			else vis[i]=1;
		}
		now=rand()*rand()%cnt;
		now=b[now];
		for(int i=0;i<4;i++)
		printf("%c",s[now][i]);
		printf("\n");
		fflush(stdout);
	}
}


#include<cstdio>
#include<ctime>
#include<cstdlib>
#include<cstring>
#define sz 10000
using namespace std;
int p[200],cnt,now,ZH,DA,vis[sz+10],b[sz],Da;
int C;
char s[sz+10][5];
void make(int x){
	int tmp=x;
	int cnt=0;
	for(int i=0;i<4;i++){
		s[tmp][cnt++]=x%10+'0';
		x/=10;
	}
}
bool check(int x){
	memset(p,0,sizeof(p));
	int zh=0,da=0;
	for(int i=0;i<4;i++){
		p[s[x][i]]++;
		if(p[s[x][i]]>1) return false;
	}
	for(int i=0;i<4;i++){
		if(p[s[now][i]]) da++;
	}
	for(int i=0;i<4;i++)
		if(s[now][i]==s[x][i]) zh++,da--;
	return da==DA&&ZH==zh;
}
bool check1(int x){
	memset(p,0,sizeof(p));
	for(int i=0;i<4;i++){
		p[s[x][i]]++;
		if(p[s[x][i]]>1) return false;
	}
}
int main(){
	srand(time(0));
	for(int i=0;i<sz;i++) make(i);
	cnt=0;
	for(int i=0;i<sz;i++)
		if(!vis[i]){
			if(check1(i)) b[cnt++]=i;
			else vis[i]=1;
		}
	now=rand()*rand()%cnt;
	now=b[now];
	now=1234;
	for(int i=0;i<4;i++)
		printf("%c",s[now][i]);
	printf("\n");
	fflush(stdout);
	while(scanf("%d%d",&ZH,&DA)&&ZH!=4){
		C++;
		cnt=0;
		for(int i=0;i<sz;i++)
		if(!vis[i]){
			if(check(i)) b[cnt++]=i;
			else vis[i]=1;
		}
		now=rand()*rand()%cnt;
		now=b[now];Da+=DA;
		if(C==1&&DA<=1)now=8567;
		if(C==2&&Da<=3)now=3690;
		for(int i=0;i<4;i++)
		printf("%c",s[now][i]);
		printf("\n");
		fflush(stdout);
	}
}


#include<cstdio>
#include<ctime>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#define sz 10000
using namespace std;
int p[200],cnt,now,ZH,DA,vis[sz+10],b[sz],C;
char s[sz+10][5];
struct he{
	int zh,da,p,d;
}c[sz];
void make(int x){
	int tmp=x;
	int cnt=0;
	for(int i=0;i<4;i++){
		s[tmp][3-cnt]=x%10+'0';
		cnt++;
		x/=10;
	}
}
bool check(int x){
	memset(p,0,sizeof(p));
	int zh=0,da=0;
	for(int i=0;i<4;i++){
		p[s[x][i]]++;
		if(p[s[x][i]]>1) return false;
	}
	for(int i=0;i<4;i++){
		if(p[s[now][i]]) da++;
	}
	for(int i=0;i<4;i++)
		if(s[now][i]==s[x][i]) zh++,da--;
	return da==DA&&ZH==zh;
}
bool check1(int x){
	memset(p,0,sizeof(p));
	for(int i=0;i<4;i++){
		p[s[x][i]]++;
		if(p[s[x][i]]>1) return false;
	}
}
void work1(int p1,int now,int x){
    for(int i='0';i<='9';i++)p[i]=0;
	int zh=0,da=0;
	for(int i=0;i<4;i++){
		p[s[x][i]]++;
	}
	for(int i=0;i<4;i++){
		if(p[s[now][i]]) da++;
	}
	for(int i=0;i<4;i++)
		if(s[now][i]==s[x][i]) zh++,da--;
	c[p1].zh+=zh;c[p1].da+=da;
	c[p1].d+=zh*2+da;
}
bool cmp(he a,he b){
	if(a.zh+a.da==b.zh+b.da){
		return a.zh>b.zh;
	}
	return a.zh+a.da>b.zh+b.da;
}
bool cmp1(he a,he b){
	return a.d<b.d;
}
bool cmp2(he a,he b){
	if(a.zh==b.zh)
	return a.da>b.da;
	return a.zh>b.zh;
}
void work(){
	for(int i=0;i<cnt;i++) c[i].zh=c[i].da=0,c[i].p=i;
	for(int i=0;i<cnt;i++){
		for(int j=0;j<cnt;j++)
			work1(i,b[i],b[j]);
	}
	sort(c,c+cnt,cmp2);
//	for(int i=0;i<cnt;i++) printf("%d %d %d\n",c[i].zh,c[i].da,b[c[i].p]);
	now=b[c[0].p];
//	printf("%d\n",now);
}
int main(){
	srand(time(0));
	for(int i=0;i<sz;i++) make(i);
	cnt=0;
//	printf("\n\n");
	for(int i=0;i<sz;i++)
		if(!vis[i]){
			if(check1(i)) b[cnt++]=i;
			else vis[i]=1;
		}
	now=rand()*rand()%cnt;
	now=b[now];
//	printf("%d\n",now);
	for(int i=0;i<4;i++)
		printf("%c",s[now][i]);
	vis[now]=1;
	printf("\n");
	fflush(stdout);
	while(scanf("%d%d",&ZH,&DA)&&ZH!=4){
		C++;
		cnt=0;
		for(int i=0;i<sz;i++)
		if(!vis[i]){
			if(check(i)) {
				b[cnt++]=i;
	//			printf("%d ",i);
			}
			else vis[i]=1;
		}
		work();
	//	printf("\n\n");
		for(int i=0;i<4;i++)
		printf("%c",s[now][i]);
		vis[now]=1;
		printf("\n");
		fflush(stdout);
	}
}


#include<cstdio>
#include<ctime>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#define sz 10000
using namespace std;
int p[200],cnt,now,ZH,DA,vis[sz+10],b[sz],C;
char s[sz+10][5];
struct he{
	int zh,da,p,d;
}c[sz];
void make(int x){
	int tmp=x;
	int cnt=0;
	for(int i=0;i<4;i++){
		s[tmp][3-cnt]=x%10+'0';
		cnt++;
		x/=10;
	}
}
bool check(int x){
	memset(p,0,sizeof(p));
	int zh=0,da=0;
	for(int i=0;i<4;i++){
		p[s[x][i]]++;
		if(p[s[x][i]]>1) return false;
	}
	for(int i=0;i<4;i++){
		if(p[s[now][i]]) da++;
	}
	for(int i=0;i<4;i++)
		if(s[now][i]==s[x][i]) zh++,da--;
	return da==DA&&ZH==zh;
}
bool check1(int x){
	memset(p,0,sizeof(p));
	for(int i=0;i<4;i++){
		p[s[x][i]]++;
		if(p[s[x][i]]>1) return false;
	}
}
void work1(int p1,int now,int x){
	memset(p,0,sizeof(p));
	int zh=0,da=0;
	for(int i=0;i<4;i++){
		p[s[x][i]]++;
	}
	for(int i=0;i<4;i++){
		if(p[s[now][i]]) da++;
	}
	for(int i=0;i<4;i++)
		if(s[now][i]==s[x][i]) zh++,da--;
	c[p1].zh+=zh;c[p1].da+=da;
	c[p1].d+=zh*2+da;
}
bool cmp(he a,he b){
	if(a.zh+a.da==b.zh+b.da){
		return a.zh>b.zh;
	}
	return a.zh+a.da>b.zh+b.da;
}
bool cmp1(he a,he b){
	return a.d<b.d;
}
void work(){
	for(int i=0;i<cnt;i++) c[i].zh=c[i].da=0,c[i].p=i;
	for(int i=0;i<cnt;i++){
		for(int j=0;j<cnt;j++)
			work1(i,b[i],b[j]);
	}
	sort(c,c+cnt,cmp);
//	for(int i=0;i<cnt;i++) printf("%d %d %d\n",c[i].zh,c[i].da,b[c[i].p]);
	now=b[c[0].p];
//	printf("%d\n",now);
}
int main(){
	srand(time(0));
	for(int i=0;i<sz;i++) make(i);
	cnt=0;
//	printf("\n\n");
	for(int i=0;i<sz;i++)
		if(!vis[i]){
			if(check1(i)) b[cnt++]=i;
			else vis[i]=1;
		}
	now=rand()*rand()%cnt;
	now=b[now];
//	printf("%d\n",now);
	for(int i=0;i<4;i++)
		printf("%c",s[now][i]);
	vis[now]=1;
	printf("\n");
	fflush(stdout);
	while(scanf("%d%d",&ZH,&DA)&&ZH!=4){
		C++;
		cnt=0;
		for(int i=0;i<sz;i++)
		if(!vis[i]){
			if(check(i)) {
				b[cnt++]=i;
	//			printf("%d ",i);
			}
			else vis[i]=1;
		}
		if(C>=2)work();
		else{
			now=rand()*rand()%cnt;
			now=b[now];
		}
	//	printf("\n\n");
		for(int i=0;i<4;i++)
		printf("%c",s[now][i]);
		vis[now]=1;
		printf("\n");
		fflush(stdout);
	}
}


#include<cstdio>
#include<ctime>
#include<cstdlib>
#include<cstring>
#define sz 10000
using namespace std;
int p[200],cnt,now,ZH,DA,vis[sz+10],b[sz];
int C;
char s[sz+10][5];
void make(int x){
	int tmp=x;
	int cnt=0;
	for(int i=0;i<4;i++){
		s[tmp][cnt++]=x%10+'0';
		x/=10;
	}
}
bool check(int x){
	memset(p,0,sizeof(p));
	int zh=0,da=0;
	for(int i=0;i<4;i++){
		p[s[x][i]]++;
		if(p[s[x][i]]>1) return false;
	}
	for(int i=0;i<4;i++){
		if(p[s[now][i]]) da++;
	}
	for(int i=0;i<4;i++)
		if(s[now][i]==s[x][i]) zh++,da--;
	return da==DA&&ZH==zh;
}
bool check1(int x){
	memset(p,0,sizeof(p));
	for(int i=0;i<4;i++){
		p[s[x][i]]++;
		if(p[s[x][i]]>1) return false;
	}
}
int main(){
	srand(time(0));
	for(int i=0;i<sz;i++) make(i);
	cnt=0;
	for(int i=0;i<sz;i++)
		if(!vis[i]){
			if(check1(i)) b[cnt++]=i;
			else vis[i]=1;
		}
	now=rand()*rand()%cnt;
	now=b[now];
	now=1234;
	for(int i=0;i<4;i++)
		printf("%c",s[now][i]);
	printf("\n");
	fflush(stdout);
	while(scanf("%d%d",&ZH,&DA)&&ZH!=4){
		C++;
		cnt=0;
		for(int i=0;i<sz;i++)
		if(!vis[i]){
			if(check(i)) b[cnt++]=i;
			else vis[i]=1;
		}
		now=rand()*rand()%cnt;
		now=b[now];
		if(C==1)now=8567;
		if(C==2)now=3690;
		for(int i=0;i<4;i++)
		printf("%c",s[now][i]);
		printf("\n");
		fflush(stdout);
	}
}


#include<cstdio>
#include<ctime>
#include<cstdlib>
#include<cstring>
#define sz 10000
using namespace std;
int p[200],cnt,now,ZH,DA,vis[sz+10],b[sz];
int C;
char s[sz+10][5];
void make(int x){
	int tmp=x;
	int cnt=0;
	for(int i=0;i<4;i++){
		s[tmp][cnt++]=x%10+'0';
		x/=10;
	}
}
bool check(int x){
	memset(p,0,sizeof(p));
	int zh=0,da=0;
	for(int i=0;i<4;i++){
		p[s[x][i]]++;
		if(p[s[x][i]]>1) return false;
	}
	for(int i=0;i<4;i++){
		if(p[s[now][i]]) da++;
	}
	for(int i=0;i<4;i++)
		if(s[now][i]==s[x][i]) zh++,da--;
	return da==DA&&ZH==zh;
}
bool check1(int x){
	memset(p,0,sizeof(p));
	for(int i=0;i<4;i++){
		p[s[x][i]]++;
		if(p[s[x][i]]>1) return false;
	}
}
int main(){
	srand(time(0));
	for(int i=0;i<sz;i++) make(i);
	cnt=0;
	for(int i=0;i<sz;i++)
		if(!vis[i]){
			if(check1(i)) b[cnt++]=i;
			else vis[i]=1;
		}
	now=rand()*rand()%cnt;
	now=b[now];
	now=1234;
	for(int i=0;i<4;i++)
		printf("%c",s[now][i]);
	printf("\n");
	fflush(stdout);
	while(scanf("%d%d",&ZH,&DA)&&ZH!=4){
		C++;
		cnt=0;
		for(int i=0;i<sz;i++)
		if(!vis[i]){
			if(check(i)) b[cnt++]=i;
			else vis[i]=1;//
		}
		now=rand()*rand()%cnt;
		now=b[now];
		if(C==1)now=8567;
		for(int i=0;i<4;i++)
		printf("%c",s[now][i]);
		printf("\n");
		fflush(stdout);
	}
}


#include<cstdio>
#include<ctime>
#include<cstdlib>
#include<cstring>
#define sz 10000
using namespace std;
int p[200],cnt,now,ZH,DA,vis[sz+10],b[sz];
int C;
char s[sz+10][5];
void make(int x){
	int tmp=x;
	int cnt=0;
	for(int i=0;i<4;i++){
		s[tmp][cnt++]=x%10+'0';
		x/=10;
	}
}
bool check(int x){
	memset(p,0,sizeof(p));
	int zh=0,da=0;
	for(int i=0;i<4;i++){
		p[s[x][i]]++;
		if(p[s[x][i]]>1) return false;
	}
	for(int i=0;i<4;i++){
		if(p[s[now][i]]) da++;
	}
	for(int i=0;i<4;i++)
		if(s[now][i]==s[x][i]) zh++,da--;
	return da==DA&&ZH==zh;
}
bool check1(int x){
	memset(p,0,sizeof(p));
	for(int i=0;i<4;i++){
		p[s[x][i]]++;
		if(p[s[x][i]]>1) return false;
	}
}
int main(){
	srand(time(0));
	for(int i=0;i<sz;i++) make(i);
	cnt=0;
	for(int i=0;i<sz;i++)
		if(!vis[i]){
			if(check1(i)) b[cnt++]=i;
			else vis[i]=1;
		}
	now=rand()*rand()%cnt;
	now=b[now];
	for(int i=0;i<4;i++)
		printf("%c",s[now][i]);
	printf("\n");
	fflush(stdout);
	while(scanf("%d%d",&ZH,&DA)&&ZH!=4){
		C++;
		cnt=0;
		for(int i=0;i<sz;i++)
		if(!vis[i]){
			if(check(i)) b[cnt++]=i;
			else vis[i]=1;
		}
		now=rand()*rand()%cnt;
		now=b[now];
		for(int i=0;i<4;i++)
		printf("%c",s[now][i]);
		printf("\n");///
		fflush(stdout);
	}
}


#include<cstdio>
#include<ctime>
#include<cstdlib>
#include<cstring>
#define sz 10000
using namespace std;
int p[200],cnt,now,ZH,DA,vis[sz+10],b[sz];
int C;
char s[sz+10][5];
void make(int x){
	int tmp=x;
	int cnt=0;
	for(int i=0;i<4;i++){
		s[tmp][cnt++]=x%10+'0';
		x/=10;
	}
}
bool check(int x){
	memset(p,0,sizeof(p));
	int zh=0,da=0;
	for(int i=0;i<4;i++){
		p[s[x][i]]++;
		if(p[s[x][i]]>1) return false;
	}
	for(int i=0;i<4;i++){
		if(p[s[now][i]]) da++;
	}
	for(int i=0;i<4;i++)
		if(s[now][i]==s[x][i]) zh++,da--;
	return da==DA&&ZH==zh;
}
bool check1(int x){
	memset(p,0,sizeof(p));
	for(int i=0;i<4;i++){
		p[s[x][i]]++;
		if(p[s[x][i]]>1) return false;
	}
}
int main(){
	srand(time(0));
	for(int i=0;i<sz;i++) make(i);
	cnt=0;
	for(int i=0;i<sz;i++)
		if(!vis[i]){
			if(check1(i)) b[cnt++]=i;
			else vis[i]=1;
		}
	now=rand()*rand()%cnt;
	now=b[now];
	now=1234;
	for(int i=0;i<4;i++)
		printf("%c",s[now][i]);
	printf("\n");
	fflush(stdout);
	while(scanf("%d%d",&ZH,&DA)&&ZH!=4){//
		C++;
		cnt=0;
		for(int i=0;i<sz;i++)
		if(!vis[i]){
			if(check(i)) b[cnt++]=i;//
			else vis[i]=1;
		}
		now=rand()*rand()%cnt;
		now=b[now];
		if(C==1)now=8567;
		for(int i=0;i<4;i++)
		printf("%c",s[now][i]);
		printf("\n");
		fflush(stdout);
	}
}


#include<cstdio>
#include<ctime>
#include<cstdlib>
#include<cstring>
#define sz 10000
using namespace std;
int p[200],cnt,now,ZH,DA,vis[sz+10],b[sz];
int C;
char s[sz+10][5];
void make(int x){////
	int tmp=x;
	int cnt=0;
	for(int i=0;i<4;i++){
		s[tmp][cnt++]=x%10+'0';
		x/=10;
	}
}
bool check(int x){
	memset(p,0,sizeof(p));
	int zh=0,da=0;
	for(int i=0;i<4;i++){
		p[s[x][i]]++;
		if(p[s[x][i]]>1) return false;
	}
	for(int i=0;i<4;i++){
		if(p[s[now][i]]) da++;
	}
	for(int i=0;i<4;i++)
		if(s[now][i]==s[x][i]) zh++,da--;
	return da==DA&&ZH==zh;
}
bool check1(int x){
	memset(p,0,sizeof(p));
	for(int i=0;i<4;i++){
		p[s[x][i]]++;
		if(p[s[x][i]]>1) return false;
	}
}
int main(){
	srand(time(0));
	for(int i=0;i<sz;i++) make(i);
	cnt=0;
	for(int i=0;i<sz;i++)
		if(!vis[i]){
			if(check1(i)) b[cnt++]=i;
			else vis[i]=1;
		}
	now=rand()*rand()%cnt;
	now=b[now];
	now=1234;
	for(int i=0;i<4;i++)
		printf("%c",s[now][i]);
	printf("\n");
	fflush(stdout);
	while(scanf("%d%d",&ZH,&DA)&&ZH!=4){
		C++;
		cnt=0;////
		for(int i=0;i<sz;i++)
		if(!vis[i]){
			if(check(i)) b[cnt++]=i;
			else vis[i]=1;
		}
		now=rand()*rand()%cnt;
		now=b[now];
		if(C==1)now=8567;
		for(int i=0;i<4;i++)
		printf("%c",s[now][i]);
		printf("\n");
		fflush(stdout);
	}
}


#include<cstdio>
#include<ctime>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#define sz 10000
using namespace std;
int p[200],cnt,now,ZH,DA,vis[sz+10],b[sz],C;
char s[sz+10][5];
struct he{
	int zh,da,p;
}c[sz];
void make(int x){
	int tmp=x;
	int cnt=0;
	for(int i=0;i<4;i++){
		s[tmp][3-cnt]=x%10+'0';
		cnt++;
		x/=10;
	}
}
bool check(int x){
	memset(p,0,sizeof(p));
	int zh=0,da=0;
	for(int i=0;i<4;i++){
		p[s[x][i]]++;
		if(p[s[x][i]]>1) return false;
	}
	for(int i=0;i<4;i++){
		if(p[s[now][i]]) da++;
	}
	for(int i=0;i<4;i++)
		if(s[now][i]==s[x][i]) zh++,da--;
	return da==DA&&ZH==zh;
}
bool check1(int x){
	memset(p,0,sizeof(p));
	for(int i=0;i<4;i++){
		p[s[x][i]]++;
		if(p[s[x][i]]>1) return false;
	}
}
void work1(int now,int x){
	memset(p,0,sizeof(p));
	int zh=0,da=0;
	for(int i=0;i<4;i++){
		p[s[x][i]]++;
	}
	for(int i=0;i<4;i++){
		if(p[s[now][i]]) da++;
	}
	for(int i=0;i<4;i++)
		if(s[now][i]==s[x][i]) zh++,da--;
	c[x].zh+=zh;c[x].da+=da;
}
bool cmp(he a,he b){
	if(a.zh+a.da==b.zh+b.da){
		return a.zh>b.zh;
	}
	return a.zh+a.da>b.zh+b.da;
}
void work(){
	for(int i=0;i<cnt;i++) c[i].zh=c[i].da=0,c[i].p=i;
	for(int i=0;i<cnt;i++){
		for(int j=0;j<cnt;j++)
			work1(b[i],b[j]);
	}
	sort(c,c+cnt,cmp);
	now=b[c[0].p];
}
int main(){
	srand(time(0));
	for(int i=0;i<sz;i++) make(i);
	cnt=0;
//	printf("\n\n");
	for(int i=0;i<sz;i++)
		if(!vis[i]){
			if(check1(i)) b[cnt++]=i;
			else vis[i]=1;
		}
	now=rand()*rand()%cnt;
	now=b[now];
//	printf("%d\n",now);
	for(int i=0;i<4;i++)
		printf("%c",s[now][i]);
	vis[now]=1;
	printf("\n");
	fflush(stdout);
	while(scanf("%d%d",&ZH,&DA)&&ZH!=4){
		C++;
		cnt=0;
		for(int i=0;i<sz;i++)
		if(!vis[i]){
			if(check(i)) {
				b[cnt++]=i;
				//printf("%d ",i);
			}
			else vis[i]=1;
		}
		if(C>=2)work();
		else{
			now=rand()*rand()%cnt;
			now=b[now];
		}
	//	printf("\n\n");
		for(int i=0;i<4;i++)
		printf("%c",s[now][i]);
		vis[now]=1;
		printf("\n");
		fflush(stdout);
	}
}


#include<cstdio>
#include<ctime>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#define sz 10000
using namespace std;
int p[200],cnt,now,ZH,DA,vis[sz+10],b[sz],C;
char s[sz+10][5];
struct he{
	int zh,da,p;
}c[sz];
void make(int x){
	int tmp=x;
	int cnt=0;
	for(int i=0;i<4;i++){
		s[tmp][3-cnt]=x%10+'0';
		cnt++;
		x/=10;
	}
}
bool check(int x){
	memset(p,0,sizeof(p));
	int zh=0,da=0;
	for(int i=0;i<4;i++){
		p[s[x][i]]++;
		if(p[s[x][i]]>1) return false;
	}
	for(int i=0;i<4;i++){
		if(p[s[now][i]]) da++;
	}
	for(int i=0;i<4;i++)
		if(s[now][i]==s[x][i]) zh++,da--;
	return da==DA&&ZH==zh;
}
bool check1(int x){
	memset(p,0,sizeof(p));
	for(int i=0;i<4;i++){
		p[s[x][i]]++;
		if(p[s[x][i]]>1) return false;
	}
}
void work1(int p1,int now,int x){
	memset(p,0,sizeof(p));
	int zh=0,da=0;
	for(int i=0;i<4;i++){
		p[s[x][i]]++;
	}
	for(int i=0;i<4;i++){
		if(p[s[now][i]]) da++;
	}
	for(int i=0;i<4;i++)
		if(s[now][i]==s[x][i]) zh++,da--;
	c[p1].zh+=zh;c[p1].da+=da;
}
bool cmp(he a,he b){
	if(a.zh+a.da==b.zh+b.da){
		return a.zh>b.zh;
	}
	return a.zh+a.da>b.zh+b.da;
}
void work(){
	for(int i=0;i<cnt;i++) c[i].zh=c[i].da=0,c[i].p=i;
	for(int i=0;i<cnt;i++){
		for(int j=0;j<cnt;j++)
			work1(i,b[i],b[j]);
	}
	sort(c,c+cnt,cmp);
//	for(int i=0;i<cnt;i++) printf("%d %d %d\n",c[i].zh,c[i].da,b[c[i].p]);
	now=b[c[0].p];
//	printf("%d\n",now);
}
int main(){
	srand(time(0));
	for(int i=0;i<sz;i++) make(i);
	cnt=0;
//	printf("\n\n");
	for(int i=0;i<sz;i++)
		if(!vis[i]){
			if(check1(i)) b[cnt++]=i;
			else vis[i]=1;
		}
	now=rand()*rand()%cnt;
	now=b[now];
//	printf("%d\n",now);
	for(int i=0;i<4;i++)
		printf("%c",s[now][i]);
	vis[now]=1;
	printf("\n");
	fflush(stdout);
	while(scanf("%d%d",&ZH,&DA)&&ZH!=4){
		C++;
		cnt=0;
		for(int i=0;i<sz;i++)
		if(!vis[i]){
			if(check(i)) {
				b[cnt++]=i;
	//			printf("%d ",i);
			}
			else vis[i]=1;
		}
		if(C>=2)work();
		else{
			now=rand()*rand()%cnt;
			now=b[now];
		}
	//	printf("\n\n");
		for(int i=0;i<4;i++)
		printf("%c",s[now][i]);
		vis[now]=1;
		printf("\n");
		fflush(stdout);
	}
}


#include<cstdio>
#include<ctime>
#include<cstdlib>
#include<cstring>
#define sz 10000
using namespace std;
int p[200],cnt,now,ZH,DA,vis[sz+10],b[sz];
int C;
char s[sz+10][5];
void make(int x){
	int tmp=x;
	int cnt=0;
	for(int i=0;i<4;i++){
		s[tmp][cnt++]=x%10+'0';
		x/=10;
	}
}
bool check(int x){
	memset(p,0,sizeof(p));
	int zh=0,da=0;
	for(int i=0;i<4;i++){
		p[s[x][i]]++;
		if(p[s[x][i]]>1) return false;
	}
	for(int i=0;i<4;i++){
		if(p[s[now][i]]) da++;
	}
	for(int i=0;i<4;i++)
		if(s[now][i]==s[x][i]) zh++,da--;
	return da==DA&&ZH==zh;
}
bool check1(int x){
	memset(p,0,sizeof(p));
	for(int i=0;i<4;i++){
		p[s[x][i]]++;
		if(p[s[x][i]]>1) return false;
	}
}
int main(){
	srand(time(0));
	for(int i=0;i<sz;i++) make(i);
	cnt=0;
	for(int i=0;i<sz;i++)
		if(!vis[i]){
			if(check1(i)) b[cnt++]=i;
			else vis[i]=1;
		}
	now=rand()*rand()%cnt;
	now=b[now];
	now=1234;
	for(int i=0;i<4;i++)
		printf("%c",s[now][i]);
	printf("\n");
	fflush(stdout);
	while(scanf("%d%d",&ZH,&DA)&&ZH!=4){
		C++;
		cnt=0;
		for(int i=0;i<sz;i++)
		if(!vis[i]){
			if(check(i)) b[cnt++]=i;
			else vis[i]=1;
		}
		now=rand()*rand()%cnt;
		now=b[now];
		if(C==1)now=8567;
		for(int i=0;i<4;i++)
		printf("%c",s[now][i]);
		printf("\n");
		fflush(stdout);
	}
}


#include<cstdio>
#include<ctime>
#include<cstdlib>
#include<cstring>
#define sz 10000
using namespace std;
int p[200],cnt,now,ZH,DA,vis[sz+10],b[sz];
int C;
char s[sz+10][5];
void make(int x){
	int tmp=x;
	int cnt=0;
	for(int i=0;i<4;i++){
		s[tmp][cnt++]=x%10+'0';
		x/=10;
	}
}
bool check(int x){
	memset(p,0,sizeof(p));
	int zh=0,da=0;
	for(int i=0;i<4;i++){
		p[s[x][i]]++;
		if(p[s[x][i]]>1) return false;
	}
	for(int i=0;i<4;i++){
		if(p[s[now][i]]) da++;
	}
	for(int i=0;i<4;i++)
		if(s[now][i]==s[x][i]) zh++,da--;
	return da==DA&&ZH==zh;
}
bool check1(int x){
	memset(p,0,sizeof(p));
	for(int i=0;i<4;i++){
		p[s[x][i]]++;
		if(p[s[x][i]]>1) return false;
	}
}
int main(){
	srand(time(0));
	for(int i=0;i<sz;i++) make(i);
	cnt=0;
	for(int i=0;i<sz;i++)
		if(!vis[i]){
			if(check1(i)) b[cnt++]=i;
			else vis[i]=1;
		}
	now=rand()*rand()%cnt;
	now=b[now];
	now=0123;
	for(int i=0;i<4;i++)
		printf("%c",s[now][i]);
	printf("\n");
	fflush(stdout);
	while(scanf("%d%d",&ZH,&DA)&&ZH!=4){
		C++;
		cnt=0;
		for(int i=0;i<sz;i++)
		if(!vis[i]){
			if(check(i)) b[cnt++]=i;
			else vis[i]=1;
		}
		now=rand()*rand()%cnt;
		now=b[now];
		if(C==1)now=4567;
		for(int i=0;i<4;i++)
		printf("%c",s[now][i]);//
		printf("\n");
		fflush(stdout);
	}
}


#include<cstdio>
#include<ctime>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#define sz 10000
using namespace std;
int p[200],cnt,now,ZH,DA,vis[sz+10],b[sz],C;
char s[sz+10][5];
struct he{
	int zh,da,p,d;
	int a[5][5];
}c[sz];
void make(int x){
	int tmp=x;
	int cnt=0;
	for(int i=0;i<4;i++){
		s[tmp][3-cnt]=x%10+'0';
		cnt++;
		x/=10;
	}
}
bool check(int x){
	memset(p,0,sizeof(p));
	int zh=0,da=0;
	for(int i=0;i<4;i++){
		p[s[x][i]]++;
		if(p[s[x][i]]>1) return false;
	}
	for(int i=0;i<4;i++){
		if(p[s[now][i]]) da++;
	}
	for(int i=0;i<4;i++)
		if(s[now][i]==s[x][i]) zh++,da--;
	return da==DA&&ZH==zh;
}
bool check1(int x){
	memset(p,0,sizeof(p));
	for(int i=0;i<4;i++){
		p[s[x][i]]++;
		if(p[s[x][i]]>1) return false;
	}
}
void work1(int p1,int now,int x){
	for(int i='0';i<='9';i++) p[i]=0;
	int zh=0,da=0;
	for(int i=0;i<4;i++){
		p[s[x][i]]++;
	}
	for(int i=0;i<4;i++){
		if(p[s[now][i]]) da++;
	}
	for(int i=0;i<4;i++)
		if(s[now][i]==s[x][i]) zh++,da--;
	c[p1].a[zh][da]++;
}
void work(){
	for(int i=0;i<cnt;i++) c[i].zh=c[i].da=0,c[i].p=i;
	for(int i=0;i<cnt;i++){
		for(int j=0;j<cnt;j++)
			work1(i,b[i],b[j]);
	}
	int pos;
	int mn=1e7;
	for(int i=0;i<cnt;i++){
		int mx=-1;
		for(int o1=0;o1<=4;o1++)
			for(int o2=0;o2<=4;o2++)
				mx=max(mx,c[i].a[o1][o2]);
		if(mx<mn) {
			mn=mx;pos=i;
		}
	}
	//sort(c,c+cnt,cmp1);
//	for(int i=0;i<cnt;i++) printf("%d %d %d\n",c[i].zh,c[i].da,b[c[i].p]);
	now=b[pos];
//	printf("%d\n",now);
}
int main(){
	srand(time(0));
	for(int i=0;i<sz;i++) make(i);
	cnt=0;
//	printf("\n\n");
	for(int i=0;i<sz;i++)
		if(!vis[i]){
			if(check1(i)) b[cnt++]=i;
			else vis[i]=1;
		}
	now=rand()*rand()%cnt;
	now=b[now];
//	printf("%d\n",now);
	for(int i=0;i<4;i++)
		printf("%c",s[now][i]);
	vis[now]=1;
	printf("\n");
	fflush(stdout);
	while(scanf("%d%d",&ZH,&DA)&&ZH!=4){
		C++;
		cnt=0;
		for(int i=0;i<sz;i++)
		if(!vis[i]){
			if(check(i)) {
				b[cnt++]=i;
	//			printf("%d ",i);
			}
			else vis[i]=1;
		}
		work();
	//	printf("\n\n");
		for(int i=0;i<4;i++)
		printf("%c",s[now][i]);
		vis[now]=1;
		printf("\n");
		fflush(stdout);
	}
}


#include<cstdio>
#include<ctime>
#include<cstdlib>
#include<cstring>
#define sz 10000
using namespace std;
int p[200],cnt,now,ZH,DA,vis[sz+10],b[sz];
int C;
char s[sz+10][5];
void make(int x){
	int tmp=x;
	int cnt=0;
	for(int i=0;i<4;i++){
		s[tmp][cnt++]=x%10+'0';
		x/=10;
	}
}
bool check(int x){
	memset(p,0,sizeof(p));
	int zh=0,da=0;
	for(int i=0;i<4;i++){
		p[s[x][i]]++;
		if(p[s[x][i]]>1) return false;
	}
	for(int i=0;i<4;i++){
		if(p[s[now][i]]) da++;
	}
	for(int i=0;i<4;i++)
		if(s[now][i]==s[x][i]) zh++,da--;
	return da==DA&&ZH==zh;
}
bool check1(int x){
	memset(p,0,sizeof(p));
	for(int i=0;i<4;i++){
		p[s[x][i]]++;
		if(p[s[x][i]]>1) return false;
	}
}
int main(){
	srand(time(0));
	for(int i=0;i<sz;i++) make(i);
	cnt=0;
	for(int i=0;i<sz;i++)
		if(!vis[i]){
			if(check1(i)) b[cnt++]=i;
			else vis[i]=1;
		}
	now=rand()*rand()%cnt;
	now=b[now];
	for(int i=0;i<4;i++)
		printf("%c",s[now][i]);
	printf("\n");
	fflush(stdout);
	while(scanf("%d%d",&ZH,&DA)&&ZH!=4){
		C++;
		cnt=0;
		for(int i=0;i<sz;i++)
		if(!vis[i]){
			if(check(i)) b[cnt++]=i;
			else vis[i]=1;
		}
		now=rand()*rand()%cnt;
		now=b[now];
		for(int i=0;i<4;i++)
		printf("%c",s[now][i]);
		printf("\n");
		fflush(stdout);
	}
}


#include<cstdio>
#include<ctime>
#include<cstdlib>
#include<cstring>
#define sz 10000
using namespace std;
int p[200],cnt,now,ZH,DA,vis[sz+10],b[sz];
int C;
char s[sz+10][5];
void make(int x){
	int tmp=x;
	int cnt=0;
	for(int i=0;i<4;i++){
		s[tmp][cnt++]=x%10+'0';
		x/=10;
	}
}
bool check(int x){
	memset(p,0,sizeof(p));
	int zh=0,da=0;
	for(int i=0;i<4;i++){
		p[s[x][i]]++;
		if(p[s[x][i]]>1) return false;
	}
	for(int i=0;i<4;i++){
		if(p[s[now][i]]) da++;
	}
	for(int i=0;i<4;i++)
		if(s[now][i]==s[x][i]) zh++,da--;
	return da==DA&&ZH==zh;
}
bool check1(int x){
	memset(p,0,sizeof(p));
	for(int i=0;i<4;i++){
		p[s[x][i]]++;
		if(p[s[x][i]]>1) return false;
	}
}
int main(){
	srand(time(0));
	for(int i=0;i<sz;i++) make(i);
	cnt=0;
	for(int i=0;i<sz;i++)
		if(!vis[i]){
			if(check1(i)) b[cnt++]=i;
			else vis[i]=1;
		}
	now=rand()*rand()%cnt;
	now=b[now];
	for(int i=0;i<4;i++)
		printf("%c",s[now][i]);////
	printf("\n");
	fflush(stdout);
	while(scanf("%d%d",&ZH,&DA)&&ZH!=4){
		C++;
		cnt=0;
		for(int i=0;i<sz;i++)
		if(!vis[i]){
			if(check(i)) b[cnt++]=i;
			else vis[i]=1;
		}
		now=rand()*rand()%cnt;
		now=b[now];
		for(int i=0;i<4;i++)
		printf("%c",s[now][i]);
		printf("\n");
		fflush(stdout);
	}
}


/*mohammadreza motabar*/
#include<bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define ll long long
#define pb push_back
typedef pair<int,int> pii;
typedef pair<long long int,long long int> pll;
const int MAX_N = 1e5+10 , INF = 1e8;
vector<pii> s;
bool mark[MAX_N];
int barabar(int a,int b){
	int ret=0,temp=0;
	int aa=a,bb=b;
	while(temp<4){
		if(aa%10==bb%10){
			ret++;
		}
		aa/=10;
		bb/=10;
		temp++;
	}
	return ret;
}
int jay(int a,int b){
	int ta[10],tb[10],aa=a,bb=b,ret=0,temp=0;
	memset(ta,0,sizeof ta);
	memset(tb,0,sizeof tb);
	while(temp<4){
		if(aa%10!=bb%10){
			ta[aa%10]++;
			tb[bb%10]++;
		}
		aa/=10;
		bb/=10;
		temp++;
	}
	for(int i=0;i<=9;i++){
		ret+=min(ta[i],tb[i]);
	}
	return ret;
}
int arzesh(int v){
	int ret=0,x,y;
	int vc[5][5];
	for(int i=0;i<s.size();i++){
		if(!mark[i]){
			x=barabar(s[i].second,v);
			y=jay(s[i].second,v);
			vc[x][y]++;
			ret=max(ret,vc[x][y]);
		}
	}
	return ret;
}
int upd(){
	int ret=s.size()-1;
	int t=300;
	while(t--){
		int r=rand()%s.size();
		if(!mark[r]){
			s[r].first=arzesh(s[r].second);
			if(s[r].first<s[ret].first){
				ret=r;
			}
		}
		else{
			t++;
		}
	}
	/*int t=0;
	for(int i=0;i<s.size() && t<7;i++){
		if(!mark[i]){
			s[i].first=arzesh(s[i].second);
			if(s[i].first<s[ret].first){
				ret=i;
			}
			t++;
		}
	}*/
	return ret;
}
void print(int v){
	if(v<10){
		cout<<0<<0<<0<<v<<endl;
	}
	else if(v<100){
		cout<<0<<0<<v<<endl;
	}
	else if(v<1000){
		cout<<0<<v<<endl;
	}
	else{
		cout<<v<<endl;
	}
}
void hazf(int v,int x,int y){
	for(int i=0;i<s.size();i++){
		if(!mark[i]){
			if(barabar(v,s[i].second)!=x || jay(v,s[i].second)!=y){
				mark[i]=1;
			}
		}
	}
}
bool mot(int v){
	int t[10+1],temp=0;
	memset(t,0,sizeof t);
	while(temp<4){
		t[v%10]++;
		v/=10;
		temp++;
	}
	for(int i=0;i<=9;i++){
		if(t[i]>1) return 0;
	}
	return 1;
}
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    srand(time(0));
    for(int i=0;i<=9999;i++){
    	if(mot(i)){
    		s.pb({0,i});
		}
	}
	s.pb({INF,10000});
	while(1){
		int x,y;
		int ind=upd();
		print(s[ind].second);
		cin>>x>>y;
		if(x==4) break;
		hazf(s[ind].second,x,y);
	}
}


/*mohammadreza motabar*/
#include<bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define ll long long
#define pb push_back
typedef pair<int,int> pii;
typedef pair<long long int,long long int> pll;
const ll MAX_N = 1e5+10 , INF = 1e9;
vector<pii> s;
bool mark[MAX_N];
int barabar(int a,int b){
	int ret=0,temp=0;
	int aa=a,bb=b;
	while(temp<4){
		if(aa%10==bb%10){
			ret++;
		}
		aa/=10;
		bb/=10;
		temp++;
	}
	return ret;
}
int jay(int a,int b){
	int ta[10],tb[10],aa=a,bb=b,ret=0,temp=0;
	memset(ta,0,sizeof ta);
	memset(tb,0,sizeof tb);
	while(temp<4){
		if(aa%10!=bb%10){
			ta[aa%10]++;
			tb[bb%10]++;
		}
		aa/=10;
		bb/=10;
		temp++;
	}
	for(int i=0;i<=9;i++){
		ret+=min(ta[i],tb[i]);
	}
	return ret;
}
int arzesh(int v){
	int ret=0,x,y;
	int vc[5][5];
	for(int i=0;i<s.size();i++){
		if(!mark[i]){
			x=barabar(s[i].second,v);
			y=jay(s[i].second,v);
			vc[x][y]++;
			ret=max(ret,vc[x][y]);
		}
	}
	return ret;
}
void upd(){
	int t=286;
	for(int i=0;i<t;i++){
		int r=rand()%s.size();
		if(!mark[r]){
			s[r].first=arzesh(s[r].second);
		}
		else{
			t++;
		}
	}
}
void print(int v){
	if(v<10){
		cout<<0<<0<<0<<v<<endl;
	}
	else if(v<100){
		cout<<0<<0<<v<<endl;
	}
	else if(v<1000){
		cout<<0<<v<<endl;
	}
	else{
		cout<<v<<endl;
	}
}
void hazf(int v,int x,int y){
	for(int i=0;i<s.size();i++){
		if(!mark[i]){
			if(barabar(v,s[i].second)!=x || jay(v,s[i].second)!=y){
				mark[i]=1;
			}
		}
	}
}
bool mot(int v){
	int t[10+1],temp=0;
	memset(t,0,sizeof t);
	while(temp<4){
		t[v%10]++;
		v/=10;
		temp++;
	}
	for(int i=0;i<=9;i++){
		if(t[i]>1) return 0;
	}
	return 1;
}
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    srand(time(0));
    for(int i=0;i<=9999;i++){
    	if(mot(i)){
    		s.pb({0,i});
		}
	}
	s.pb({INF,10000});
	while(1){
		int x,y;
		upd();
		int ind=s.size()-1;
		for(int i=0;i<s.size();i++){
			if(!mark[i] && s[i].first<s[ind].first){
				ind=i;
			}
		}
		print(s[ind].second);
		cin>>x>>y;
		if(x==4) break;
		hazf(s[ind].second,x,y);
	}
}


	// Author : Saumitra Tripathi
	#include<bits/stdc++.h>
	using namespace std;
	typedef long long ll;
	typedef unsigned long long ull;
	#define all(v) v.begin(),v.end()
	#define pb push_back
	#define m_p make_pair
	#define f first
	#define s second
	vector <ll> adj[100010];
	ll level[100010];
	ll visited[100010];
	void dfs(ll p)
	{
		visited[p]=1;
		for(int i=0;i<adj[p].size();i++)
		{
			if(!visited[adj[p][i]])
			{
				level[adj[p][i]]=level[p]+1;
				dfs(adj[p][i]);
			}
		}
	}
	void solve()
	{
		ll n,a,b,da,db,x,y,sum,f=0;
		cin>>n>>a>>b>>da>>db;
		for(int i=1;i<=n;i++)
			visited[i]=0;
		for(int i=1;i<=n-1;i++)
		{
			cin>>x>>y;
			adj[x].pb(y);   adj[y].pb(x);
		}
		level[a]=1;
		dfs(a);
		vector <ll> v;
		for(int i=1;i<=n;i++)
		{
			if(adj[i].size()==1 && i!=a)
				v.pb(level[i]-1);
		}
		sort(all(v),greater <ll>());
		if(v.size()==1) sum=v[0];
		else 			sum=v[0]+v[1];
		if(da>=level[b]-level[a])	f=1;
		if(sum<db)					f=1;
		if(db<=2*da)				f=1;
		if(f)	cout<<"Alice\n";
		else 	cout<<"Bob\n";
		v.clear();
		for(int i=1;i<=n;i++)
			visited[i]=0;
		for(int i=1;i<=n;i++)
			adj[i].clear();
	}
	int main()
	{
		ios_base::sync_with_stdio(false);
		cin.tie(NULL);
		cout.tie(NULL);
		#ifndef ONLINE_JUDGE
	    	freopen("/home/ubuntu/.config/sublime-text-3/Packages/User/input.txt", "r", stdin);
	     	freopen("/home/ubuntu/.config/sublime-text-3/Packages/User/output.txt", "w", stdout);
		#endif

		int t;
		cin>>t;
		while(t--)
			solve();
	}


	// Author : Saumitra Tripathi
	#include<bits/stdc++.h>
	using namespace std;
	typedef long long ll;
	typedef unsigned long long ull;
	#define all(v) v.begin(),v.end()
	#define pb push_back
	#define m_p make_pair
	#define f first
	#define s second
	vector <ll> adj[100010];
	ll level[100010];
	ll visited[100010];
	void dfs(ll p)
	{
		visited[p]=1;
		for(int i=0;i<adj[p].size();i++)
		{
			if(!visited[adj[p][i]])
			{
				level[adj[p][i]]=level[p]+1;
				dfs(adj[p][i]);
			}
		}
	}
	void solve()
	{
		ll n,a,b,da,db,x,y,sum,f=0;
		cin>>n>>a>>b>>da>>db;
		for(int i=1;i<=n;i++)
			visited[i]=0;
		for(int i=1;i<=n-1;i++)
		{
			cin>>x>>y;
			adj[x].pb(y);   adj[y].pb(x);
		}
		level[a]=1;
		dfs(a);
		vector <ll> v;
		for(int i=1;i<=n;i++)
		{
			if(adj[i].size()==1 && i!=a)
				v.pb(level[i]-1);
		}
		sort(all(v),greater <ll>());
		if(adj[a].size()==1) sum=v[0];
		else 			sum=v[0]+v[1];
		if(da>=level[b]-level[a])	f=1;
		if(sum<db)					f=1;
		if(db<=2*da)				f=1;
		// cout<<sum<<"\n";

		if(f)	cout<<"Alice\n";
		else 	cout<<"Bob\n";
		v.clear();
		for(int i=1;i<=n;i++)
			visited[i]=0;
		for(int i=1;i<=n;i++)
			adj[i].clear();
	}
	int main()
	{
		ios_base::sync_with_stdio(false);
		cin.tie(NULL);
		cout.tie(NULL);
		#ifndef ONLINE_JUDGE
	    	freopen("/home/ubuntu/.config/sublime-text-3/Packages/User/input.txt", "r", stdin);
	     	freopen("/home/ubuntu/.config/sublime-text-3/Packages/User/output.txt", "w", stdout);
		#endif

		int t;
		cin>>t;
		while(t--)
			solve();
	}


	// Author : Saumitra Tripathi
	#include<bits/stdc++.h>
	using namespace std;
	typedef long long ll;
	typedef unsigned long long ull;
	#define all(v) v.begin(),v.end()
	#define pb push_back
	#define m_p make_pair
	#define f first
	#define s second
	vector <ll> adj[100010];
	ll level[100010];
	ll visited[100010];
	void dfs(ll p)
	{
		visited[p]=1;
		for(int i=0;i<adj[p].size();i++)
		{
			if(!visited[adj[p][i]])
			{
				level[adj[p][i]]=level[p]+1;
				dfs(adj[p][i]);
			}
		}
	}
	void solve()
	{
		ll n,a,b,da,db,x,y,sum,f=0;
		cin>>n>>a>>b>>da>>db;
		for(int i=0;i<100010;i++)
			visited[i]=0;
		for(int i=1;i<=n-1;i++)
		{
			cin>>x>>y;
			adj[x].pb(y);   adj[y].pb(x);
		}
		level[a]=1;
		dfs(a);
		vector <ll> v;
		for(int i=1;i<=n;i++)
		{
			if(adj[i].size()==1 && i!=a)
				v.pb(level[i]-1);
		}
		sort(all(v),greater <ll>());
		if(v.size()==1) sum=v[0];
		else 			sum=v[0]+v[1];
		if(da>=level[b]-level[a])	f=1;
		if(sum<db)					f=1;
		if(db<=2*da)				f=1;
		if(f)	cout<<"Alice\n";
		else 	cout<<"Bob\n";
		v.clear();
		for(int i=0;i<100010;i++)
			visited[i]=0;
		for(int i=0;i<100010;i++)
			adj[i].clear();
	}
	int main()
	{
		ios_base::sync_with_stdio(false);
		cin.tie(NULL);
		cout.tie(NULL);
		#ifndef ONLINE_JUDGE
	    	freopen("/home/ubuntu/.config/sublime-text-3/Packages/User/input.txt", "r", stdin);
	     	freopen("/home/ubuntu/.config/sublime-text-3/Packages/User/output.txt", "w", stdout);
		#endif

		int t;
		cin>>t;
		while(t--)
			solve();
	}


// Author : Saumitra Tripathi
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define all(v) v.begin(),v.end()
#define pb push_back
#define m_p make_pair
#define f first
#define s second
vector <ll> adj[100010];
ll level[100010];
ll visited[100010];
ll maxm;
int x;
void dfs(ll p)
{
	visited[p]=1;
	for(int i=0;i<adj[p].size();i++)
	{
		if(!visited[adj[p][i]])
		{
			level[adj[p][i]]=level[p]+1;
			dfs(adj[p][i]);
		}

	}
}
void dfs1(ll p,ll count1)
{
	visited[p]=1;
	count1++;
	for(int i=0;i<adj[p].size();i++)
	{
		if(!visited[adj[p][i]])
		{
			if(count1>maxm)
			{
				maxm=count1;
				x=adj[p][i];
			}
			dfs1(adj[p][i],count1);
		}
	}
}
void solve()
{
	ll n,a,b,da,db,x1,y1,sum,f=0;
	cin>>n>>a>>b>>da>>db;
	maxm=INT_MIN;
	for(int i=1;i<=n;i++)
		visited[i]=0;
	for(int i=1;i<=n-1;i++)
	{
		cin>>x1>>y1;
		adj[x1].pb(y1);   adj[y1].pb(x1);
	}
	level[a]=1;
	dfs(a);
	for(int i=1;i<=n;i++)	visited[i]=0;
	dfs1(1,0);
	for(int i=1;i<=n;i++)	visited[i]=0;
	dfs1(x,0);
	sum=maxm;
	if(da>=level[b]-level[a])	f=1;
	if(sum<db)					f=1;
	if(db<=2*da)				f=1;
	// cout<<sum<<"\n";
	if(f)	cout<<"Alice\n";
	else 	cout<<"Bob\n";
	for(int i=1;i<=n;i++)	visited[i]=0;
	for(int i=1;i<=n;i++)	adj[i].clear();
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	#ifndef ONLINE_JUDGE
	    freopen("/home/ubuntu/.config/sublime-text-3/Packages/User/input.txt", "r", stdin);
	     freopen("/home/ubuntu/.config/sublime-text-3/Packages/User/output.txt", "w", stdout);
	#endif

	int t;
	cin>>t;
	while(t--)
		solve();
}


// Author : Saumitra Tripathi
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define all(v) v.begin(),v.end()
#define pb push_back
#define m_p make_pair
#define f first
#define s second
vector <ll> adj[100010];
ll level[100010];
ll visited[100010];
ll maxm;
int x;
void dfs(ll p)
{
	visited[p]=1;
	for(int i=0;i<adj[p].size();i++)
	{
		if(!visited[adj[p][i]])
		{
			level[adj[p][i]]=level[p]+1;
			dfs(adj[p][i]);
		}

	}
}
void dfs1(ll p,ll count1)
{
	visited[p]=1;
	count1++;
	for(int i=0;i<adj[p].size();i++)
	{
		if(!visited[adj[p][i]])
		{
			if(count1>maxm)
			{
				maxm=count1;
				x=adj[p][i];
			}
			dfs1(adj[p][i],count1);
		}
	}
}
void solve()
{
	ll n,a,b,da,db,x,y,sum,f=0;
	cin>>n>>a>>b>>da>>db;
	for(int i=1;i<=n;i++)
		visited[i]=0;
	for(int i=1;i<=n-1;i++)
	{
		cin>>x>>y;
		adj[x].pb(y);   adj[y].pb(x);
	}
	level[a]=1;
	dfs(a);
	for(int i=1;i<=n;i++)	visited[i]=0;
	dfs1(1,0);
	for(int i=1;i<=n;i++)	visited[i]=0;
	dfs1(x,0);
	sum=maxm;
	if(da>=level[b]-level[a])	f=1;
	if(sum<db)					f=1;
	if(db<=2*da)				f=1;
	// cout<<sum<<"\n";
	if(f)	cout<<"Alice\n";
	else 	cout<<"Bob\n";
	for(int i=1;i<=n;i++)	visited[i]=0;
	for(int i=1;i<=n;i++)	adj[i].clear();
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	#ifndef ONLINE_JUDGE
	    freopen("/home/ubuntu/.config/sublime-text-3/Packages/User/input.txt", "r", stdin);
	     freopen("/home/ubuntu/.config/sublime-text-3/Packages/User/output.txt", "w", stdout);
	#endif

	int t;
	cin>>t;
	while(t--)
		solve();
}


// Author : Saumitra Tripathi
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define all(v) v.begin(),v.end()
#define pb push_back
#define m_p make_pair
#define f first
#define s second
vector <ll> adj[100010];
ll level[100010];
ll visited[100010];
ll maxm;
int x;
void dfs(ll p)
{
	visited[p]=1;
	for(int i=0;i<adj[p].size();i++)
	{
		if(!visited[adj[p][i]])
		{
			level[adj[p][i]]=level[p]+1;
			dfs(adj[p][i]);
		}

	}
}
void dfs1(ll p,ll count1)
{
	visited[p]=1;
	count1++;
	for(int i=0;i<adj[p].size();i++)
	{
		if(!visited[adj[p][i]])
		{
			if(count1>maxm)
			{
				maxm=count1;
				x=adj[p][i];
			}
			dfs1(adj[p][i],count1);
		}
	}
}
void solve()
{
	ll n,a,b,da,db,x1,y1,sum,f=0;
	cin>>n>>a>>b>>da>>db;
	for(int i=1;i<=n;i++)
		visited[i]=0;
	for(int i=1;i<=n-1;i++)
	{
		cin>>x1>>y1;
		adj[x1].pb(y1);   adj[y1].pb(x1);
	}
	level[a]=1;
	dfs(a);
	for(int i=1;i<=n;i++)	visited[i]=0;
	dfs1(1,0);
	for(int i=1;i<=n;i++)	visited[i]=0;
	dfs1(x,0);
	sum=maxm;
	if(da>=level[b]-level[a])	f=1;
	if(sum<db)					f=1;
	if(db<=2*da)				f=1;
	// cout<<sum<<"\n";
	if(f)	cout<<"Alice\n";
	else 	cout<<"Bob\n";
	for(int i=1;i<=n;i++)	visited[i]=0;
	for(int i=1;i<=n;i++)	adj[i].clear();
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	#ifndef ONLINE_JUDGE
	    freopen("/home/ubuntu/.config/sublime-text-3/Packages/User/input.txt", "r", stdin);
	     freopen("/home/ubuntu/.config/sublime-text-3/Packages/User/output.txt", "w", stdout);
	#endif

	int t;
	cin>>t;
	while(t--)
		solve();
}


#include<bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>

#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
#pragma GCC optimize("-ffloat-store")

#define int  long long
#define rep(i,begin,end) for(__typeof(end)i=(begin)-((begin)>(end));i!=(end)-((begin)>(end));i+=1-2*((begin)>(end)))
#define F first
#define S second
#define sz(x) ((int)x.size())
#define pb push_back
#define pf push_front
#define eb emplace_back
#define all(v) (v).begin(), (v).end()
#define mod 1000000007
#define what_is(x) cerr << #x << " is " << x <<"\n";
#define sortA(v) sort(v.begin(), v.end())
#define sortD(v) sort(v.rbegin(), v.rend())
#define PI 3.14159265358979323846
#define vout(a) for(auto x:a) cout<<x<<" ";
#define INF 1000000000000000 //1e16

// #define ordered_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>

// using namespace __gnu_pbds;
using namespace std;

using ll  = long long;
using vi  = vector<int>;
using vvi = vector<vi>;
using pii = pair<int,int>;
using vii = vector<pii>;
using mi  = multiset<int>;
using mii = multiset<pii>;
using ld  = long double;

int lcm(int a,int b) {return (a*(b/__gcd(a,b)));}

const int N=200005;
vector<int> adj[N];
vector<int> level(N);
vector<int> parent(N);
vector<bool> vis(N,false);

void dfs(int s)
{
    vis[s]=true;
    for(int u:adj[s])
    {
        if(!vis[u])
        {
            level[u]=level[s]+1;
            dfs(u);
        }
    }
}

void solve()
{
    int n,m,t,i,k,l,r,s,u,v,w,j,pos,sum=0,flag=0,count=0;
    string S,T;
    int a,b,da,db;
    cin>>n>>a>>b>>da>>db;
    rep(i,0,n-1)
    {
        cin>>u>>v;
        adj[u].pb(v);
        adj[v].pb(u);
    }
    if(2*da>db)
    {
        cout<<"Alice";
        rep(i,1,n+1)
        {
            adj[i].clear();
            vis[i]=false;
            level[i]=0;
        }
        return;
    }
    dfs(a);
    if(level[b]<=da)
    {
        // cout<<b<<" "<<level[b]<<" ";
        cout<<"Alice";
        rep(i,1,n+1)
        {
            adj[i].clear();
            vis[i]=false;
            level[i]=0;
        }
        return;
    }
    vis.assign(sz(vis),false);
    int mx=0,start;
    mx=*max_element(all(level));
    rep(i,1,n+1)
    {
        if(level[i]==mx)
        {
            start=i;
            break;
        }
    }
    level.assign(sz(level),0);
    dfs(start);
    int dia=*max_element(all(level));
    if(db>level[b]%da+da+1)
    {
        cout<<"Bob";
        rep(i,1,n+1)
        {
            adj[i].clear();
            vis[i]=false;
            level[i]=0;
        }
        return;
    }
    cout<<"Alice";
    rep(i,1,n+1)
    {
        adj[i].clear();
        vis[i]=false;
        level[i]=0;
    }
}

signed main()
{
    #ifndef ONLINE_JUDGE
       freopen("input.txt","r",stdin);
       freopen("output.txt","w",stdout);
    #endif
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int t=1;
    cin>>t;
    while(t--)
    {
        solve();
        if(t)cout<<"\n";
    }
    return 0;
}


#include<bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>

#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
#pragma GCC optimize("-ffloat-store")

#define int  long long
#define rep(i,begin,end) for(__typeof(end)i=(begin)-((begin)>(end));i!=(end)-((begin)>(end));i+=1-2*((begin)>(end)))
#define F first
#define S second
#define sz(x) ((int)x.size())
#define pb push_back
#define pf push_front
#define eb emplace_back
#define all(v) (v).begin(), (v).end()
#define mod 1000000007
#define what_is(x) cerr << #x << " is " << x <<"\n";
#define sortA(v) sort(v.begin(), v.end())
#define sortD(v) sort(v.rbegin(), v.rend())
#define PI 3.14159265358979323846
#define vout(a) for(auto x:a) cout<<x<<" ";
#define INF 1000000000000000 //1e16

// #define ordered_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>

// using namespace __gnu_pbds;
using namespace std;

using ll  = long long;
using vi  = vector<int>;
using vvi = vector<vi>;
using pii = pair<int,int>;
using vii = vector<pii>;
using mi  = multiset<int>;
using mii = multiset<pii>;
using ld  = long double;

int lcm(int a,int b) {return (a*(b/__gcd(a,b)));}

const int N=200005;
vector<int> adj[N];
vector<int> level(N);
vector<int> parent(N);
vector<bool> vis(N,false);

void dfs(int s)
{
    vis[s]=true;
    for(int u:adj[s])
    {
        if(!vis[u])
        {
            level[u]=level[s]+1;
            dfs(u);
        }
    }
}

void solve()
{
    int n,m,t,i,k,l,r,s,u,v,w,j,pos,sum=0,flag=0,count=0;
    string S,T;
    int a,b,da,db;
    cin>>n>>a>>b>>da>>db;
    rep(i,0,n-1)
    {
        cin>>u>>v;
        adj[u].pb(v);
        adj[v].pb(u);
    }
    if(da>=db)
    {
        cout<<"Alice";
        rep(i,1,n+1)
        {
            adj[i].clear();
            vis[i]=false;
            level[i]=0;
        }
        return;
    }
    dfs(a);
    if(level[b]<=da)
    {
        // cout<<b<<" "<<level[b]<<" ";
        cout<<"Alice";
        rep(i,1,n+1)
        {
            adj[i].clear();
            vis[i]=false;
            level[i]=0;
        }
        return;
    }
    vis.assign(sz(vis),false);
    int mx=0,start;
    mx=*max_element(all(level));
    rep(i,1,n+1)
    {
        if(level[i]==mx)
        {
            start=i;
            break;
        }
    }
    level.assign(sz(level),0);
    dfs(start);
    int dia=*max_element(all(level));
    if(db>2*da)
    {
        cout<<"Bob";
        rep(i,1,n+1)
        {
            adj[i].clear();
            vis[i]=false;
            level[i]=0;
        }
        return;
    }
    cout<<"Alice";
    rep(i,1,n+1)
    {
        adj[i].clear();
        vis[i]=false;
        level[i]=0;
    }
}

signed main()
{
    #ifndef ONLINE_JUDGE
       freopen("input.txt","r",stdin);
       freopen("output.txt","w",stdout);
    #endif
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int t=1;
    cin>>t;
    while(t--)
    {
        solve();
        if(t)cout<<"\n";
    }
    return 0;
}


#include<bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>

#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
#pragma GCC optimize("-ffloat-store")

#define int  long long
#define rep(i,begin,end) for(__typeof(end)i=(begin)-((begin)>(end));i!=(end)-((begin)>(end));i+=1-2*((begin)>(end)))
#define F first
#define S second
#define sz(x) ((int)x.size())
#define pb push_back
#define pf push_front
#define eb emplace_back
#define all(v) (v).begin(), (v).end()
#define mod 1000000007
#define what_is(x) cerr << #x << " is " << x <<"\n";
#define sortA(v) sort(v.begin(), v.end())
#define sortD(v) sort(v.rbegin(), v.rend())
#define PI 3.14159265358979323846
#define vout(a) for(auto x:a) cout<<x<<" ";
#define INF 1000000000000000 //1e16

// #define ordered_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>

// using namespace __gnu_pbds;
using namespace std;

using ll  = long long;
using vi  = vector<int>;
using vvi = vector<vi>;
using pii = pair<int,int>;
using vii = vector<pii>;
using mi  = multiset<int>;
using mii = multiset<pii>;
using ld  = long double;

int lcm(int a,int b) {return (a*(b/__gcd(a,b)));}

const int N=200005;
vector<int> adj[N];
vector<int> level(N);
vector<int> parent(N);
vector<bool> vis(N,false);

void dfs(int s)
{
    vis[s]=true;
    for(int u:adj[s])
    {
        if(!vis[u])
        {
            level[u]=level[s]+1;
            dfs(u);
        }
    }
}

void solve()
{
    int n,m,t,i,k,l,r,s,u,v,w,j,pos,sum=0,flag=0,count=0;
    string S,T;
    int a,b,da,db;
    cin>>n>>a>>b>>da>>db;
    rep(i,0,n-1)
    {
        cin>>u>>v;
        adj[u].pb(v);
        adj[v].pb(u);
    }
    if(da>db)
    {
        cout<<"Alice";
        rep(i,1,n+1)
        {
            adj[i].clear();
            vis[i]=false;
            level[i]=0;
        }
        return;
    }
    dfs(a);
    if(level[b]<=da)
    {
        // cout<<b<<" "<<level[b]<<" ";
        cout<<"Alice";
        rep(i,1,n+1)
        {
            adj[i].clear();
            vis[i]=false;
            level[i]=0;
        }
        return;
    }
    vis.assign(sz(vis),false);
    int mx=0,start;
    mx=*max_element(all(level));
    rep(i,1,n+1)
    {
        if(level[i]==mx)
        {
            start=i;
            break;
        }
    }
    level.assign(sz(level),0);
    dfs(start);
    int dia=*max_element(all(level));
    if(db>level[b]%da+da+1)
    {
        cout<<"Bob";
        rep(i,1,n+1)
        {
            adj[i].clear();
            vis[i]=false;
            level[i]=0;
        }
        return;
    }
    cout<<"Alice";
    rep(i,1,n+1)
    {
        adj[i].clear();
        vis[i]=false;
        level[i]=0;
    }
}

signed main()
{
    #ifndef ONLINE_JUDGE
       freopen("input.txt","r",stdin);
       freopen("output.txt","w",stdout);
    #endif
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int t=1;
    cin>>t;
    while(t--)
    {
        solve();
        if(t)cout<<"\n";
    }
    return 0;
}


#include<bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>

#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
#pragma GCC optimize("-ffloat-store")

#define int  long long
#define rep(i,begin,end) for(__typeof(end)i=(begin)-((begin)>(end));i!=(end)-((begin)>(end));i+=1-2*((begin)>(end)))
#define F first
#define S second
#define sz(x) ((int)x.size())
#define pb push_back
#define pf push_front
#define eb emplace_back
#define all(v) (v).begin(), (v).end()
#define mod 1000000007
#define what_is(x) cerr << #x << " is " << x <<"\n";
#define sortA(v) sort(v.begin(), v.end())
#define sortD(v) sort(v.rbegin(), v.rend())
#define PI 3.14159265358979323846
#define vout(a) for(auto x:a) cout<<x<<" ";
#define INF 1000000000000000 //1e16

// #define ordered_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>

// using namespace __gnu_pbds;
using namespace std;

using ll  = long long;
using vi  = vector<int>;
using vvi = vector<vi>;
using pii = pair<int,int>;
using vii = vector<pii>;
using mi  = multiset<int>;
using mii = multiset<pii>;
using ld  = long double;

int lcm(int a,int b) {return (a*(b/__gcd(a,b)));}

const int N=200005;
vector<int> adj[N];
vector<int> level(N);
vector<int> parent(N);
vector<bool> vis(N,false);

void dfs(int s)
{
    vis[s]=true;
    for(int u:adj[s])
    {
        if(!vis[u])
        {
            level[u]=level[s]+1;
            dfs(u);
        }
    }
}

void solve()
{
    int n,m,t,i,k,l,r,s,u,v,w,j,pos,sum=0,flag=0,count=0;
    string S,T;
    int a,b,da,db;
    cin>>n>>a>>b>>da>>db;
    rep(i,0,n-1)
    {
        cin>>u>>v;
        adj[u].pb(v);
        adj[v].pb(u);
    }
    if(2*da>=db)
    {
        cout<<"Alice";
        rep(i,1,n+1)
        {
            adj[i].clear();
            vis[i]=false;
            level[i]=0;
        }
        return;
    }
    dfs(a);
    if(level[b]<=da)
    {
        // cout<<b<<" "<<level[b]<<" ";
        cout<<"Alice";
        rep(i,1,n+1)
        {
            adj[i].clear();
            vis[i]=false;
            level[i]=0;
        }
        return;
    }
    vis.assign(sz(vis),false);
    int mx=0,start;
    mx=*max_element(all(level));
    rep(i,1,n+1)
    {
        if(level[i]==mx)
        {
            start=i;
            break;
        }
    }
    level.assign(sz(level),0);
    dfs(start);
    int dia=*max_element(all(level));
    if(db>level[b]%da+da+1)
    {
        cout<<"Bob";
        rep(i,1,n+1)
        {
            adj[i].clear();
            vis[i]=false;
            level[i]=0;
        }
        return;
    }
    cout<<"Alice";
    rep(i,1,n+1)
    {
        adj[i].clear();
        vis[i]=false;
        level[i]=0;
    }
}

signed main()
{
    #ifndef ONLINE_JUDGE
       freopen("input.txt","r",stdin);
       freopen("output.txt","w",stdout);
    #endif
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int t=1;
    cin>>t;
    while(t--)
    {
        solve();
        if(t)cout<<"\n";
    }
    return 0;
}


#include<bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>

#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
#pragma GCC optimize("-ffloat-store")

#define int  long long
#define rep(i,begin,end) for(__typeof(end)i=(begin)-((begin)>(end));i!=(end)-((begin)>(end));i+=1-2*((begin)>(end)))
#define F first
#define S second
#define sz(x) ((int)x.size())
#define pb push_back
#define pf push_front
#define eb emplace_back
#define all(v) (v).begin(), (v).end()
#define mod 1000000007
#define what_is(x) cerr << #x << " is " << x <<"\n";
#define sortA(v) sort(v.begin(), v.end())
#define sortD(v) sort(v.rbegin(), v.rend())
#define PI 3.14159265358979323846
#define vout(a) for(auto x:a) cout<<x<<" ";
#define INF 1000000000000000 //1e16

// #define ordered_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>

// using namespace __gnu_pbds;
using namespace std;

using ll  = long long;
using vi  = vector<int>;
using vvi = vector<vi>;
using pii = pair<int,int>;
using vii = vector<pii>;
using mi  = multiset<int>;
using mii = multiset<pii>;
using ld  = long double;

int lcm(int a,int b) {return (a*(b/__gcd(a,b)));}

const int N=200005;
vector<int> adj[N];
vector<int> level(N);
vector<int> parent(N);
vector<bool> vis(N,false);

void dfs(int s)
{
    vis[s]=true;
    for(int u:adj[s])
    {
        if(!vis[u])
        {
            level[u]=level[s]+1;
            dfs(u);
        }
    }
}

void solve()
{
    int n,m,t,i,k,l,r,s,u,v,w,j,pos,sum=0,flag=0,count=0;
    string S,T;
    int a,b,da,db;
    cin>>n>>a>>b>>da>>db;
    rep(i,0,n-1)
    {
        cin>>u>>v;
        adj[u].pb(v);
        adj[v].pb(u);
    }
    if(2*da>=db)
    {
        cout<<"Alice";
        rep(i,1,n+1)
        {
            adj[i].clear();
            vis[i]=false;
            level[i]=0;
        }
        return;
    }
    dfs(a);
    if(level[b]<=da)
    {
        // cout<<b<<" "<<level[b]<<" ";
        cout<<"Alice";
        rep(i,1,n+1)
        {
            adj[i].clear();
            vis[i]=false;
            level[i]=0;
        }
        return;
    }
    vis.assign(sz(vis),false);
    int mx=0,start;
    mx=*max_element(all(level));
    rep(i,1,n+1)
    {
        if(level[i]==mx)
        {
            start=i;
            break;
        }
    }
    level.assign(sz(level),0);
    dfs(start);
    int dia=*max_element(all(level));
    if(dia<=2*da)
    {
        cout<<"Alice";
        rep(i,1,n+1)
        {
            adj[i].clear();
            vis[i]=false;
            level[i]=0;
        }
        return;
    }
    // da=min(da,dia);
    // db=min(db,dia);
    if(db>2*da)
    {
        cout<<"Bob";
        rep(i,1,n+1)
        {
            adj[i].clear();
            vis[i]=false;
            level[i]=0;
        }
        return;
    }
    cout<<"Alice";
    rep(i,1,n+1)
    {
        adj[i].clear();
        vis[i]=false;
        level[i]=0;
    }
}

signed main()
{
    #ifndef ONLINE_JUDGE
       freopen("input.txt","r",stdin);
       freopen("output.txt","w",stdout);
    #endif
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int t=1;
    cin>>t;
    while(t--)
    {
        solve();
        if(t)cout<<"\n";
    }
    return 0;
}


#include<bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>

#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
#pragma GCC optimize("-ffloat-store")

#define int  long long
#define rep(i,begin,end) for(__typeof(end)i=(begin)-((begin)>(end));i!=(end)-((begin)>(end));i+=1-2*((begin)>(end)))
#define F first
#define S second
#define sz(x) ((int)x.size())
#define pb push_back
#define pf push_front
#define eb emplace_back
#define all(v) (v).begin(), (v).end()
#define mod 1000000007
#define what_is(x) cerr << #x << " is " << x <<"\n";
#define sortA(v) sort(v.begin(), v.end())
#define sortD(v) sort(v.rbegin(), v.rend())
#define PI 3.14159265358979323846
#define vout(a) for(auto x:a) cout<<x<<" ";
#define INF 1000000000000000 //1e16

// #define ordered_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>

// using namespace __gnu_pbds;
using namespace std;

using ll  = long long;
using vi  = vector<int>;
using vvi = vector<vi>;
using pii = pair<int,int>;
using vii = vector<pii>;
using mi  = multiset<int>;
using mii = multiset<pii>;
using ld  = long double;

int lcm(int a,int b) {return (a*(b/__gcd(a,b)));}

const int N=200005;
vector<int> adj[N];
vector<int> level(N);
vector<int> parent(N);
vector<bool> vis(N,false);

void dfs(int s)
{
    vis[s]=true;
    for(int u:adj[s])
    {
        if(!vis[u])
        {
            level[u]=level[s]+1;
            dfs(u);
        }
    }
}

void solve()
{
    int n,m,t,i,k,l,r,s,u,v,w,j,pos,sum=0,flag=0,count=0;
    string S,T;
    int a,b,da,db;
    cin>>n>>a>>b>>da>>db;
    rep(i,0,n-1)
    {
        cin>>u>>v;
        adj[u].pb(v);
        adj[v].pb(u);
    }
    if(da>=db)
    {
        cout<<"Alice";
        rep(i,1,n+1)
        {
            adj[i].clear();
            vis[i]=false;
            level[i]=0;
        }
        return;
    }
    dfs(a);
    if(level[b]<=da)
    {
        // cout<<b<<" "<<level[b]<<" ";
        cout<<"Alice";
        rep(i,1,n+1)
        {
            adj[i].clear();
            vis[i]=false;
            level[i]=0;
        }
        return;
    }
    vis.assign(sz(vis),false);
    int mx=0,start;
    mx=*max_element(all(level));
    rep(i,1,n+1)
    {
        if(level[i]==mx)
        {
            start=i;
            break;
        }
    }
    level.assign(sz(level),0);
    dfs(start);
    int dia=*max_element(all(level));
    if(db>level[b]%da+da+1)
    {
        cout<<"Bob";
        rep(i,1,n+1)
        {
            adj[i].clear();
            vis[i]=false;
            level[i]=0;
        }
        return;
    }
    cout<<"Alice";
    rep(i,1,n+1)
    {
        adj[i].clear();
        vis[i]=false;
        level[i]=0;
    }
}

signed main()
{
    #ifndef ONLINE_JUDGE
       freopen("input.txt","r",stdin);
       freopen("output.txt","w",stdout);
    #endif
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int t=1;
    cin>>t;
    while(t--)
    {
        solve();
        if(t)cout<<"\n";
    }
    return 0;
}


#include<bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>

#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
#pragma GCC optimize("-ffloat-store")

#define int  long long
#define rep(i,begin,end) for(__typeof(end)i=(begin)-((begin)>(end));i!=(end)-((begin)>(end));i+=1-2*((begin)>(end)))
#define F first
#define S second
#define sz(x) ((int)x.size())
#define pb push_back
#define pf push_front
#define eb emplace_back
#define all(v) (v).begin(), (v).end()
#define mod 1000000007
#define what_is(x) cerr << #x << " is " << x <<"\n";
#define sortA(v) sort(v.begin(), v.end())
#define sortD(v) sort(v.rbegin(), v.rend())
#define PI 3.14159265358979323846
#define vout(a) for(auto x:a) cout<<x<<" ";
#define INF 1000000000000000 //1e16

// #define ordered_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>

// using namespace __gnu_pbds;
using namespace std;

using ll  = long long;
using vi  = vector<int>;
using vvi = vector<vi>;
using pii = pair<int,int>;
using vii = vector<pii>;
using mi  = multiset<int>;
using mii = multiset<pii>;
using ld  = long double;

int lcm(int a,int b) {return (a*(b/__gcd(a,b)));}

const int N=200005;
vector<int> adj[N];
vector<int> level(N);
vector<int> parent(N);
vector<bool> vis(N,false);

void dfs(int s)
{
    vis[s]=true;
    for(int u:adj[s])
    {
        if(!vis[u])
        {
            level[u]=level[s]+1;
            dfs(u);
        }
    }
}

void solve()
{
    int n,m,t,i,k,l,r,s,u,v,w,j,pos,sum=0,flag=0,count=0;
    string S,T;
    int a,b,da,db;
    cin>>n>>a>>b>>da>>db;
    rep(i,0,n-1)
    {
        cin>>u>>v;
        adj[u].pb(v);
        adj[v].pb(u);
    }
    if(2*da>=db)
    {
        cout<<"Alice";
        rep(i,1,n+1)
        {
            adj[i].clear();
            vis[i]=false;
            level[i]=0;
        }
        return;
    }
    dfs(a);
    if(level[b]<=da)
    {
        // cout<<b<<" "<<level[b]<<" ";
        cout<<"Alice";
        rep(i,1,n+1)
        {
            adj[i].clear();
            vis[i]=false;
            level[i]=0;
        }
        return;
    }
    cout<<"Bob";
    rep(i,1,n+1)
    {
        adj[i].clear();
        vis[i]=false;
        level[i]=0;
    }
    return;
    vis.assign(sz(vis),false);
    int mx=0,start;
    mx=*max_element(all(level));
    rep(i,1,n+1)
    {
        if(level[i]==mx)
        {
            start=i;
            break;
        }
    }
    level.assign(sz(level),0);
    dfs(start);
    int dia=*max_element(all(level));
    if(db>level[b]%da+da+1)
    {
        cout<<"Bob";
        rep(i,1,n+1)
        {
            adj[i].clear();
            vis[i]=false;
            level[i]=0;
        }
        return;
    }
    cout<<"Alice";
    rep(i,1,n+1)
    {
        adj[i].clear();
        vis[i]=false;
        level[i]=0;
    }
}

signed main()
{
    #ifndef ONLINE_JUDGE
       freopen("input.txt","r",stdin);
       freopen("output.txt","w",stdout);
    #endif
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int t=1;
    cin>>t;
    while(t--)
    {
        solve();
        if(t)cout<<"\n";
    }
    return 0;
}


#include<bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>

#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
#pragma GCC optimize("-ffloat-store")

#define int  long long
#define rep(i,begin,end) for(__typeof(end)i=(begin)-((begin)>(end));i!=(end)-((begin)>(end));i+=1-2*((begin)>(end)))
#define F first
#define S second
#define sz(x) ((int)x.size())
#define pb push_back
#define pf push_front
#define eb emplace_back
#define all(v) (v).begin(), (v).end()
#define mod 1000000007
#define what_is(x) cerr << #x << " is " << x <<"\n";
#define sortA(v) sort(v.begin(), v.end())
#define sortD(v) sort(v.rbegin(), v.rend())
#define PI 3.14159265358979323846
#define vout(a) for(auto x:a) cout<<x<<" ";
#define INF 1000000000000000 //1e16

// #define ordered_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>

// using namespace __gnu_pbds;
using namespace std;

using ll  = long long;
using vi  = vector<int>;
using vvi = vector<vi>;
using pii = pair<int,int>;
using vii = vector<pii>;
using mi  = multiset<int>;
using mii = multiset<pii>;
using ld  = long double;

int lcm(int a,int b) {return (a*(b/__gcd(a,b)));}

const int N=200005;
vector<int> adj[N];
vector<int> level(N);
vector<int> parent(N);
vector<bool> vis(N,false);

void dfs(int s)
{
    vis[s]=true;
    for(int u:adj[s])
    {
        if(!vis[u])
        {
            level[u]=level[s]+1;
            dfs(u);
        }
    }
}

void solve()
{
    int n,m,t,i,k,l,r,s,u,v,w,j,pos,sum=0,flag=0,count=0;
    string S,T;
    int a,b,da,db;
    cin>>n>>a>>b>>da>>db;
    rep(i,0,n-1)
    {
        cin>>u>>v;
        adj[u].pb(v);
        adj[v].pb(u);
    }
    if(da>=db)
    {
        cout<<"Alice";
        rep(i,1,n+1)
        {
            adj[i].clear();
            vis[i]=false;
            level[i]=0;
        }
        return;
    }
    dfs(a);
    if(level[b]<=da)
    {
        // cout<<b<<" "<<level[b]<<" ";
        cout<<"Alice";
        rep(i,1,n+1)
        {
            adj[i].clear();
            vis[i]=false;
            level[i]=0;
        }
        return;
    }
    vis.assign(sz(vis),false);
    int mx=0,start;
    mx=*max_element(all(level));
    rep(i,1,n+1)
    {
        if(level[i]==mx)
        {
            start=i;
            break;
        }
    }
    level.assign(sz(level),0);
    dfs(start);
    int dia=*max_element(all(level));
    if((dia+1)/2>da)
    {
        cout<<"Bob";
        rep(i,1,n+1)
        {
            adj[i].clear();
            vis[i]=false;
            level[i]=0;
        }
        return;
    }
    cout<<"Alice";
    rep(i,1,n+1)
    {
        adj[i].clear();
        vis[i]=false;
        level[i]=0;
    }
}

signed main()
{
    #ifndef ONLINE_JUDGE
       freopen("input.txt","r",stdin);
       freopen("output.txt","w",stdout);
    #endif
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int t=1;
    cin>>t;
    while(t--)
    {
        solve();
        if(t)cout<<"\n";
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define pb push_back
#define vll vector<ll>
#define pll pair<ll,ll>
#define vpll vector<pll>
#define ub upper_bound
#define lb lower_bound
#define all(v) ((v).begin()),((v).end())
#define allr(v) ((v).rbegin()),((v).rend())
#define ff first
#define ss second
#define mp make_pair
#define pll pair<ll,ll>
#define fo(i,n) for(ll i=0;i<n;i++)
#define foa(i,s,e) for(ll i=(s);i<=e;i++)
#define fod(i,s,e) for(ll i= (s);i>=(e);i--)
#define max3(a,b,c) max(max(a,b),c)
#define min3(a,b,c) min(min(a,b),c)
#define deb(x) cerr<<#x<<' '<<'='<<' '<<x<<'\n'
#define sz(x) (ll)(x.size())
#define ANS cout<<ans<<'\n'
#define YES cout<<"YES\n"
#define NO cout<<"NO\n"
#define Yes cout<<"Yes\n"
#define No cout<<"No\n"
const ld pi = 3.14159265358979323846;
ll MOD = 1e9 + 7;
//ll MOD = 998244353;
const char nl = '\n';
const ll inf = 1e15;
#define fill(a,b) memset(a, b, sizeof(a))
#define setbits(x) __builtin_popcountll(x)
#define print2d(dp,n,m) fo(i, n){fo(j, m)cout<<dp[i][j]<<" ";cout<<"\n";}
ll nxt(){ll x; cin >> x; return x;}
ll mul(ll x,ll y){
    return (1ll* (x%MOD)*(y%MOD));
}
ll modpow(ll x,ll y){ll z=1;while(y>0){if(y%2)z=mul(z,x);x =mul(x,x) ;y/=2;}return z;}
ll power(ll x,ll y){ll z=1;while(y>0){if(y%2)z=z*x;x =x*x ;y/=2;}return z;}
ll gcd(ll a,ll b){if(a<b) return gcd(b,a);if(b==0) return a;return gcd(b,a%b);}
ll min(ll a,ll b){if(a<b)return a;return b;}
ll max(ll a,ll b){if(a>b)return a;return b;}
ll sq(ll a){
    ll ans = (1ll*a*a);
    return ans;
}
const ll N = 1e5 + 5;
vll g[N];
ll dis[N];
string lose = "Alice", win = "Bob";
ll mxn, mx;
void dfs(ll u, ll par){
    dis[u] = 1 + dis[par];
    if(dis[u] > mx){
        mx = dis[u];
        mxn = u;
    }
    for(ll x : g[u]){
        if(x!=par)dfs(x, u);
    }
}
void solve(){
    ll n, a, b, da, db;
    cin >> n >> a >> b >> da >> db;
    for(ll i = 1; i <= n; i++)g[i].clear();
    fo(i, n - 1){
        ll x, y;
        cin >> x >> y;
        g[x].pb(y);
        g[y].pb(x);
    }
    dis[0] = -1;
    mxn = a;
    dfs(a, 0);
    if(dis[b] <= da || 2 * da >= db){
        cout << lose << nl;
        return;
    }
    ll p = mxn;
    mx = 0;
    dfs(p, 0);
    //cout << mx << nl;
    if(da * 2 >= mx){
        cout << lose << nl;
        return;
    }

    cout << win << nl;
}
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0),cout.tie(0);
    #ifndef ONLINE_JUDGE
    freopen("inputf.txt" , "r" , stdin) ;
    freopen("outputf.txt" , "w" , stdout) ;
    freopen("error.txt" , "w" , stderr) ;
    #endif
    ll TC = 1;
    cin>>TC;
    fo(TT, TC){
        // Google,FB cout << "Case #"<< TT + 1 << ": ";
        solve();
    }
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define pb push_back
#define vll vector<ll>
#define pll pair<ll,ll>
#define vpll vector<pll>
#define ub upper_bound
#define lb lower_bound
#define all(v) ((v).begin()),((v).end())
#define allr(v) ((v).rbegin()),((v).rend())
#define ff first
#define ss second
#define mp make_pair
#define pll pair<ll,ll>
#define fo(i,n) for(ll i=0;i<n;i++)
#define foa(i,s,e) for(ll i=(s);i<=e;i++)
#define fod(i,s,e) for(ll i= (s);i>=(e);i--)
#define max3(a,b,c) max(max(a,b),c)
#define min3(a,b,c) min(min(a,b),c)
#define deb(x) cerr<<#x<<' '<<'='<<' '<<x<<'\n'
#define sz(x) (ll)(x.size())
#define ANS cout<<ans<<'\n'
#define YES cout<<"YES\n"
#define NO cout<<"NO\n"
#define Yes cout<<"Yes\n"
#define No cout<<"No\n"
const ld pi = 3.14159265358979323846;
ll MOD = 1e9 + 7;
//ll MOD = 998244353;
const char nl = '\n';
const ll inf = 1e15;
#define fill(a,b) memset(a, b, sizeof(a))
#define setbits(x) __builtin_popcountll(x)
#define print2d(dp,n,m) fo(i, n){fo(j, m)cout<<dp[i][j]<<" ";cout<<"\n";}
ll nxt(){ll x; cin >> x; return x;}
ll mul(ll x,ll y){
    return (1ll* (x%MOD)*(y%MOD));
}
ll modpow(ll x,ll y){ll z=1;while(y>0){if(y%2)z=mul(z,x);x =mul(x,x) ;y/=2;}return z;}
ll power(ll x,ll y){ll z=1;while(y>0){if(y%2)z=z*x;x =x*x ;y/=2;}return z;}
ll gcd(ll a,ll b){if(a<b) return gcd(b,a);if(b==0) return a;return gcd(b,a%b);}
ll min(ll a,ll b){if(a<b)return a;return b;}
ll max(ll a,ll b){if(a>b)return a;return b;}
ll sq(ll a){
    ll ans = (1ll*a*a);
    return ans;
}
const ll N = 1e5 + 5;
vll g[N];
ll dis[N];
string lose = "Alice", win = "Bob";
ll mxn, mx;
void dfs(ll u, ll par){
    dis[u] = 1 + dis[par];
    if(dis[u] > mx){
        mx = dis[u];
        mxn = u;
    }
    for(ll x : g[u]){
        if(x!=par)dfs(x, u);
    }
}
void solve(){
    ll n, a, b, da, db;
    cin >> n >> a >> b >> da >> db;
    for(ll i = 1; i <= n; i++)g[i].clear();
    fo(i, n - 1){
        ll x, y;
        cin >> x >> y;
        g[x].pb(y);
        g[y].pb(x);
    }
    dis[0] = -1;
    mxn = a;
    dfs(a, 0);
    if(dis[b] <= da){
        cout << lose << nl;
        return;
    }
    ll p = mxn;
    mx = 0;
    dfs(p, 0);
    //cout << mx << nl;
    if(da * 2 >= min(db, mx)){
        cout << lose << nl;
        return;
    }

    cout << win << nl;
}
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0),cout.tie(0);
    #ifndef ONLINE_JUDGE
    freopen("inputf.txt" , "r" , stdin) ;
    freopen("outputf.txt" , "w" , stdout) ;
    freopen("error.txt" , "w" , stderr) ;
    #endif
    ll TC = 1;
    cin>>TC;
    fo(TT, TC){
        // Google,FB cout << "Case #"<< TT + 1 << ": ";
        solve();
    }
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define pb push_back
#define vll vector<ll>
#define pll pair<ll,ll>
#define vpll vector<pll>
#define ub upper_bound
#define lb lower_bound
#define all(v) ((v).begin()),((v).end())
#define allr(v) ((v).rbegin()),((v).rend())
#define ff first
#define ss second
#define mp make_pair
#define pll pair<ll,ll>
#define fo(i,n) for(ll i=0;i<n;i++)
#define foa(i,s,e) for(ll i=(s);i<=e;i++)
#define fod(i,s,e) for(ll i= (s);i>=(e);i--)
#define max3(a,b,c) max(max(a,b),c)
#define min3(a,b,c) min(min(a,b),c)
#define deb(x) cerr<<#x<<' '<<'='<<' '<<x<<'\n'
#define sz(x) (ll)(x.size())
#define ANS cout<<ans<<'\n'
#define YES cout<<"YES\n"
#define NO cout<<"NO\n"
#define Yes cout<<"Yes\n"
#define No cout<<"No\n"
const ld pi = 3.14159265358979323846;
ll MOD = 1e9 + 7;
//ll MOD = 998244353;
const char nl = '\n';
const ll inf = 1e15;
#define fill(a,b) memset(a, b, sizeof(a))
#define setbits(x) __builtin_popcountll(x)
#define print2d(dp,n,m) fo(i, n){fo(j, m)cout<<dp[i][j]<<" ";cout<<"\n";}
ll nxt(){ll x; cin >> x; return x;}
ll mul(ll x,ll y){
    return (1ll* (x%MOD)*(y%MOD));
}
ll modpow(ll x,ll y){ll z=1;while(y>0){if(y%2)z=mul(z,x);x =mul(x,x) ;y/=2;}return z;}
ll power(ll x,ll y){ll z=1;while(y>0){if(y%2)z=z*x;x =x*x ;y/=2;}return z;}
ll gcd(ll a,ll b){if(a<b) return gcd(b,a);if(b==0) return a;return gcd(b,a%b);}
ll min(ll a,ll b){if(a<b)return a;return b;}
ll max(ll a,ll b){if(a>b)return a;return b;}
ll sq(ll a){
    ll ans = (1ll*a*a);
    return ans;
}
const ll N = 1e5 + 5;
vll g[N];
ll dis[N];
string lose = "Alice", win = "Bob";
ll mxn, mx;
void dfs(ll u, ll par){
    dis[u] = 1 + dis[par];
    if(dis[u] > mx){
        mx = dis[u];
        mxn = u;
    }
    for(ll x : g[u]){
        if(x!=par)dfs(x, u);
    }
}
void solve(){
    ll n, a, b, da, db;
    cin >> n >> a >> b >> da >> db;
    for(ll i = 1; i <= n; i++)g[i].clear(),dis[n] = 0;
    fo(i, n - 1){
        ll x, y;
        cin >> x >> y;
        g[x].pb(y);
        g[y].pb(x);
    }
    dis[0] = -1;
    mxn = a;
    dfs(a, 0);
    if(dis[b] <= da){
        cout << lose << nl;
        return;
    }
    ll p = mxn;
    for(ll i = 1; i<= n; i++)dis[i] = 0;
    dis[0] = -1;
    mx = 0;
    dfs(p, 0);
    //cout << mx << nl;
    if(da * 2 >= min(db, mx)){
        cout << lose << nl;
        return;
    }

    cout << win << nl;
}
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0),cout.tie(0);
    #ifndef ONLINE_JUDGE
    freopen("inputf.txt" , "r" , stdin) ;
    freopen("outputf.txt" , "w" , stdout) ;
    freopen("error.txt" , "w" , stderr) ;
    #endif
    ll TC = 1;
    cin>>TC;
    fo(TT, TC){
        // Google,FB cout << "Case #"<< TT + 1 << ": ";
        solve();
    }
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define pb push_back
#define vll vector<ll>
#define pll pair<ll,ll>
#define vpll vector<pll>
#define ub upper_bound
#define lb lower_bound
#define all(v) ((v).begin()),((v).end())
#define allr(v) ((v).rbegin()),((v).rend())
#define ff first
#define ss second
#define mp make_pair
#define pll pair<ll,ll>
#define fo(i,n) for(ll i=0;i<n;i++)
#define foa(i,s,e) for(ll i=(s);i<=e;i++)
#define fod(i,s,e) for(ll i= (s);i>=(e);i--)
#define max3(a,b,c) max(max(a,b),c)
#define min3(a,b,c) min(min(a,b),c)
#define deb(x) cerr<<#x<<' '<<'='<<' '<<x<<'\n'
#define sz(x) (ll)(x.size())
#define ANS cout<<ans<<'\n'
#define YES cout<<"YES\n"
#define NO cout<<"NO\n"
#define Yes cout<<"Yes\n"
#define No cout<<"No\n"
const ld pi = 3.14159265358979323846;
ll MOD = 1e9 + 7;
//ll MOD = 998244353;
const char nl = '\n';
const ll inf = 1e15;
#define fill(a,b) memset(a, b, sizeof(a))
#define setbits(x) __builtin_popcountll(x)
#define print2d(dp,n,m) fo(i, n){fo(j, m)cout<<dp[i][j]<<" ";cout<<"\n";}
ll nxt(){ll x; cin >> x; return x;}
ll mul(ll x,ll y){
    return (1ll* (x%MOD)*(y%MOD));
}
ll modpow(ll x,ll y){ll z=1;while(y>0){if(y%2)z=mul(z,x);x =mul(x,x) ;y/=2;}return z;}
ll power(ll x,ll y){ll z=1;while(y>0){if(y%2)z=z*x;x =x*x ;y/=2;}return z;}
ll gcd(ll a,ll b){if(a<b) return gcd(b,a);if(b==0) return a;return gcd(b,a%b);}
ll min(ll a,ll b){if(a<b)return a;return b;}
ll max(ll a,ll b){if(a>b)return a;return b;}
ll sq(ll a){
    ll ans = (1ll*a*a);
    return ans;
}
const ll N = 1e5 + 5;
vll g[N];
ll dis[N];
string lose = "Alice", win = "Bob";
ll mxn, mx;
void dfs(ll u, ll par){
    dis[u] = 1 + dis[par];
    if(dis[u] > mx){
        mx = dis[u];
        mxn = u;
    }
    for(ll x : g[u]){
        if(x!=par)dfs(x, u);
    }
}
void solve(){
    ll n, a, b, da, db;
    cin >> n >> a >> b >> da >> db;
    for(ll i = 1; i <= n; i++)g[i].clear();
    fo(i, n - 1){
        ll x, y;
        cin >> x >> y;
        g[x].pb(y);
        g[y].pb(x);
    }
    if(da * 2 >= db){
        cout << lose << nl;
        return;
    }
    dis[0] = -1;
    mx = 0;
    mxn = a;
    dfs(a, 0);
    if(dis[b] <= da){
        cout << lose << nl;
        return;
    }
    ll p = mxn;
    dfs(p, 0);
    if(mx <= 2 * da){
        cout << lose << nl;
        return;
    }
    cout << win << nl;
}
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0),cout.tie(0);
    #ifndef ONLINE_JUDGE
    freopen("inputf.txt" , "r" , stdin) ;
    freopen("outputf.txt" , "w" , stdout) ;
    freopen("error.txt" , "w" , stderr) ;
    #endif
    ll TC = 1;
    cin>>TC;
    fo(TT, TC){
        // Google,FB cout << "Case #"<< TT + 1 << ": ";
        solve();
    }
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define pb push_back
#define vll vector<ll>
#define pll pair<ll,ll>
#define vpll vector<pll>
#define ub upper_bound
#define lb lower_bound
#define all(v) ((v).begin()),((v).end())
#define allr(v) ((v).rbegin()),((v).rend())
#define ff first
#define ss second
#define mp make_pair
#define pll pair<ll,ll>
#define fo(i,n) for(ll i=0;i<n;i++)
#define foa(i,s,e) for(ll i=(s);i<=e;i++)
#define fod(i,s,e) for(ll i= (s);i>=(e);i--)
#define max3(a,b,c) max(max(a,b),c)
#define min3(a,b,c) min(min(a,b),c)
#define deb(x) cerr<<#x<<' '<<'='<<' '<<x<<'\n'
#define sz(x) (ll)(x.size())
#define ANS cout<<ans<<'\n'
#define YES cout<<"YES\n"
#define NO cout<<"NO\n"
#define Yes cout<<"Yes\n"
#define No cout<<"No\n"
const ld pi = 3.14159265358979323846;
ll MOD = 1e9 + 7;
//ll MOD = 998244353;
const char nl = '\n';
const ll inf = 1e15;
#define fill(a,b) memset(a, b, sizeof(a))
#define setbits(x) __builtin_popcountll(x)
#define print2d(dp,n,m) fo(i, n){fo(j, m)cout<<dp[i][j]<<" ";cout<<"\n";}
ll nxt(){ll x; cin >> x; return x;}
ll mul(ll x,ll y){
    return (1ll* (x%MOD)*(y%MOD));
}
ll modpow(ll x,ll y){ll z=1;while(y>0){if(y%2)z=mul(z,x);x =mul(x,x) ;y/=2;}return z;}
ll power(ll x,ll y){ll z=1;while(y>0){if(y%2)z=z*x;x =x*x ;y/=2;}return z;}
ll gcd(ll a,ll b){if(a<b) return gcd(b,a);if(b==0) return a;return gcd(b,a%b);}
ll min(ll a,ll b){if(a<b)return a;return b;}
ll max(ll a,ll b){if(a>b)return a;return b;}
ll sq(ll a){
    ll ans = (1ll*a*a);
    return ans;
}
const ll N = 1e5 + 5;
vll g[N];
ll dis[N];
string lose = "Alice", win = "Bob";
ll mxn, mx;
void dfs(ll u, ll par){
    dis[u] = 1 + dis[par];
    if(dis[u] > mx){
        mx = dis[u];
        mxn = u;
    }
    for(ll x : g[u]){
        if(x!=par)dfs(x, u);
    }
}
void solve(){
    ll n, a, b, da, db;
    cin >> n >> a >> b >> da >> db;
    for(ll i = 1; i <= n; i++)g[i].clear();
    fo(i, n - 1){
        ll x, y;
        cin >> x >> y;
        g[x].pb(y);
        g[y].pb(x);
    }
    if(da * 2 >= db){
        cout << lose << nl;
        return;
    }
    dis[0] = -1;
    mxn = a;
    dfs(a, 0);
    if(dis[b] <= da){
        cout << lose << nl;
        return;
    }
    ll p = mxn;
    dfs(p, 0);
    if(mx >= db){
        cout << win << nl;
        return;
    }
    cout << lose << nl;
}
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0),cout.tie(0);
    #ifndef ONLINE_JUDGE
    freopen("inputf.txt" , "r" , stdin) ;
    freopen("outputf.txt" , "w" , stdout) ;
    freopen("error.txt" , "w" , stderr) ;
    #endif
    ll TC = 1;
    cin>>TC;
    fo(TT, TC){
        // Google,FB cout << "Case #"<< TT + 1 << ": ";
        solve();
    }
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define pb push_back
#define vll vector<ll>
#define pll pair<ll,ll>
#define vpll vector<pll>
#define ub upper_bound
#define lb lower_bound
#define all(v) ((v).begin()),((v).end())
#define allr(v) ((v).rbegin()),((v).rend())
#define ff first
#define ss second
#define mp make_pair
#define pll pair<ll,ll>
#define fo(i,n) for(ll i=0;i<n;i++)
#define foa(i,s,e) for(ll i=(s);i<=e;i++)
#define fod(i,s,e) for(ll i= (s);i>=(e);i--)
#define max3(a,b,c) max(max(a,b),c)
#define min3(a,b,c) min(min(a,b),c)
#define deb(x) cerr<<#x<<' '<<'='<<' '<<x<<'\n'
#define sz(x) (ll)(x.size())
#define ANS cout<<ans<<'\n'
#define YES cout<<"YES\n"
#define NO cout<<"NO\n"
#define Yes cout<<"Yes\n"
#define No cout<<"No\n"
const ld pi = 3.14159265358979323846;
ll MOD = 1e9 + 7;
//ll MOD = 998244353;
const char nl = '\n';
const ll inf = 1e15;
#define fill(a,b) memset(a, b, sizeof(a))
#define setbits(x) __builtin_popcountll(x)
#define print2d(dp,n,m) fo(i, n){fo(j, m)cout<<dp[i][j]<<" ";cout<<"\n";}
ll nxt(){ll x; cin >> x; return x;}
ll mul(ll x,ll y){
    return (1ll* (x%MOD)*(y%MOD));
}
ll modpow(ll x,ll y){ll z=1;while(y>0){if(y%2)z=mul(z,x);x =mul(x,x) ;y/=2;}return z;}
ll power(ll x,ll y){ll z=1;while(y>0){if(y%2)z=z*x;x =x*x ;y/=2;}return z;}
ll gcd(ll a,ll b){if(a<b) return gcd(b,a);if(b==0) return a;return gcd(b,a%b);}
ll min(ll a,ll b){if(a<b)return a;return b;}
ll max(ll a,ll b){if(a>b)return a;return b;}
ll sq(ll a){
    ll ans = (1ll*a*a);
    return ans;
}
const ll N = 1e5 + 5;
vll g[N];
ll dis[N];
string lose = "Alice", win = "Bob";
ll mxn, mx;
void dfs(ll u, ll par){
    dis[u] = 1 + dis[par];
    if(dis[u] > mx){
        mx = dis[u];
        mxn = u;
    }
    for(ll x : g[u]){
        if(x!=par)dfs(x, u);
    }
}
void solve(){
    ll n, a, b, da, db;
    cin >> n >> a >> b >> da >> db;
    for(ll i = 1; i <= n; i++)g[i].clear();
    fo(i, n - 1){
        ll x, y;
        cin >> x >> y;
        g[x].pb(y);
        g[y].pb(x);
    }
    if(da * 2 >= db){
        cout << lose << nl;
        return;
    }
    dis[0] = -1;
    mxn = a;
    dfs(a, 0);
    if(dis[b] <= da){
        cout << lose << nl;
        return;
    }
    ll p = mxn;
    dfs(p, 0);
    if(mx > 2 * da){
        cout << win << nl;
        return;
    }
    cout << lose << nl;
}
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0),cout.tie(0);
    #ifndef ONLINE_JUDGE
    freopen("inputf.txt" , "r" , stdin) ;
    freopen("outputf.txt" , "w" , stdout) ;
    freopen("error.txt" , "w" , stderr) ;
    #endif
    ll TC = 1;
    cin>>TC;
    fo(TT, TC){
        // Google,FB cout << "Case #"<< TT + 1 << ": ";
        solve();
    }
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define pb push_back
#define vll vector<ll>
#define pll pair<ll,ll>
#define vpll vector<pll>
#define ub upper_bound
#define lb lower_bound
#define all(v) ((v).begin()),((v).end())
#define allr(v) ((v).rbegin()),((v).rend())
#define ff first
#define ss second
#define mp make_pair
#define pll pair<ll,ll>
#define fo(i,n) for(ll i=0;i<n;i++)
#define foa(i,s,e) for(ll i=(s);i<=e;i++)
#define fod(i,s,e) for(ll i= (s);i>=(e);i--)
#define max3(a,b,c) max(max(a,b),c)
#define min3(a,b,c) min(min(a,b),c)
#define deb(x) cerr<<#x<<' '<<'='<<' '<<x<<'\n'
#define sz(x) (ll)(x.size())
#define ANS cout<<ans<<'\n'
#define YES cout<<"YES\n"
#define NO cout<<"NO\n"
#define Yes cout<<"Yes\n"
#define No cout<<"No\n"
const ld pi = 3.14159265358979323846;
ll MOD = 1e9 + 7;
//ll MOD = 998244353;
const char nl = '\n';
const ll inf = 1e15;
#define fill(a,b) memset(a, b, sizeof(a))
#define setbits(x) __builtin_popcountll(x)
#define print2d(dp,n,m) fo(i, n){fo(j, m)cout<<dp[i][j]<<" ";cout<<"\n";}
ll nxt(){ll x; cin >> x; return x;}
ll mul(ll x,ll y){
    return (1ll* (x%MOD)*(y%MOD));
}
ll modpow(ll x,ll y){ll z=1;while(y>0){if(y%2)z=mul(z,x);x =mul(x,x) ;y/=2;}return z;}
ll power(ll x,ll y){ll z=1;while(y>0){if(y%2)z=z*x;x =x*x ;y/=2;}return z;}
ll gcd(ll a,ll b){if(a<b) return gcd(b,a);if(b==0) return a;return gcd(b,a%b);}
ll min(ll a,ll b){if(a<b)return a;return b;}
ll max(ll a,ll b){if(a>b)return a;return b;}
ll sq(ll a){
    ll ans = (1ll*a*a);
    return ans;
}
const ll N = 1e5 + 5;
vll g[N];
ll dis[N];
string lose = "Alice", win = "Bob";
ll mxn, mx;
ll dfs(ll x, ll p) {
    ll len = 0;
    for(ll y : g[x]) {
        if(y != p) {
            dis[y] = dis[x] + 1;
            ll cur = 1 + dfs(y, x);
            mx = max(mx, cur + len);
            len = max(len, cur);
        }
    }
    return len;
}
void solve(){
    ll n, a, b, da, db;
    cin >> n >> a >> b >> da >> db;
    for(ll i = 1; i <= n; i++)g[i].clear();
    fo(i, n - 1){
        ll x, y;
        cin >> x >> y;
        g[x].pb(y);
        g[y].pb(x);
    }
    dis[a] = 0;
    dfs(a, 0);
    if(da * 2 >= min(db, mx) || dis[b] <= da){
        cout << lose << nl;
    }
    else cout << win << nl;
}
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0),cout.tie(0);
    #ifndef ONLINE_JUDGE
    freopen("inputf.txt" , "r" , stdin) ;
    freopen("outputf.txt" , "w" , stdout) ;
    freopen("error.txt" , "w" , stderr) ;
    #endif
    ll TC = 1;
    cin>>TC;
    fo(TT, TC){
        // Google,FB cout << "Case #"<< TT + 1 << ": ";
        solve();
    }
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define pb push_back
#define vll vector<ll>
#define pll pair<ll,ll>
#define vpll vector<pll>
#define ub upper_bound
#define lb lower_bound
#define all(v) ((v).begin()),((v).end())
#define allr(v) ((v).rbegin()),((v).rend())
#define ff first
#define ss second
#define mp make_pair
#define pll pair<ll,ll>
#define fo(i,n) for(ll i=0;i<n;i++)
#define foa(i,s,e) for(ll i=(s);i<=e;i++)
#define fod(i,s,e) for(ll i= (s);i>=(e);i--)
#define max3(a,b,c) max(max(a,b),c)
#define min3(a,b,c) min(min(a,b),c)
#define deb(x) cerr<<#x<<' '<<'='<<' '<<x<<'\n'
#define sz(x) (ll)(x.size())
#define ANS cout<<ans<<'\n'
#define YES cout<<"YES\n"
#define NO cout<<"NO\n"
#define Yes cout<<"Yes\n"
#define No cout<<"No\n"
const ld pi = 3.14159265358979323846;
ll MOD = 1e9 + 7;
//ll MOD = 998244353;
const char nl = '\n';
const ll inf = 1e15;
#define fill(a,b) memset(a, b, sizeof(a))
#define setbits(x) __builtin_popcountll(x)
#define print2d(dp,n,m) fo(i, n){fo(j, m)cout<<dp[i][j]<<" ";cout<<"\n";}
ll nxt(){ll x; cin >> x; return x;}
ll mul(ll x,ll y){
    return (1ll* (x%MOD)*(y%MOD));
}
ll modpow(ll x,ll y){ll z=1;while(y>0){if(y%2)z=mul(z,x);x =mul(x,x) ;y/=2;}return z;}
ll power(ll x,ll y){ll z=1;while(y>0){if(y%2)z=z*x;x =x*x ;y/=2;}return z;}
ll gcd(ll a,ll b){if(a<b) return gcd(b,a);if(b==0) return a;return gcd(b,a%b);}
ll min(ll a,ll b){if(a<b)return a;return b;}
ll max(ll a,ll b){if(a>b)return a;return b;}
ll sq(ll a){
    ll ans = (1ll*a*a);
    return ans;
}
const ll N = 1e5 + 5;
vll g[N];
ll dis[N];
string lose = "Alice", win = "Bob";
ll mxn, mx;
void dfs(ll u, ll par){
    dis[u] = 1 + dis[par];
    if(dis[u] > mx){
        mx = dis[u];
        mxn = u;
    }
    for(ll x : g[u]){
        if(x!=par)dfs(x, u);
    }
}
void solve(){
    ll n, a, b, da, db;
    cin >> n >> a >> b >> da >> db;
    for(ll i = 1; i <= n; i++)g[i].clear();
    fo(i, n - 1){
        ll x, y;
        cin >> x >> y;
        g[x].pb(y);
        g[y].pb(x);
    }
    dis[0] = -1;
    mxn = a;
    dfs(a, 0);
    if(dis[b] <= da){
        cout << lose << nl;
        return;
    }
    ll p = mxn;
    dfs(p, 0);
    //cout << mx << nl;
    if(da * 2 >= min(db, mx)){
        cout << lose << nl;
        return;
    }

    cout << win << nl;
}
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0),cout.tie(0);
    #ifndef ONLINE_JUDGE
    freopen("inputf.txt" , "r" , stdin) ;
    freopen("outputf.txt" , "w" , stdout) ;
    freopen("error.txt" , "w" , stderr) ;
    #endif
    ll TC = 1;
    cin>>TC;
    fo(TT, TC){
        // Google,FB cout << "Case #"<< TT + 1 << ": ";
        solve();
    }
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define pb push_back
#define vll vector<ll>
#define pll pair<ll,ll>
#define vpll vector<pll>
#define ub upper_bound
#define lb lower_bound
#define all(v) ((v).begin()),((v).end())
#define allr(v) ((v).rbegin()),((v).rend())
#define ff first
#define ss second
#define mp make_pair
#define pll pair<ll,ll>
#define fo(i,n) for(ll i=0;i<n;i++)
#define foa(i,s,e) for(ll i=(s);i<=e;i++)
#define fod(i,s,e) for(ll i= (s);i>=(e);i--)
#define max3(a,b,c) max(max(a,b),c)
#define min3(a,b,c) min(min(a,b),c)
#define deb(x) cerr<<#x<<' '<<'='<<' '<<x<<'\n'
#define sz(x) (ll)(x.size())
#define ANS cout<<ans<<'\n'
#define YES cout<<"YES\n"
#define NO cout<<"NO\n"
#define Yes cout<<"Yes\n"
#define No cout<<"No\n"
const ld pi = 3.14159265358979323846;
ll MOD = 1e9 + 7;
//ll MOD = 998244353;
const char nl = '\n';
const ll inf = 1e15;
#define fill(a,b) memset(a, b, sizeof(a))
#define setbits(x) __builtin_popcountll(x)
#define print2d(dp,n,m) fo(i, n){fo(j, m)cout<<dp[i][j]<<" ";cout<<"\n";}
ll nxt(){ll x; cin >> x; return x;}
ll mul(ll x,ll y){
    return (1ll* (x%MOD)*(y%MOD));
}
ll modpow(ll x,ll y){ll z=1;while(y>0){if(y%2)z=mul(z,x);x =mul(x,x) ;y/=2;}return z;}
ll power(ll x,ll y){ll z=1;while(y>0){if(y%2)z=z*x;x =x*x ;y/=2;}return z;}
ll gcd(ll a,ll b){if(a<b) return gcd(b,a);if(b==0) return a;return gcd(b,a%b);}
ll min(ll a,ll b){if(a<b)return a;return b;}
ll max(ll a,ll b){if(a>b)return a;return b;}
ll sq(ll a){
    ll ans = (1ll*a*a);
    return ans;
}
const ll N = 1e5 + 5;
vll g[N];
ll dis[N];
string lose = "Alice", win = "Bob";
ll mxn, mx;
void dfs(ll u, ll par){
    dis[u] = 1 + dis[par];
    if(dis[u] > mx){
        mx = dis[u];
        mxn = u;
    }
    for(ll x : g[u]){
        if(x!=par)dfs(x, u);
    }
}
void solve(){
    ll n, a, b, da, db;
    cin >> n >> a >> b >> da >> db;
    for(ll i = 1; i <= n; i++)g[i].clear();
    fo(i, n - 1){
        ll x, y;
        cin >> x >> y;
        g[x].pb(y);
        g[y].pb(x);
    }
    if(da * 2 >= db){
        cout << lose << nl;
        return;
    }
    dis[0] = -1;
    mxn = a;
    dfs(a, 0);
    if(dis[b] <= da){
        cout << lose << nl;
        return;
    }
    ll p = mxn;
    dfs(p, 0);
    if(mx <= 2 * da){
        cout << lose << nl;
        return;
    }
    cout << win << nl;
}
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0),cout.tie(0);
    #ifndef ONLINE_JUDGE
    freopen("inputf.txt" , "r" , stdin) ;
    freopen("outputf.txt" , "w" , stdout) ;
    freopen("error.txt" , "w" , stderr) ;
    #endif
    ll TC = 1;
    cin>>TC;
    fo(TT, TC){
        // Google,FB cout << "Case #"<< TT + 1 << ": ";
        solve();
    }
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
}


#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define PB push_back
#define PF push_front
#define P push
#define INC(i,a,b) for (ll i = a; i <= b; i++)
#define DEC(i,b,a) for (ll i = b; i >= a ; i--)
#define inf LLONG_MAX
#define neginf LLONG_MIN
#define mod  1000000007
#define eps 1e-9
typedef ostringstream OS ;
typedef stringstream SS ;
typedef long long ll ;
typedef unsigned long long ull;
typedef pair < ll , ll > PLL ;
typedef pair < char,ll > PCL ;
typedef deque < double > DD ;
typedef deque < PCL > DCL ;
typedef deque < ll > DL ;
typedef deque < PLL > DLL ;
typedef deque < char > DC ;
typedef deque < string > DS ;
typedef vector < double > VD;
typedef vector < PCL > VCL ;
typedef vector < ll > VL;
typedef vector < PLL > VLL ;
typedef vector < char > VC ;
typedef vector < string > VS ;
typedef map < ll ,ll > MLL ;
typedef map < char,ll > MCL;
typedef map < ll,char > MLC;
typedef map < string,ll> MSL;
typedef priority_queue < PLL > PQLL ;
typedef priority_queue < ll > PQL ;
typedef stack < ll > SKL ;
typedef stack < PLL > SKLL ;
typedef queue < ll > QL ;
typedef queue < PLL > QLL ;
typedef set < ll > SL ;
typedef set < PLL > SLL ;
typedef set < char > SC ;

string numtostr(ll n) {
     OS str1 ;
     str1 << n ;
     return str1.str();
}
ll strtonum(string s) {
     ll x ;
     SS str1(s);
     str1 >> x ;
     return x ;
}
ll GCD(ll a, ll b) {
    if ( b == 0 ) return a ;
    else return GCD(b,a%b);
}
ll LCM(ll a , ll b) {
    ll gcd = GCD(a,b);
     return (a/gcd)*b ;
}
VL visited,dis ;
vector < VL > graph ;
void setting(ll n) {
    visited.clear();
    dis.clear();
    graph.clear();
    visited.resize(n+5,0);
    dis.resize(n+5,0);
    graph.resize(n+5);
}
void dfs(ll node, ll parent ,ll durotto) {
    dis[node] = durotto;
    for ( ll child : graph[node]) {
        if ( child == parent) continue;
        dfs(child,node,durotto+1);
    }
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    ll t ;
    cin >> t ;
    while(t--) {
        ll n,a,b,da,db ;
        cin >> n >> a >> da >> b >> db ;
        setting(n);
        INC(i,1,n-1) {
            ll node1,node2 ;
            cin >> node1 >> node2;
            graph[node1].PB(node2);
            graph[node2].PB(node1);
        }

        dfs(a,-1,0);
        if (dis[b] <= da ) {
            cout << "Alice" << endl;
            continue ;
        }
        ll maximum = 0 ;
        ll furthestnode = -1 ;
        INC(i,1,n) if ( dis[i] > maximum) {
            maximum = dis[i];
            furthestnode = i ;
        }
        visited.clear();
        dis.clear();
        visited.resize(n+5,0);
        dis.resize(n+5,0);
        dfs(furthestnode,-1,0);
        ll treediameter = 0 ;
        INC(i,1,n) treediameter = max(treediameter,dis[i]);
        if ( treediameter <= 2*da || db <= 2*da  )  {
            cout << "Alice" << endl;
            continue ;
        }
        cout << "Bob" << endl;
    }

    return 0 ;
}