#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 10;
int n, m, h, u, v, a[maxn];
struct Edge {
  int to, nex;
} edge[maxn << 1];
int head[maxn], ecnt;
void add_edge(int u, int v) {
  edge[++ecnt] = {v, head[u]};
  head[u] = ecnt;
}
int color, id, Index;
int vis[maxn], dfn[maxn], stk[maxn], low[maxn], belong[maxn], sz[maxn];
void tarjan(int now) {
  dfn[now] = low[now] = ++color;
  stk[++Index] = now;
  vis[now] = 1;
  for (int i = head[now]; i; i = edge[i].nex) {
    int to = edge[i].to;
    if (!dfn[to]) {
      tarjan(to);
      low[now] = min(low[now], low[to]);
    } else if (vis[to])
      low[now] = min(low[now], dfn[to]);
  }
  if (low[now] == dfn[now]) {
    id++;
    while (1) {
      belong[stk[Index]] = id;
      sz[id]++;
      vis[stk[Index]] = 0;
      Index--;
      if (now == stk[Index + 1]) break;
    }
  }
}
int dgr[maxn];
int main() {
  scanf("%d %d %d", &n, &m, &h);
  for (int i = 1; i <= n; i++) scanf("%d", a + i);
  for (int i = 1; i <= m; i++) {
    scanf("%d %d", &u, &v);
    if ((a[u] + 1) % h == a[v]) add_edge(u, v);
    if ((a[v] + 1) % h == a[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 = head[i]; j; j = edge[j].nex) {
      int to = edge[j].to;
      if (belong[i] != belong[to]) dgr[belong[i]]++;
    }
  }
  int best = n + 1, ans = 0;
  for (int i = 1; i <= id; i++) {
    if (dgr[i]) continue;
    if (best > sz[i]) {
      ans = i;
      best = sz[i];
    }
  }
  printf("%d\n", best);
  for (int i = 1; i <= n; i++)
    if (belong[i] == ans) printf("%d ", i);
  return 0;
}
