#include #define int long long using namespace std; string to_string(string s) { return s; } template string to_string(T v) { string res = "["; for (const auto &x : v) { res += to_string(x) + ", "; } res += "]"; return res; } void dbg_out() { cout << endl; } template void dbg_out(Head H, Tail... T) { cout << ' ' << to_string(H); dbg_out(T...); } #ifdef DEBUG #define dbg(...) cout << "(" << #__VA_ARGS__ << "):", dbg_out(__VA_ARGS__) #else #define dbg(...) #endif using ll = long long; using vi = vector; #define rep(i, a, b) for (int i = (a); i < (b); ++i) #define all(v) (v).begin(), (v).end() #define sz(v) ((int)(v).size()) const int MAX_ACTIVITIES = 2e6; map , bool> Compared; vector Peoples[MAX_ACTIVITIES]; vector Contain[MAX_ACTIVITIES]; int nbPeoples, nbActivities; bool SortSz(int a, int b) { return Peoples[a].size() < Peoples[b].size(); } int Inside(int target, int id) { int pos = -1; int sz = Peoples[id].size(); for (int jump = 1 << 20; jump; jump >>= 1) { if (pos + jump < sz && Peoples[id][pos + jump] <= target) pos += jump; } return Peoples[id][pos] == target; } int Check(int a, int b) { int small = Peoples[a].size(); int big = Peoples[b].size(); if (small < big / 10) { for (int act : Peoples[a]) { if (!Inside(act, b)) return 0; } return 1; } int cur = 0; for (int i = 0; i < small; i ++) { while (cur < big && Peoples[b][cur] != Peoples[a][i]) cur ++; if (cur == big) return 0; } return 1; } pair Solve(int cur) { sort(Contain[cur].begin(), Contain[cur].end(), SortSz); for (int i = 1; i < (int)Contain[cur].size(); i ++) { int a = Contain[cur][i - 1], b = Contain[cur][i]; if (Compared[make_pair(a, b)]) continue; if (Check(a, b)) Compared[make_pair(a, b)] = 1; else { return make_pair(a, b); } } return make_pair(-1, -1); } void Read() { cin >> nbPeoples >> nbActivities; for (int i = 0; i < nbPeoples; i ++) { int nb; cin >> nb; for (int j = 0; j < nb; j ++) { int a; cin >> a; Peoples[i].push_back(a); Contain[a].push_back(i); } sort(Peoples[i].begin(), Peoples[i].end()); } for (int act = 0; act <= nbActivities; act ++) { pair ans = Solve(act); if (ans.first >= 0) { printf("YES\n%lld %lld\n", ++ ans.first, ++ ans.second); return; } } cout << "NO" << endl; return; } signed main() { ios_base::sync_with_stdio(false); cin.tie(0); Read(); return 0; }