#include <iostream>
using namespace std;//判断是否在区域
bool isIn(int xl, int yd, int xr, int yu, int x, int y)
{if ((x >= xl && x <= xr) && (y >= yd && y <= yu)){return true;}return false;
}struct position
{int a, b;
}po[1005];
int main()
{int n, k, t, xl, yd, xr, yu;cin >> n >> k >> t >> xl >> yd >> xr >> yu;int max = 0;int d1 = 0, d2 = 0;while (n--){max = 0;int count = 0;for (int i = 0; i < t; i++){cin >> po[i].a >> po[i].b;if (isIn(xl, yd, xr, yu, po[i].a, po[i].b) == true){count++;}else{count = 0;}if (count > max){max = count;}}if (max >= k){d2++;}else if (max >= 1){d1++;}}cout << d1 + d2 << endl;cout << d2 << endl;
}