#include <bits/stdc++.h>
using namespace std;
const int N = 200050;
int d[N], tim, t[N], siz[N], bl[N], st[N], dfn[N], low[N], ins[N], top, tot;
struct graph {
  int nn[N][2], cnt, head[N];
  void link(int u, int v) {
    nn[++cnt][1] = v, nn[cnt][0] = head[u], head[u] = cnt;
    return;
  }
  void tarjan(int x) {
    dfn[x] = low[x] = ++tim, st[++top] = x, ins[x] = 1;
    for (int i = head[x], y; i; i = nn[i][0])
      if (!dfn[y = nn[i][1]])
        tarjan(y), low[x] = (low[x] < low[y] ? low[x] : low[y]);
      else if (ins[y])
        low[x] = (low[x] < dfn[y] ? low[x] : dfn[y]);
    if (low[x] == dfn[x]) {
      ++tot;
      do bl[st[top]] = tot, ++siz[tot], ins[st[top]] = 0;
      while (st[top--] != x);
    }
    return;
  }
} G[2];
int main() {
  int n, m, h, u, v;
  cin >> n >> m >> h;
  for (int i = 1; i <= n; ++i) scanf("%d", &t[i]);
  for (int i = 1; i <= m; ++i) {
    scanf("%d%d", &u, &v);
    if ((t[u] + 1) % h == t[v]) G[0].link(u, v);
    if ((t[v] + 1) % h == t[u]) G[0].link(v, u);
  }
  for (int i = 1; i <= n; ++i)
    if (!dfn[i]) G[0].tarjan(i);
  for (int x = 1; x <= n; ++x)
    for (int i = G[0].head[x], y; i; i = G[0].nn[i][0])
      if (bl[y = G[0].nn[i][1]] != bl[x]) ++d[bl[x]];
  int mn = 1e9, id = 0;
  for (int i = 1; i <= tot; ++i)
    if (!d[i] && siz[i] < mn) mn = siz[i], id = i;
  cout << siz[id] << endl;
  for (int i = 1; i <= n; ++i)
    if (bl[i] == id) printf("%d ", i);
  return 0;
}
