1: #include<iostream>
namespace std;
int m,n,k,l,d;
int maxn=3000;
int hen[maxn]={0},shu[maxn]={0},posh[maxn]={0},poss[maxn]={0};
bool opth[maxn]={0},opts[maxn]={0};
7:
void get_prepare()
9: {
int x1,y1,x2,y2;
11: cin >> n >> m >> k >> l >> d;
int i=0;i<d;i++){
13: cin >> x1 >> y1 >> x2 >> y2;
14: x1==x2?shu[(y1+y2)/2-1]++:hen[(x1+x2)/2-1]++;
15: }
int i=0;i<n;i++) posh[i]=i+1;
int i=0;i<m;i++) poss[i]=i+1;
18: }
int r)
20: {
int i=l,j=r,mid=hen[(l+r)/2],tmp;
while (i<=j){
while (hen[i]>mid) i++;
while (hen[j]<mid) j--;
if (i<=j){
26: tmp=hen[i];hen[i]=hen[j];hen[j]=tmp;
27: tmp=posh[i];posh[i++]=posh[j];posh[j--]=tmp;
28: }
29: }
if (i<r) sorth(i,r);
if (l<j) sorth(l,j);
32: }
int r)
34: {
int i=l,j=r,mid=shu[(l+r)/2],tmp;
while (i<=j){
while (shu[i]>mid) i++;
while (shu[j]<mid) j--;
if (i<=j){
40: tmp=shu[i];shu[i]=shu[j];shu[j]=tmp;
41: tmp=poss[i];poss[i++]=poss[j];poss[j--]=tmp;
42: }
43: }
if (i<r) sorts(i,r);
if (l<j) sorts(l,j);
46: }
int main()
48: {
49: get_prepare();
50: sorth(0,n-1);
51: sorts(0,m-1);
int i=0;i<k;i++) opth[posh[i]]=1;
' ';
'\n';
int i=0;i<l;i++) opts[poss[i]]=1;
' ';
'\n';
return 0;
59: }