#include<iostream>
using namespace std;
int xy[104][104],z[104][104];
int main()
{
int x1=0,y1=0,x2=0,y2=0,x=0,y=0,n=0,m=0,y3;
cin>>n>>m>>x>>y;
y3=y;
for(int q=1;q<=x;q++)
{
cin>>x1>>y1>>x2>>y2;
for(int i=x1;i<=x2;i++)
{
for(int j=y1;j<=y2;j++)
{
xy[i][j]++;
z[i][j]=q;
}
}
}
for(int q=1;q<=y3;q++)
{
cin>>x>>y;
if(xy[x][y]!=0)
{
cout<<"Y "<<xy[x][y]<<" "<<z[x][y]<<endl;
}
else
{
cout<<"N"<<endl;
}
}
}