#include <bits/stdc++.h>
using namespace std;
vector<int> dg[101000], dgr[101000], compadj[101000];
int n, m, h, u[101000], in1, in2, seq[101000], seqp;
int component[101000], comp_group, compcnt[101000], minn;
bool processed[101000];
void dfs(int a) {
  if (processed[a]) return;
  processed[a] = true;
  for (auto x : dg[a]) dfs(x);
  seq[seqp++] = a;
}
void dfss(int a) {
  if (processed[a]) return;
  processed[a] = true;
  component[a] = comp_group;
  for (auto x : dgr[a]) dfss(x);
}
int main() {
  cin >> n >> m >> h;
  for (int i = 1; i <= n; i++) cin >> u[i];
  for (int i = 0; i < m; i++) {
    cin >> in1 >> in2;
    if (u[in2] > u[in1]) swap(in1, in2);
    if ((u[in1] - u[in2]) == 1) {
      dg[in2].push_back(in1);
      dgr[in1].push_back(in2);
    }
    if ((u[in1] == (h - 1)) && (u[in2] == 0)) {
      dg[in1].push_back(in2);
      dgr[in2].push_back(in1);
    }
  }
  for (int i = 1; i <= n; i++) dfs(i);
  for (int i = 1; i <= n; i++) processed[i] = false;
  for (int i = n - 1; i >= 0; i--) {
    if (processed[seq[i]]) continue;
    dfss(seq[i]);
    comp_group++;
  }
  for (int i = 1; i <= n; i++) {
    for (auto x : dg[i]) {
      if (component[i] == component[x]) continue;
      compadj[component[i]].push_back(component[x]);
    }
  }
  for (int i = 1; i <= n; i++) {
    compcnt[component[i]]++;
  }
  minn = n;
  int minni = 0;
  for (int i = 0; i < comp_group; i++) {
    if ((compadj[i].size() == 0) && (compcnt[i] < minn)) {
      minn = min(minn, compcnt[i]);
      minni = i;
    }
  }
  cout << minn << endl;
  for (int i = 1; i <= n; i++) {
    if (component[i] == minni) cout << i << " ";
  }
  cout << endl;
}
