#include <bits/stdc++.h>
using namespace std;
const int MAXN = 100044;
const int INF = 1e9 + 7;
vector<int> G[MAXN], scc[MAXN];
int pre[MAXN], lowlink[MAXN], sccno[MAXN], dfs_clock, scc_cnt;
stack<int> S;
struct edge {
  int from, to;
};
vector<edge> edges;
void dfs(int u) {
  pre[u] = lowlink[u] = ++dfs_clock;
  S.push(u);
  for (int i = 0; i < G[u].size(); ++i) {
    int v = G[u][i];
    if (!pre[v]) {
      dfs(v);
      lowlink[u] = min(lowlink[u], lowlink[v]);
    } else if (!sccno[v])
      lowlink[u] = min(lowlink[u], pre[v]);
  }
  if (lowlink[u] == pre[u]) {
    scc_cnt++;
    scc[scc_cnt].clear();
    while (1) {
      int x = S.top();
      S.pop();
      if (sccno[x] != scc_cnt) scc[scc_cnt].push_back(x);
      sccno[x] = scc_cnt;
      if (x == u) break;
    }
  }
}
void find_scc(int n) {
  dfs_clock = scc_cnt = 0;
  memset(sccno, 0, sizeof(sccno));
  memset(pre, 0, sizeof(pre));
  for (int i = 1; i <= n; ++i)
    if (!pre[i]) dfs(i);
}
void adde(int u, int v) {
  G[u].push_back(v);
  edges.push_back(edge{u, v});
}
int n, m, h, H[MAXN], out[MAXN], u[MAXN], v[MAXN];
int trans(int x) { return (x + 1) % h; }
int main() {
  scanf("%d%d%d", &n, &m, &h);
  for (int i = 1; i <= n; ++i) scanf("%d", H + i);
  for (int i = 1; i <= m; ++i) {
    int x, y;
    scanf("%d%d", &x, &y);
    if (trans(H[x]) == H[y]) adde(x, y);
    if (trans(H[y]) == H[x]) adde(y, x);
  }
  for (int i = 1; i <= n; ++i) reverse(G[i].begin(), G[i].end());
  find_scc(n);
  for (int i = 0; i < edges.size(); ++i) {
    int x = edges[i].from;
    int y = edges[i].to;
    if (sccno[x] != sccno[y]) ++out[sccno[x]];
  }
  int ans = INF, ind;
  for (int i = 1; i <= scc_cnt; ++i)
    if (out[i] == 0 && scc[i].size() < ans) ans = scc[i].size(), ind = i;
  printf("%d\n", ans);
  for (int i = 0; i < scc[ind].size(); ++i)
    printf("%d%c", scc[ind][i], " \n"[i == scc[ind].size() - 1]);
  return 0;
}
