#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 100010;
int u[MAX_N];
set<int> adj[MAX_N];
set<int> revAdj[MAX_N];
vector<set<int>> scc;
int compOf[MAX_N];
set<int> out[MAX_N];
int order[MAX_N];
bool visited[MAX_N];
void topologicalSort(int v, int& pos) {
  visited[v] = true;
  for (int w : revAdj[v]) {
    if (!visited[w]) {
      topologicalSort(w, pos);
    }
  }
  order[pos--] = v;
}
void getSCC(int v, set<int>& comp) {
  visited[v] = true;
  comp.insert(v);
  compOf[v] = scc.size();
  for (int w : adj[v]) {
    if (!visited[w]) {
      getSCC(w, comp);
    }
  }
}
int main() {
  ios::sync_with_stdio(false);
  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 c1, c2;
    cin >> c1 >> c2;
    if ((u[c1] + 1) % h == u[c2]) {
      adj[c1].insert(c2);
      revAdj[c2].insert(c1);
    }
    if ((u[c2] + 1) % h == u[c1]) {
      adj[c2].insert(c1);
      revAdj[c1].insert(c2);
    }
  }
  int pos = n;
  for (int v = 1; v <= n; ++v) {
    visited[v] = false;
  }
  for (int v = 1; v <= n; ++v) {
    if (!visited[v]) {
      topologicalSort(v, pos);
    }
  }
  for (int v = 1; v <= n; ++v) {
    visited[v] = false;
  }
  for (int i = 1; i <= n; ++i) {
    int v = order[i];
    if (!visited[v]) {
      set<int> comp;
      getSCC(v, comp);
      scc.push_back(comp);
    }
  }
  for (int i = 1; i <= n; ++i) {
    for (int w : adj[i]) {
      if (compOf[i] != compOf[w]) {
        out[compOf[i]].insert(compOf[w]);
      }
    }
  }
  int res = n + 1;
  int cIdx = -1;
  for (int i = 0; i < scc.size(); ++i) {
    if (out[i].size() == 0 && scc[i].size() < res) {
      res = scc[i].size();
      cIdx = i;
    }
  }
  cout << res << endl;
  for (int v : scc[cIdx]) {
    cout << v << " ";
  }
  cout << endl;
  return 0;
}
