#include <bits/stdc++.h>
using namespace std;
const int MAXN = 100001;
int fir[MAXN], nxt[MAXN << 1], to[MAXN << 1], from[MAXN << 1], cnt;
int dfn[MAXN], low[MAXN], tim;
int scc[MAXN], size[MAXN], num, minsize = 99999999;
int t[MAXN], du[MAXN];
bool vis[MAXN];
stack<int> S;
inline int read() {
  int k = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    k = k * 10 + ch - '0';
    ch = getchar();
  }
  return k * f;
}
inline void add_edge(int a, int b) {
  from[++cnt] = a;
  to[cnt] = b;
  nxt[cnt] = fir[a];
  fir[a] = cnt;
}
void Tarjan(int u) {
  dfn[u] = low[u] = ++tim;
  S.push(u), vis[u] = true;
  for (int i = fir[u]; i != -1; i = nxt[i]) {
    int v = to[i];
    if (!dfn[v]) {
      Tarjan(v);
      low[u] = min(low[u], low[v]);
    } else if (vis[v])
      low[u] = min(low[u], dfn[v]);
  }
  if (low[u] == dfn[u]) {
    num++;
    while (1) {
      int x = S.top();
      S.pop();
      scc[x] = num;
      size[num]++;
      if (x == u) break;
    }
  }
}
int main() {
  memset(fir, -1, sizeof(fir));
  int n = read(), m = read(), h = read(), rec;
  for (int i = 1; i <= n; i++) t[i] = read();
  for (int i = 1; i <= m; i++) {
    int u = read(), v = read();
    if ((t[u] + 1) % h == t[v]) add_edge(u, v);
    if ((t[v] + 1) % h == t[u]) add_edge(v, u);
  }
  for (int i = 1; i <= n; i++)
    if (!dfn[i]) Tarjan(i);
  for (int i = 1; i <= n; i++) {
    for (int j = fir[i]; j != -1; j = nxt[j]) {
      int x = to[j];
      if (scc[x] != scc[i]) {
        du[scc[i]]++;
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    if (!du[scc[i]] && size[scc[i]] < minsize) {
      minsize = size[scc[i]];
      rec = scc[i];
    }
  }
  printf("%d\n", minsize);
  for (int i = 1; i <= n; i++) {
    if (scc[i] == rec) printf("%d ", i);
  }
  return 0;
}
