#include <bits/stdc++.h>
using namespace std;
const int maxn = 100003;
int SCCtag, n, m, h, a, b, t = 1, ans = INT_MAX, mySCC;
int disctime[maxn], mintime[maxn], horas[maxn], DAGnode[maxn], SCCsize[maxn];
bool vis[maxn], instack[maxn], vis2[maxn];
stack<int> scc;
set<pair<int, int>> edges;
vector<int> ady[maxn];
set<int> DAGady[maxn];
void procesa(int node) {
  ++SCCtag;
  int tp;
  do {
    SCCsize[SCCtag]++;
    tp = scc.top();
    scc.pop();
    instack[tp] = false;
    DAGnode[tp] = SCCtag;
  } while (tp != node);
}
void Tarjan(int node) {
  if (vis[node]) return;
  vis[node] = true;
  instack[node] = true;
  scc.push(node);
  mintime[node] = disctime[node] = t++;
  for (auto vec : ady[node]) {
    Tarjan(vec);
    if (instack[vec]) mintime[node] = min(mintime[node], mintime[vec]);
  }
  if (disctime[node] == mintime[node]) procesa(node);
  return;
}
int main() {
  scanf("%d %d %d", &n, &m, &h);
  for (int i = 1; i <= n; i++) scanf("%d", &horas[i]);
  for (int i = 0; i < m; i++) {
    scanf("%d %d", &a, &b);
    if ((horas[a] + 1) % h == horas[b]) {
      if (edges.find({a, b}) == edges.end()) {
        ady[a].push_back(b);
        edges.insert({a, b});
      }
    }
    if ((horas[b] + 1) % h == horas[a]) {
      if (edges.find({b, a}) == edges.end()) {
        ady[b].push_back(a);
        edges.insert({b, a});
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    Tarjan(i);
  }
  for (set<pair<int, int>>::iterator it = edges.begin(); it != edges.end();
       it++) {
    a = (*it).first;
    b = (*it).second;
    if (DAGnode[a] != DAGnode[b]) DAGady[DAGnode[a]].insert(DAGnode[b]);
  }
  for (int i = 1; i <= SCCtag; i++) {
    if (DAGady[i].size() == 0) {
      if (SCCsize[i] < ans) {
        ans = SCCsize[i];
        mySCC = i;
      }
    }
  }
  printf("%d\n", ans);
  for (int i = 1; i <= n; i++)
    if (DAGnode[i] == mySCC) printf("%d ", i);
  return 0;
}
