dfs:
/*
dfs
*/
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<algorithm>
#include<iostream>
#include<queue>
#include<map>
#include<stack>
#include<set>
#include<math.h>
using namespace std;
typedef long long int64;
//typedef __int64 int64;
typedef pair<int64,int64> PII;
#define MP(a,b) make_pair((a),(b))
const int maxn = ;
const int inf = 0x7fffffff;
const double pi=acos(-1.0);
const double eps = 1e-; int vis[ maxn ];
struct Edge{
int u,next;
}edge[ maxn<< ];
int cnt,head[ maxn ];
void init(){
memset( vis,-,sizeof( vis ) );
cnt = ;
memset( head,-,sizeof( head ) );
}
void addedge( int a,int b ){
edge[ cnt ].u = b;
edge[ cnt ].next = head[ a ];
head[ a ] = cnt++;
} bool flag;
int ans;
void dfs( int cur ){
if( flag ) return ;
vis[ cur ] = ;
for( int i=head[ cur ];i!=-;i=edge[i].next ){
int nxt = edge[i].u;
if(nxt == ans){
flag = true;
return;
}
if(vis[ nxt ] == )continue;
if( flag )return;
dfs( nxt );
}
} int main(){
int T;
scanf("%d",&T);
int Case = ;
while( T-- ){
int n,m;
scanf("%d%d",&n,&m);
int edge_a,edge_b;
scanf("%d%d",&edge_a,&edge_b);
int x,y;
init();
while( edge_a-- ){
scanf("%d%d",&x,&y);
x++,y++;
y += n;
addedge( x,y );
}
while( edge_b-- ){
scanf("%d%d",&x,&y);
x++,y++;
x += n;
addedge( x,y );
}
flag = false; for( int i=;i<=n;i++ ){
memset(vis,,sizeof(vis));
ans = i;
dfs(i);
if(flag)break;
/*
if( flag==false&&vis[i]==-1 ){
dfs( i,-1 );
}
*/
}
printf("Case %d: ",Case ++ );
if( flag ) printf("Possible\n");
else printf("Impossible\n");
}
return ;
}