2 10 1 1 1
1
10
1
1 5 1 8
 4 4 1 0 1
1

1
1 2 1 4
 2 5 1 0 1
2

1
1 4 1 5
 10 10 1 8 4
10
2 3 4 5 6 7 8 9
10
1 1 3 1
2 1 7 1
1 1 9 1
7 1 4 1
10 1 7 1
2 1 7 1
3 1 2 1
5 1 2 1
10 1 5 1
6 1 9 1
 2 4 1 1 1
1
4
1
1 2 1 3
 2 2 0 1 1

1
1
1 2 2 2
 1000 1000 1 1 10
1
2
1
1 900 1 1000
 5 5 1 1 1
3
2
1
1 5 1 1
 2 4 1 1 1
1
2
1
2 3 2 4
 4 4 1 0 1
4

5
1 1 2 2
1 3 2 2
3 3 4 3
3 2 2 2
1 2 2 3

3
 2
 1
 3
4
4
3
3
4
3
3
4
3
 1
 3
 100
 4
 1
 6
4
3
5
4

#include<bits\stdc++.h>
using namespace std;
#define ll long long int

int n,m,cl,ce,v;
int acl[100001];
int ace[100001];


int main()
{
    memset(acl,-1,sizeof acl);
    memset(ace,-1,sizeof ace);
    cin>>n>>m>>cl>>ce>>v;
    for(int i=0;i<cl;i++)
        cin>>acl[i];
    for(int i=0;i<ce;i++)
        cin>>ace[i];
    int q;
    cin>>q;
    for(int i=0;i<q;i++)
    {
        int x1,x2,y1,y2;
        cin>>x1>>y1>>x2>>y2;
        int y=min(y1,y2);
        int yy=max(y1,y2);
        int x,xx;
        if(y1<y2)
        {
            x=x1;
            xx=x2;
        }
        else
        {
            xx=x1;
            x=x2;
        }
        int lo=0;
        int hi=cl;
        int ans=-1;
        int sum=1e8+1;
        while(lo<=hi)
        {
            int j=(lo+hi)/2;
            if(y<acl[j]&&acl[j]<yy)
            {
                ans=acl[j];
                break;
            }
            else if(acl[j]<y)
            {
                if(2*(y-acl[j])<sum)
                {
                    sum=2*(y-acl[j]);
                    ans=acl[j];
                }
                lo=j+1;
            }
            else
            {
                if(2*(acl[j]-yy)<sum)
                {
                    sum=2*(acl[j]-yy);
                    ans=acl[j];
                    
                }
                hi=j-1;
            }
        }
        lo=0;
        hi=ce;
        int ans1=-1;
        int sum1=1e8+1;
        while(lo<=hi)
        {
            int j=(lo+hi)/2;
            if(y<ace[j]&&ace[j]<yy)
            {
                ans1=ace[j];
                break;
            }
            else if(ace[j]<y)
            {
                if(2*(y-ace[j])<sum1)
                {
                    sum1=2*(y-ace[j]);
                    ans1=ace[j];
                    
                }
                lo=j+1;
            }
            else
            {
                if(2*(ace[j]-yy)<sum1)
                {
                    sum1=2*(ace[j]-yy);
                    ans1=ace[j];
                    
                }
                hi=j-1;
            }
        }
        lo=0;
        hi=2*(1e8)+1;
        int res=-1;
        //cout<<"x="<<x<<endl<<"y="<<y<<endl;
        //cout<<"xx="<<xx<<endl<<"yy="<<yy<<endl;
        //cout<<"ans="<<ans<<endl<<"ans1="<<ans1<<endl;
        while(lo<=hi)
        {
            int j=(lo+hi)/2;
            int u=-5;
            if(ans!=-1)
            {
                u=j;
                //cout<<"u="<<u<<endl;
                //cout<<"dif="<<2*(y-ans)+(yy-y)+abs(xx-x)<<endl;
                if(y<ans&&ans<yy)
                    u-=(yy-y)+abs(xx-x);
                else if(ans<y)
                    u-=2*(y-ans)+(yy-y)+abs(xx-x);
                else if(ans>yy)
                    u-=2*(ans-yy)+(yy-y)+abs(xx-x);
            }
            int k=-5;
            if(ans1!=-1)
            {
                k=j;
                //cout<<"k="<<k<<endl;
                //cout<<"dif="<<2*(y-ans1)+(yy-y)+abs(xx-x)/v+(abs(xx-x)%v>0)<<endl;
                if(y<ans1&&ans1<yy)
                    k-=(yy-y)+abs(xx-x)/v+(abs(xx-x)%v>0);
                else if(ans1<y)
                    k-=2*(y-ans1)+(yy-y)+abs(xx-x)/v+(abs(xx-x)%v>0);
                else if(ans1>yy)
                    k-=2*(ans1-yy)+(yy-y)+abs(xx-x)/v+(abs(xx-x)%v>0);
            }
            //cout<<u<<" "<<k<<endl;
            if(k>=0||u>=0)
            {
                res=j;
                hi=j-1;
            }
            else
            {
                lo=j+1;
            }
        }
        cout<<res<<endl;
    }
    
    return 0;
}