#include <bits/stdc++.h>
using namespace std;
const int SIZE = 100228;
int n, m, h;
int tme[SIZE];
vector<int> gr[SIZE], rgr[SIZE];
vector<int> topsort;
vector<bool> used;
vector<int> gr_comp[SIZE];
int comps[SIZE];
vector<int> vert[SIZE];
void dfsts(int v) {
  used[v] = true;
  for (int i : gr[v]) {
    if (!used[i]) {
      dfsts(i);
    }
  }
  topsort.push_back(v);
}
void dfs(int v, int comp) {
  comps[v] = comp;
  vert[comp].push_back(v);
  used[v] = true;
  for (int i : rgr[v]) {
    if (!used[i]) {
      dfs(i, comp);
    } else if (used[i] && comps[i] != comps[v]) {
      gr_comp[comps[i]].push_back(comps[v]);
    }
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cin >> n >> m >> h;
  for (int i = 0; i < n; ++i) {
    cin >> tme[i];
  }
  for (int i = 0; i < m; ++i) {
    int c1, c2;
    cin >> c1 >> c2;
    c1--;
    c2--;
    if ((tme[c1] + 1) % h == tme[c2]) {
      gr[c1].push_back(c2);
      rgr[c2].push_back(c1);
    }
    if ((tme[c2] + 1) % h == tme[c1]) {
      gr[c2].push_back(c1);
      rgr[c1].push_back(c2);
    }
  }
  used.resize(n);
  for (int i = 0; i < n; ++i) {
    if (!used[i]) {
      dfsts(i);
    }
  }
  reverse(topsort.begin(), topsort.end());
  used.assign(n, false);
  int cur_comp = 0;
  for (int i = 0; i < n; ++i) {
    if (!used[topsort[i]]) {
      dfs(topsort[i], cur_comp);
      cur_comp++;
    }
  }
  int pos = -1;
  for (int i = 0; i < cur_comp; ++i) {
    if (gr_comp[i].size() == 0 &&
        (pos == -1 || vert[i].size() < vert[pos].size())) {
      pos = i;
    }
  }
  cout << vert[pos].size() << endl;
  for (int i : vert[pos]) {
    cout << i + 1 << ' ';
  }
}
