#include <bits/stdc++.h>
int const maxn = 200003;
int n = 0, m = 0, h = 0;
int t[maxn];
int head[maxn], nxt[maxn], to[maxn], cnt = 0;
inline void insert(int u, int e) {
  nxt[++cnt] = head[u];
  head[u] = cnt;
  to[cnt] = e;
}
int dfn[maxn], low[maxn], cdfn = 0;
int st[maxn], top = 0;
bool in[maxn];
int sym[maxn], siz[maxn];
void tarjan(int x) {
  dfn[x] = low[x] = ++cdfn;
  st[++top] = x;
  in[x] = true;
  for (int i = head[x]; i; i = nxt[i])
    if (!dfn[to[i]]) {
      tarjan(to[i]);
      low[x] = std::min(low[x], low[to[i]]);
    } else if (in[to[i]])
      low[x] = std::min(low[x], dfn[to[i]]);
  if (dfn[x] == low[x]) {
    int y = 0;
    do {
      y = st[top--];
      in[y] = false;
      sym[y] = x;
      ++siz[x];
    } while (y != x);
  }
}
int d[maxn];
int main() {
  scanf("%d %d %d", &n, &m, &h);
  for (int i = 1; i <= n; ++i) scanf("%d", t + i);
  int x = 0, y = 0;
  for (int i = 1; i <= m; ++i) {
    scanf("%d %d", &x, &y);
    if ((t[x] + 1) % h == t[y]) insert(x, y);
    if ((t[y] + 1) % h == t[x]) insert(y, x);
  }
  for (int i = 1; i <= n; ++i)
    if (!dfn[i]) tarjan(i);
  for (int x = 1; x <= n; ++x)
    for (int i = head[x]; i; i = nxt[i])
      if (sym[to[i]] != sym[x]) ++d[sym[x]];
  int j = 0, s = 0x3f3f3f3f;
  for (int i = 1; i <= n; ++i)
    if (sym[i] == i && d[i] == 0 && siz[i] < s) {
      j = i;
      s = siz[i];
    }
  printf("%d\n", s);
  for (int i = 1; i <= n; ++i)
    if (sym[i] == j) printf("%d ", i);
  printf("\n");
  return 0;
}
