#include<bits/stdc++.h>
using namespace std;
//注意cmath里面有y1函数,所以变量不能出现y1
int n,k,t,x11,y11,x22,y22;
int main(){
cin>>n>>k>>t>>x11>>y11>>x22>>y22;
int res1=0,res2=0;
while(n--){
int s=0;
bool r1=false,r2=false;
for(int i=0;i<t;i++){
int x,y;
cin>>x>>y;
if(x>=x11&&x<=x22&&y>=y11&&y<=y22) {
s++;
r1=true;
if(s>=k) r2=true;
}
else s=0;
}
if(r1) res1++;
if(r2) res2++;
}
cout<<res1<<endl<<res2;
return 0;
}