#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 cur1 = a[i].first; int cur2 = a[i].second; if(s[cur1] < c){ s[cur1]++; fir++; vis[i] = true; } else if (s[cur2] < c){ s[cur2]++; sec++; 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"; }