#include <bits/stdc++.h>
using namespace std;
int main(){
int n,k,t,x1,y1,x2,y2;
cin >> n >> k >> t >> x1 >> y1 >> x2 >> y2;
int ans1 = 0;
int ans2 = 0;
for(int i = 0;i < n;i++){
bool flag = false;
vector p;
for(int j = 0;j < t;j++){
int a,b;cin >> a >> b;
if(a >= x1 && a <= x2 && b <= y2 && b >= y1){
flag = true;
p.push_back(j);
}
}
if(flag){
ans1++;
bool flag2 = false;
for(int j = 0;j < p.size();j++){
if(j+k-1 < p.size() && p[j+k-1] == p[j] + k - 1){
flag2 = true;
break;
}
}
if(flag2){
ans2++;
}
}
}
cout << ans1 << endl << ans2 << endl;
}