//A[i],B[i]>0 or (l1==r1 or l2==r2) (10~65pts)
#include<bits/stdc++.h>
using namespace std;
long long n,m,q,a[100005],b[100005],ans,l1,l2,r1,r2;
int main(){
freopen("csp2022_game.in","r",stdin);
freopen("csp2022_game.out","w",stdout);
cin>>n>>m>>q;
for(int i=1;i<=n;i++)cin>>a[i];
for(int i=1;i<=m;i++)cin>>b[i];
while(q--){
cin>>l1>>r1>>l2>>r2;
if(l1==r1){
long long minb=1e18+1;
for(long long i=l2;i<=r2;i++){
minb=min(a[l1]*b[i],minb);
}
cout<<minb<<endl;
}else if(l2==r2){
long long maxa=-1e18;
for(long long i=l1;i<=r1;i++){
maxa=max(b[l2]*a[i],maxa);
}
cout<<maxa<<' ';
}else{
long long maxa=-1e18;
for(long long i=l1;i<=r1;i++){
maxa=max(maxa,a[i]);
}
long long minb=1e18;
for(long long i=l2;i<=r2;i++){
minb=min(minb,b[i]);
}
cout<<maxa*minb<<endl;
}
}
return 0;
}