#include <bits/stdc++.h>
using namespace std;
vector<int> ady[100005], rev_ady[100005];
int N, M, H, ho[100005], marcas[100005], CFC, x, y, comp, tamcom[100005],
    tamres;
bool vis[100005], relacion[100005];
stack<int> elementos;
void dfs(int nodo) {
  vis[nodo] = true;
  for (int i = 0; i < ady[nodo].size(); i++)
    if (!vis[ady[nodo][i]]) dfs(ady[nodo][i]);
  elementos.push(nodo);
}
void dfs2(int nodo) {
  marcas[nodo] = CFC, tamcom[CFC]++;
  for (int i = 0; i < rev_ady[nodo].size(); i++)
    if (!marcas[rev_ady[nodo][i]]) dfs2(rev_ady[nodo][i]);
}
void Kosaraju() {
  for (int i = 1; i <= N; i++)
    if (!vis[i]) dfs(i);
  while (!elementos.empty()) {
    x = elementos.top();
    elementos.pop();
    if (!marcas[x]) CFC++, dfs2(x);
  }
}
int main() {
  scanf("%d %d %d", &N, &M, &H);
  for (int i = 1; i <= N; i++) scanf("%d", &ho[i]);
  for (int i = 0; i < M; i++) {
    scanf("%d %d", &x, &y);
    if ((ho[x] + 1) % H == ho[y]) ady[x].push_back(y), rev_ady[y].push_back(x);
    if ((ho[y] + 1) % H == ho[x]) ady[y].push_back(x), rev_ady[x].push_back(y);
  }
  Kosaraju();
  for (int i = 1; i <= N; i++)
    for (int j = 0; j < ady[i].size(); j++) {
      if (relacion[marcas[i]]) break;
      if (marcas[i] != marcas[ady[i][j]]) relacion[marcas[i]] = true;
    }
  for (int i = 1; i <= CFC; i++)
    if (!relacion[i] && (!tamres || tamres > tamcom[i]))
      tamres = tamcom[i], comp = i;
  printf("%d\n", tamres);
  for (int i = 1; i <= N; i++)
    if (marcas[i] == comp) printf("%d ", i);
  return 0;
}
