#include using namespace std; int n, m, c; int used[101010]; pair t[101010]; int main() { cin >> n >> m >> c; for (int i = 1; i <= n; i++) { cin >> t[i].first >> t[i].second; } int A = 0, B = 0; for (int i = 1; i <= n; i++) { if (used[t[i].first] < c) { used[t[i].first]++; A++; continue; } if (used[t[i].second] < c) { used[t[i].second]++; B++; continue; } } cout << A << " " << B << '\n'; return 0; }