#include <bits/stdc++.h>
using namespace std;
int n, m, h, u[100001], visit[100001], low[100001], num[100001], cur,
    Min = INT_MAX;
vector<int> adj[100001], comp;
set<int> scc, res;
bool checkScc() {
  for (int i : scc)
    for (int j : adj[i])
      if (scc.find(j) == scc.end()) return false;
  return true;
}
void dfs(int x) {
  if (num[x] != 0) return;
  visit[x] = 1;
  comp.push_back(x);
  num[x] = low[x] = cur++;
  for (int i : adj[x]) {
    if (num[i] == 0) dfs(i);
    if (visit[i]) low[x] = min(low[x], low[i]);
  }
  if (low[x] == num[x]) {
    scc.clear();
    while (1) {
      int v = comp.back();
      comp.pop_back();
      visit[v] = 0;
      scc.insert(v);
      if (v == x) break;
    }
    if (checkScc() && scc.size() < Min) {
      res = scc;
      Min = scc.size();
    }
  }
}
void setup() {
  cin >> n >> m >> h;
  for (int i = 1; i <= n; ++i) cin >> u[i];
  for (int i = 1; i <= m; ++i) {
    int c1, c2;
    cin >> c1 >> c2;
    int temp = u[c2] - u[c1];
    if (temp == 1 || temp == 1 - h) adj[c1].push_back(c2);
    if (temp == -1 || temp == h - 1) adj[c2].push_back(c1);
  }
}
void process() {
  for (int i = 1; i <= n; ++i)
    if (num[i] == 0) dfs(i);
  cout << res.size() << '\n';
  for (int i : res) cout << i << ' ';
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  setup();
  process();
  return 0;
}
