#include <bits/stdc++.h>
using namespace std;
long long n, m, q, c[1010][1010], a[1010], b[1010];
long long maxn = 200000000000000000;
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];
}
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= m; j++) {
c[i][j] = a[i] * b[j];
}
}
for (int i = 1; i <= q; i++) {
int l1, l2, r1, r2;
long long ans = -maxn;
scanf("%d%d%d%d", &l1, &r1, &l2, &r2);
for (int j = l1; j <= r1; j++) {
long long u = maxn;
for (int k = l2; k <= r2; k++) {
u = min(u, c[j][k]);
}
ans = max(ans, u);
}
printf("%lld\n", ans);
}
return 0;
}