#include #define all(a) a.begin(),a.end() #define len(a) (int)(a.size()) #define fir first #define sec second #define fi first #define se second #define mp make_pair #define pb push_back using namespace std; typedef pair pii; typedef long long ll; typedef long double ld; template bool umin(T &a, T b) { if (b < a) { a = b; return 1; } return 0; } template bool umax(T &a, T b) { if (a < b) { a = b; return 1; } return 0; } #ifdef KIVI #define DEBUG for (int _____DEBUG=1;_____DEBUG;_____DEBUG=0) #define LOG(...) prnt(#__VA_ARGS__" ::",__VA_ARGS__)< auto &prnt(Ts ...ts) { return ((cerr << ts << " "), ...); } #else #define DEBUG while (false) #define LOG(...) #endif const int max_n = 200222, inf = 1000111222; const int max_m = 1000111; int n, m, last[max_m]; vector ids[max_n], v; bool cmp(int i, int j) { return ids[i].size() > ids[j].size(); } int main() { // freopen("input.txt","r",stdin); // freopen("output.txt","w",stdout); ios_base::sync_with_stdio(0); cin.tie(0); cin >> n >> m; ++m; v.resize(n); for (int i = 0; i < n; ++i) { v[i] = i; int k; cin >> k; ids[i].resize(k); for (int &x : ids[i]) { cin >> x; } } sort(v.begin(), v.end(), cmp); ::memset(last, -1, sizeof(last)); int num = 0; for (int i : v) { int mx = -inf, mn = inf; for (int j : ids[i]) { mx = max(mx, last[j]); mn = min(mn, last[j]); last[j] = num; } if (mn != mx && mn != inf) { cout << "YES\n"; cout << v[mx] + 1 << " " << i + 1 << "\n"; return 0; } ++num; } cout << "NO\n"; exit(0); }