#include <bits/stdc++.h>
using namespace std;
int n, m, h;
int U[100001];
vector<int> V[100001];
int C[100001], L[100001], second[100001], R[100001], t = 0, top = 0;
int SCC[100001], out[100001], nSCC = 1;
void DFS(int v) {
  L[v] = C[v] = ++t;
  second[top++] = v;
  for (int e : V[v]) {
    if (!C[e]) DFS(e);
    if (!R[e]) L[v] = (L[v] < L[e] ? L[v] : L[e]);
  }
  if (C[v] == L[v]) {
    for (int i = second[--top]; i != v; i = second[--top]) R[i] = nSCC;
    R[v] = nSCC++;
  }
  return;
}
int main() {
  scanf("%d %d %d", &n, &m, &h);
  for (int i = 1; i <= n; i++) scanf("%d", &U[i]);
  for (int i = 0; i < m; i++) {
    int a, b;
    scanf("%d %d", &a, &b);
    if ((U[a] + 1) % h == U[b]) V[a].push_back(b);
    if ((U[b] + 1) % h == U[a]) V[b].push_back(a);
  }
  for (int i = 1; i <= n; i++)
    if (!C[i]) DFS(i);
  for (int i = 1; i <= n; i++) {
    SCC[R[i]] += 1;
    for (int e : V[i])
      if (R[e] != R[i]) out[R[i]] += 1;
  }
  int min = 100001 + 1, minP = -1;
  for (int i = 1; i < nSCC; i++) {
    if (out[i] == 0)
      if (SCC[i] < min) min = SCC[i], minP = i;
  }
  printf("%d\n", min);
  for (int i = 1; i <= n; i++) {
    if (R[i] == minP) printf("%d ", i);
  }
  return 0;
}
