#include <bits/stdc++.h>
using namespace std;
int n, m, h;
int a[300005];
int lv, comp;
int d[300005], low[300005], scc[300005];
bool vis[300005], nope[300005];
int cnt[300005];
stack<int> s;
namespace SCC {
struct S {
  S(int n) : low(n, 0), comp(n, -1), time(0), ncomp(0) {}
  int time;
  int ncomp;
  vector<int> low, comp;
  stack<int> pool;
};
template <class G>
int dfs(const G &g, S &s, int v) {
  int entry = s.low[v] = ++s.time;
  s.pool.push(v);
  for (auto &(u) : (g[v]))
    if (s.comp[u] == -1) s.low[v] = min(s.low[v], (s.low[u]) ?: dfs(g, s, u));
  if (entry == s.low[v]) {
    int u;
    do {
      u = s.pool.top();
      s.pool.pop();
      s.comp[u] = s.ncomp;
    } while (v != u);
    s.ncomp++;
  }
  return s.low[v];
}
template <class G>
vector<int> scc(const G &g) {
  int n = (int)(g).size();
  S s = S(n);
  for (int i = 0; i < n; i++)
    if (s.comp[i] == -1) dfs(g, s, i);
  return s.comp;
}
}  // namespace SCC
int main() {
  scanf("%d%d%d", &n, &m, &h);
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
    scc[i] = -1;
    d[i] = -1;
  }
  vector<vector<int>> edge(n);
  for (int i = 0; i < m; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    --x;
    --y;
    if ((a[x] + 1) % h == a[y]) edge[x].push_back(y);
    if ((a[y] + 1) % h == a[x]) edge[y].push_back(x);
  }
  vector<int> scc = SCC::scc(edge);
  for (int i = 0; i < n; i++) {
    cnt[scc[i]]++;
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < edge[i].size(); j++) {
      if (scc[i] != scc[edge[i][j]]) nope[scc[i]] = true;
    }
  }
  int cid = -1;
  for (int i = 0; i < n; i++) {
    if (nope[scc[i]]) continue;
    if (cid == -1 || cnt[scc[i]] < cnt[cid]) cid = scc[i];
  }
  printf("%d\n", cnt[cid]);
  vector<int> ans_v;
  for (int i = 0; i < n; i++) {
    if (scc[i] == cid) {
      ans_v.push_back(i + 1);
    }
  }
  for (int i = 0; i < ans_v.size(); i++) {
    if (i) printf(" ");
    printf("%d", ans_v[i]);
  }
  puts("");
  return 0;
}
