#include using namespace std; const int N = (int) 1e6 + 7; int n, m, allord[N]; vector v[N]; vector la[N]; bool cmp1(int i, int j) { if ((int) v[i].size() == (int) v[j].size()) { return v[i] < v[j]; } return (int) v[i].size() < (int) v[j].size(); } void print(vector a) { cout << " ---> "; for (auto &x : a) { cout << x << " "; } cout << "\n"; } bool incl(vector &sm, vector &bg) { int ptr = 0; for (auto &x : sm) { while (ptr < (int) bg.size() && bg[ptr] < x) ptr++; if (ptr < (int) bg.size() && bg[ptr] == x) { ptr++; continue; } return 0; } return 1; } void solvetc() { cin >> n >> m; for (int i = 1; i <= n; i++) { int k; cin >> k; v[i].resize(k); for (auto &x : v[i]) { cin >> x; } sort(v[i].begin(), v[i].end()); allord[i] = i; } sort(allord + 1, allord + n + 1, cmp1); vector ord; ord.push_back(allord[1]); for (int i = 2; i <= n; i++) { if (v[allord[i - 1]] == v[allord[i]]) continue; ord.push_back(allord[i]); } for (auto &i : ord) for (auto &x : v[i]) la[x].push_back(i); for (int x = 1; x <= m; x++) { sort(la[x].begin(), la[x].end(), [&] (int i, int j) {return (int) v[i].size() < (int) v[j].size();}); for (int j = 1; j < (int) la[x].size(); j++) { // cout << "lol " << la[x][j - 1] << " and " << la[x][j] << "\n"; if(!incl(v[la[x][j - 1]], v[la[x][j]])) { cout << "YES\n"; cout << la[x][j - 1] << " " << la[x][j] << "\n"; exit(0); } } } cout << "NO\n"; exit(0); return; cout << " : "; for (auto &i : ord) { // print(v[i]); cout << i << " "; } cout << "\n"; } int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); int t = 1; // cin >> t; while (t--) { solvetc(); } return 0; }