#include <bits/stdc++.h>
using namespace std;
const int inf = 2e9;
const long double eps = 1e-12;
const int maxn = 1e6 + 12, base = 1e9 + 7;
const long long llinf = 4e18 + 5;
template <typename T>
string bin(T x, int st = 2) {
  string ans = "";
  while (x > 0) {
    ans += char('0' + x % st);
    x /= st;
  }
  reverse(ans.begin(), ans.end());
  return ans.empty() ? "0" : ans;
}
template <typename T>
void amax(T& x, T y) {
  x = max(x, y);
}
template <typename T>
void amin(T& x, T y) {
  x = min(x, y);
}
template <typename T>
T input() {
  T ans = 0, m = 1;
  char c = ' ';
  while (!((c >= '0' && c <= '9') || c == '-')) {
    c = getchar();
  }
  if (c == '-') m = -1, c = getchar();
  while (c >= '0' && c <= '9') {
    ans = ans * 10 + (c - '0'), c = getchar();
  }
  return ans * m;
}
template <typename T>
void read(T& a) {
  a = input<T>();
}
template <typename T>
void read(T& a, T& b) {
  read(a), read(b);
}
template <typename T>
void read(T& a, T& b, T& c) {
  read(a, b), read(c);
}
template <typename T>
void read(T& a, T& b, T& c, T& d) {
  read(a, b), read(c, d);
}
template <typename T>
T binpow(T n, T second) {
  if (second <= 0) return 1LL;
  if (second % 2 == 0) {
    T b = binpow(n, second / 2);
    return (1LL * b * b) % base;
  } else {
    return (1LL * binpow(n, second - 1) * n) % base;
  }
}
int n, m;
vector<int> second[maxn];
vector<int> g[maxn];
bool pushed[maxn];
int first[maxn];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  read(n, m);
  for (int i = 0; i < n; i++) {
    int l;
    read(l);
    while (l--) {
      int x;
      read(x);
      x--;
      second[i].push_back(x);
    }
  }
  for (int i = 0; i < m; i++) first[i] = -1;
  vector<pair<int, int> > e;
  queue<int> q;
  for (int i = 0; i + 1 < n; i++) {
    int frst = -1;
    for (int j = 0; j < min(second[i].size(), second[i + 1].size()); j++) {
      if (second[i][j] != second[i + 1][j]) {
        frst = j;
        break;
      }
    }
    if (frst == -1) {
      if (second[i].size() > second[i + 1].size()) {
        puts("No");
        return 0;
      }
      continue;
    }
    e.push_back(make_pair(second[i][frst], second[i + 1][frst]));
    int x = second[i][frst], y = second[i + 1][frst];
    if (x < y) {
      g[y].push_back(x);
    } else {
      if (first[x] == 0 || first[y] == 1) {
        puts("No");
        return 0;
      }
      first[x] = 1;
      first[y] = 0;
      if (!pushed[x]) {
        q.push(x);
        pushed[x] = 1;
      }
    }
  }
  while (!q.empty()) {
    int v = q.front();
    q.pop();
    for (int i = 0; i < g[v].size(); i++) {
      int to = g[v][i];
      if (first[to] == 0) {
        puts("No");
        return 0;
      }
      if (first[to] == -1) {
        first[to] = 1;
        q.push(to);
      }
    }
  }
  for (int i = 0; i < m; i++)
    if (first[i] == -1) first[i] = 0;
  for (int i = 0; i < e.size(); i++) {
    int x = e[i].first, y = e[i].second;
    if (first[x] == first[y]) {
      if (x > y) {
        puts("No");
        return 0;
      }
    }
    if (first[x] == 0 && first[y] == 1) {
      puts("No");
      return 0;
    }
  }
  vector<int> ans;
  for (int i = 0; i < m; i++)
    if (first[i] == 1) ans.push_back(i);
  cout << "Yes\n";
  cout << ans.size() << '\n';
  for (int i : ans) cout << i + 1 << ' ';
  return 0;
}
