#include <bits/stdc++.h>
using namespace std;
inline void read(int &x) {
  x = 0;
  char ch = getchar();
  int pd = 1;
  while (ch < '0' || ch > '9') {
    if (ch == '-') {
      pd = -pd;
    }
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  x *= pd;
}
inline void write(const int &x) {
  char ggg[10001];
  int s = 0;
  int tmp = x;
  if (tmp == 0) {
    putchar('0');
    return;
  }
  if (tmp < 0) {
    tmp = -tmp;
    putchar('-');
  }
  while (tmp > 0) {
    ggg[s++] = tmp % 10 + '0';
    tmp /= 10;
  }
  while (s > 0) {
    putchar(ggg[--s]);
  }
}
const int N = 3e5 + 7, M = 3e6 + 7;
int t, h[N], dfn[N], low[N], id[N], num, cnt, cc, ans[N], n, m;
bool vis[N];
int a[2][1000001];
struct dd {
  int end, nt;
} e[M];
inline void add(int begin, int end) {
  ++t;
  e[t].end = end;
  e[t].nt = h[begin];
  h[begin] = t;
}
stack<int> st;
void tarjan(int x) {
  dfn[x] = low[x] = ++num;
  st.push(x);
  for (register int i = h[x]; i; i = e[i].nt) {
    int u = e[i].end;
    if (!dfn[u]) {
      tarjan(u);
      low[x] = (low[x] < low[u] ? low[x] : low[u]);
    } else {
      if (!id[u]) {
        low[x] = (low[x] < dfn[u] ? low[x] : dfn[u]);
      }
    }
  }
  if (dfn[x] == low[x]) {
    id[x] = ++cnt;
    while (st.top() != x) {
      id[st.top()] = cnt;
      st.pop();
    }
    st.pop();
  }
}
void wrl(const int &x) {
  write(x);
  puts("");
}
void wrs(const int &x) {
  write(x);
  putchar(' ');
}
int main() {
  read(m);
  read(n);
  int lasta;
  for (register int i = 1; i <= m; ++i) {
    int aa;
    read(aa);
    int now = (i & 1);
    bool flag = false;
    for (register int j = 1; j <= aa; ++j) {
      read(a[now][j]);
      if (i > 1 && !flag) {
        if (j > lasta) continue;
        if (a[now][j] < a[now ^ 1][j]) {
          add(a[now ^ 1][j] + n, a[now ^ 1][j]);
          add(a[now][j], a[now][j] + n);
          flag = 1;
        }
        if (a[now][j] > a[now ^ 1][j]) {
          add(a[now ^ 1][j] + n, a[now][j] + n);
          add(a[now][j], a[now ^ 1][j]);
          flag = 1;
        }
        if (j == aa && lasta > aa && !flag) {
          puts("No");
          return 0;
        }
      }
    }
    lasta = aa;
  }
  for (register int i = 1; i <= 2 * n; ++i) {
    if (!dfn[i]) {
      tarjan(i);
    }
  }
  for (register int i = 1; i <= n; ++i) {
    if (id[i] == id[i + n]) {
      puts("No");
      return 0;
    }
  }
  puts("Yes");
  int cc = 0;
  for (register int i = 1; i <= n; ++i) {
    if (id[i] < id[i + n]) {
      ans[++cc] = i;
    }
  }
  wrl(cc);
  for (register int i = 1; i <= cc; ++i) {
    wrs(ans[i]);
  }
}
