#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  int n, m, h;
  cin >> n >> m >> h;
  vector<int> mh(n + 1);
  for (int i = 1; i <= n; ++i) {
    cin >> mh[i];
  }
  auto conf = [&](int a, int b) {
    return mh[b] == mh[a] + 1 || mh[a] == h - 1 && mh[b] == 0;
  };
  vector<vector<int>> edges(n + 1);
  vector<vector<int>> rdges(n + 1);
  for (int i = 0; i < m; ++i) {
    int c, d;
    cin >> c >> d;
    if (conf(c, d)) {
      edges[d].push_back(c);
      rdges[c].push_back(d);
    }
    if (conf(d, c)) {
      edges[c].push_back(d);
      rdges[d].push_back(c);
    }
  }
  int cur = 0;
  vector<int> post(n + 1);
  vector<bool> vis(n + 1);
  vector<int> scc;
  function<void(int)> dfs = [&](int v) {
    vis[v] = true;
    scc.push_back(v);
    for (auto i : edges[v]) {
      if (!vis[i]) {
        dfs(i);
      }
    }
    post[v] = ++cur;
  };
  for (int i = 1; i <= n; ++i) {
    if (!vis[i]) {
      dfs(i);
    }
  }
  auto cmp = [&](int a, int b) { return post[a] > post[b]; };
  vector<int> possibleSinks(n);
  iota(possibleSinks.begin(), possibleSinks.end(), 1);
  sort(possibleSinks.begin(), possibleSinks.end(), cmp);
  fill(vis.begin(), vis.end(), false);
  vector<int> sinks;
  for (int i : possibleSinks) {
    if (!vis[i]) {
      sinks.push_back(i);
      dfs(i);
    }
  }
  swap(edges, rdges);
  fill(vis.begin(), vis.end(), false);
  vector<int> ans(n + 1);
  for (int i : sinks) {
    scc.clear();
    dfs(i);
    if (scc.size() < ans.size()) {
      ans = scc;
    }
  }
  cout << ans.size() << endl;
  for (int i : ans) {
    cout << i << ' ';
  }
  cout << endl;
  return 0;
}
