#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e5;
int v[MAXN + 1], scc[MAXN + 1], seen[MAXN + 1], sz[MAXN + 1], out[MAXN + 1];
vector<int> g[MAXN + 1], gt[MAXN + 1], stk;
inline void add_edg(int x, int y, int h) {
  if ((v[x] + 1) % h == v[y]) {
    g[x].push_back(y);
    gt[y].push_back(x);
  }
}
void regular_dfs(int node) {
  seen[node] = 1;
  for (auto it : g[node])
    if (seen[it] == 0) regular_dfs(it);
  stk.push_back(node);
}
void trans_dfs(int node, int comp) {
  seen[node] = 0;
  for (auto it : gt[node])
    if (seen[it]) trans_dfs(it, comp);
  scc[node] = comp;
  ++sz[comp];
}
int main() {
  int n, m, h;
  cin >> n >> m >> h;
  for (int i = 1; i <= n; ++i) cin >> v[i];
  for (int i = 0; i < m; ++i) {
    int x, y;
    cin >> x >> y;
    add_edg(x, y, h);
    add_edg(y, x, h);
  }
  for (int i = 1; i <= n; ++i)
    if (seen[i] == 0) regular_dfs(i);
  int acc = 0;
  while (stk.empty() == false) {
    if (seen[stk.back()]) trans_dfs(stk.back(), ++acc);
    stk.pop_back();
  }
  for (int i = 1; i <= n; ++i)
    for (auto it : g[i])
      if (scc[i] ^ scc[it]) ++out[scc[i]];
  int comp = 0;
  sz[0] = MAXN + 1;
  for (int i = 1; i <= n; ++i)
    if (sz[scc[i]] < sz[comp] && out[scc[i]] == 0) comp = scc[i];
  cout << sz[comp] << '\n';
  for (int i = 1; i <= n; ++i)
    if (scc[i] == comp) cout << i << " ";
  return 0;
}
