#include <bits/stdc++.h>
using namespace std;
const int N = 1005;
int n, k, t, xl, yd, xr, yu;
struct people
{
int id;
int cishu;
} p[25];
int main()
{
cin >> n >> k >> t >> xl >> yd >> xr >> yu;
int ans1 = 0, ans2 = 0;
for (int i = 0; i < n; i++)
{
p[i].id = i;
int xx, yy;
int lianxu = 0;
int tt = 0;
for (int j = 0; j < t; j++)
{
cin >> xx >> yy;
if (xx >= xl && xx <= xr && yy >= yd && yy <= yu)
{
if (lianxu == 0)
{
lianxu++;
tt = j;
}
else if (lianxu > 0 && tt == j - 1)
{ // 之前有&&上一个t为上一时刻
lianxu++;
tt = j;
}
else if (lianxu > 0 && tt != j - 1)
{ // 不连续
p[i].cishu = max(p[i].cishu, lianxu);
lianxu = 1;
tt = j;
}
}
}
p[i].cishu = max(p[i].cishu, lianxu);
lianxu = 0;
tt = 0;
}
for (int i = 0; i < n; i++)
{
if (p[i].cishu > 0)
ans1++;
if (p[i].cishu >= k)
ans2++;
}
cout << ans1 << endl
<< ans2;
}
(好简单。。还以为要用二维前缀和。。)