#include <bits/stdc++.h>
using namespace std;
const double PI = 3.1415926535897932384626433;
const long long mod = 1000000007;
const int INF = 0x3f3f3f3f;
const double eps = 1e-8;
template <class T>
T gcd(T a, T b) {
  if (!b) return a;
  return gcd(b, a % b);
}
const int maxn = 1e5 + 10;
vector<int> edg[maxn], vi, ans;
int now[maxn], nxt[maxn], len1, len2, n, m, vis[maxn], st[maxn], flg;
void dfs(int u) {
  if (st[u] < 0) flg = 0;
  if (flg == 0) return;
  vis[u] = 1;
  ans.push_back(u);
  for (int i = 0; i < edg[u].size(); i++) {
    int nxt = edg[u][i];
    if (st[nxt] < 0) flg = 0;
    if (!vis[nxt]) dfs(nxt);
  }
}
int deal(int *a1, int *a2) {
  int len = min(len1, len2);
  for (int i = 0; i < len; i++) {
    if (a1[i] < a2[i]) {
      edg[a2[i]].push_back(a1[i]);
      return 1;
    } else if (a1[i] > a2[i]) {
      vi.push_back(a1[i]);
      if (st[a1[i]] == -1 || st[a2[i]] == 1) return 0;
      st[a1[i]] = 1;
      st[a2[i]] = -1;
      return 1;
    }
  }
  return len1 <= len2;
}
int solve() {
  memset(st, 0, sizeof(st));
  int *a1 = now, *a2 = nxt;
  scanf("%d", &len1);
  for (int i = 0; i < len1; i++) scanf("%d", &a1[i]);
  flg = 1;
  for (int t = 1; t < n; t++) {
    scanf("%d", &len2);
    for (int i = 0; i < len2; i++) scanf("%d", &a2[i]);
    if (deal(a1, a2) == 0) flg = 0;
    swap(a1, a2);
    len1 = len2;
  }
  memset(vis, 0, sizeof(vis));
  for (int i = 0; i < vi.size(); i++)
    if (!vis[vi[i]]) dfs(vi[i]);
  return flg;
}
int main() {
  scanf("%d", &n);
  scanf("%d", &m);
  if (solve()) {
    printf("Yes\n%d\n", ans.size());
    for (int i = 0; i < ans.size(); i++) printf("%d ", ans[i]);
    puts("");
  } else {
    printf("No\n");
  }
  return 0;
}
