#include<iostream>
using namespace std;
typedef struct coordinate//定义坐标类型,处理更加方便
{
int x,y;
}coordinate;
int main(void)
{
int n,k,t,xl,yd,xr,yu;//按题目中要求命名一致,思路更清晰
cin>>n>>k>>t>>xl>>yd>>xr>>yu;//第一行输入
coordinate pos[n][t];//坐标,用矩阵n*t矩阵存储总的位置信息
for(int i=0;i<n;i++)
{
for(int j=0;j<t;j++)
{
cin>>pos[i][j].x>>pos[i][j].y;
}
}
int pass=0;//经过人数
int stay=0;//逗留人数
for(int i=0;i<n;i++)
{
int temp=0;//temp用于记录连续多少个节点经过危险区域
bool flag=false;//标志变量标志是否经过危险区域
for(int j=0;j<t;j++)
{
if(pos[i][j].x>=xl && pos[i][j].x<=xr && pos[i][j].y>=yd && pos[i][j].y<=yu)
{
flag=true;
temp++;
if(temp>=k)//当连续的经过点数量达到k时直接跳出循环
break;
}
else
{
temp=0;
}
}
if(!flag);
else if(flag && temp<k)pass++;//只经过不逗留
else//逗留一定经过
{
pass++;
stay++;
}
}
cout<<pass<<'\n'<<stay;
return 0;
}