#include <bits/stdc++.h>
using namespace std;
vector<int> v[200001];
vector<int> g[200001];
bool reached[200001];
bool visited[200001];
bool cycle = false;
int indeg[200001];
bool mark[200001];
vector<int> revg[200001];
void dfs(int pos) {
  reached[pos] = true;
  for (int i = 0; i < g[pos].size(); i++) {
    if (!reached[g[pos][i]]) {
      dfs(g[pos][i]);
    } else {
      if (!visited[g[pos][i]]) {
        cycle = true;
      }
    }
  }
  visited[pos] = true;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n, m;
  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    int x;
    cin >> x;
    for (int j = 0; j < x; j++) {
      int y;
      cin >> y;
      v[i].push_back(y);
    }
  }
  for (int i = 1; i < n; i++) {
    for (int j = 0; j < v[i].size(); j++) {
      if (j < v[i + 1].size()) {
        if (v[i][j] == v[i + 1][j]) {
          continue;
        } else {
          g[v[i][j]].push_back(v[i + 1][j]);
          revg[v[i + 1][j]].push_back(v[i][j]);
          indeg[v[i][j]]++;
          if (v[i][j] > v[i + 1][j]) {
            mark[v[i][j]] = true;
          }
          break;
        }
      } else {
        break;
      }
    }
  }
  for (int i = 1; i <= m; i++) {
    if (!reached[i]) {
      dfs(i);
    }
  }
  if (cycle) {
    cout << "No" << endl;
  } else {
    queue<int> q;
    for (int i = 1; i <= m; i++) {
      if (!indeg[i]) {
        q.push(i);
      }
    }
    while (!q.empty()) {
      int x = q.front();
      q.pop();
      for (int i = 0; i < revg[x].size(); i++) {
        indeg[revg[x][i]]--;
        if (!indeg[revg[x][i]]) {
          q.push(revg[x][i]);
          mark[revg[x][i]] |= mark[x];
        }
      }
    }
    bool flag = true;
    vector<int> ans;
    for (int i = 1; i < n; i++) {
      for (int j = 0; j < v[i].size(); j++) {
        if (j < v[i + 1].size()) {
          if (v[i][j] != v[i + 1][j]) {
            if (mark[v[i][j]]) {
              if (mark[v[i + 1][j]] && (v[i][j] > v[i + 1][j])) {
                flag = false;
              }
            } else {
              if (mark[v[i + 1][j]]) {
                flag = false;
              } else {
                if (v[i][j] > v[i + 1][j]) {
                  flag = false;
                }
              }
            }
            break;
          }
        } else {
          flag = false;
          break;
        }
      }
    }
    if (!flag) {
      cout << "No\n";
      return 0;
    }
    for (int i = 1; i <= m; i++) {
      if (mark[i]) {
        ans.push_back(i);
      }
    }
    cout << "Yes\n";
    cout << ans.size() << endl;
    for (int i = 0; i < ans.size(); i++) {
      cout << ans[i] << " ";
    }
    cout << endl;
  }
}
