#include //#define int long long using namespace std; signed main(){ cin.tie(0); ios::sync_with_stdio(0); int n, m, c; cin >> n >> m >> c; vector> a(n); vector s(m, 0); int fir = 0; int sec = 0; vector vis(n, false); for(int i = 0; i < n; i++){ int x, y; cin >> x >> y; x--;y--; a[i] = {x,y}; } for(int i = 0; i < n; i++){ int cur = a[i].first; if(s[cur] < c){ fir++; s[cur]++; vis[i] = true; } } for(int i = 0; i < n; i++){ int cur = a[i].second; if(s[cur] < c && !vis[i]){ sec++; s[cur]++; } } cout << fir << " " << sec << "\n"; }