#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5;
int v[N];
vector<int> edge[N];
vector<int> compId[N];
int outdeg[N];
bool viz[N];
bool in_s[N];
stack<int> st;
int fr = 0;
int tin[N], low[N];
int comp[N], compSz[N];
int noComp = 0;
int u[N];
void dfs(int x) {
  fr++;
  viz[x] = true;
  in_s[x] = true;
  st.push(x);
  tin[x] = low[x] = fr;
  for (auto &it : edge[x]) {
    if (viz[it] == false) {
      dfs(it);
      low[x] = min(low[x], low[it]);
    } else if (in_s[it] == true) {
      low[x] = min(low[x], tin[it]);
    }
  }
  if (low[x] == tin[x]) {
    int y;
    noComp++;
    do {
      y = st.top();
      st.pop();
      comp[y] = noComp;
      in_s[y] = false;
      compId[noComp].emplace_back(y);
      compSz[noComp]++;
    } while (x != y);
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n, m, h;
  cin >> n >> m >> h;
  for (int i = 1; i <= n; i++) {
    cin >> u[i];
  }
  for (int i = 1; i <= m; i++) {
    int x, y;
    cin >> x >> y;
    int nxt = u[x] + 1;
    if (nxt == h) {
      nxt = 0;
    }
    if (nxt == u[y]) {
      edge[x].emplace_back(y);
    }
    nxt = u[y] + 1;
    if (nxt == h) {
      nxt = 0;
    }
    if (nxt == u[x]) {
      edge[y].emplace_back(x);
    }
  }
  for (int i = 1; i <= n; i++) {
    if (viz[i] == 0) {
      dfs(i);
    }
  }
  for (int i = 1; i <= n; i++) {
    for (auto &it : edge[i]) {
      if (comp[i] != comp[it]) outdeg[comp[i]]++;
    }
  }
  int id = 0;
  compSz[0] = n + 5;
  for (int i = 1; i <= noComp; i++) {
    if (outdeg[i] == 0 && compSz[i] < compSz[id]) {
      id = i;
    }
  }
  cout << compId[id].size() << '\n';
  for (auto &it : compId[id]) {
    cout << it << ' ';
  }
  return 0;
}
