#include <iostream> #include<set> #include<vector> #include<unordered_map> #include<algorithm> using namespace std; struct compare { bool operator()(const pair<int, int>& a, const pair<int, int>& b) { return a.second > b.second; } }; int main() { int n, m, k, l, d; cin >> n >> m >> k >> l >> d; unordered_map<int, int>row; unordered_map<int, int>column; while (d--) { int x, y, p, q; cin >> x >> y >> p >> q; if (x == p) column[min(y, q)]++; else if (y == q) row[min(x, p)]++; } multiset<pair<int, int>, compare>r_sort; multiset<pair<int, int>, compare>c_sort; vector<int>r_a; vector<int>r_b; for (const auto& x : row) r_sort.insert(x); for (const auto& x : column) c_sort.insert(x); int i = 0; for (const auto& x : r_sort) { if (i < k) { r_a.push_back(x.first); i++; } else break; } i=0; for (const auto& x : c_sort) { if (i < l) { r_b.push_back(x.first); i++; } else break; } sort(r_a.begin(), r_a.end()); sort(r_b.begin(), r_b.end()); for (int x : r_a) cout << x << " "; cout << endl; for (int x : r_b) cout << x << " "; } // 64 位输出请用 printf("%lld")