#include <bits/stdc++.h>
using namespace std;
const int NMAX = 100005;
vector<int> G[NMAX], GT[NMAX], ctc[NMAX];
int N, M, post[NMAX], viz[NMAX], cnt, H, hours[NMAX], whatCtc[NMAX];
void dfs(int nod) {
  viz[nod] = 1;
  for (vector<int>::iterator it = G[nod].begin(); it != G[nod].end(); ++it)
    if (!viz[*it]) dfs(*it);
  post[++cnt] = nod;
}
void dfs2(int nod, int sol) {
  viz[nod] = 0;
  ctc[sol].push_back(nod);
  for (vector<int>::iterator it = GT[nod].begin(); it != GT[nod].end(); ++it)
    if (viz[*it]) dfs2(*it, sol);
}
bool verifica(int nod) {
  for (int i = 0; i < G[nod].size(); ++i)
    if (whatCtc[nod] != whatCtc[G[nod][i]]) return false;
  return true;
}
int main() {
  scanf("%d%d%d", &N, &M, &H);
  for (int i = 1; i <= N; ++i) scanf("%d", &hours[i]);
  int a, b;
  for (int i = 1; i <= M; ++i) {
    scanf("%d%d", &a, &b);
    if ((hours[a] + 1) % H == hours[b]) {
      G[a].push_back(b);
      GT[b].push_back(a);
    }
    if ((hours[b] + 1) % H == hours[a]) {
      G[b].push_back(a);
      GT[a].push_back(b);
    }
  }
  for (int i = 1; i <= N; ++i)
    if (!viz[i]) dfs(i);
  int sol = 0;
  for (int i = N; i >= 1; --i)
    if (viz[post[i]]) {
      ++sol;
      dfs2(post[i], sol);
    }
  int minim = NMAX, indSol = 1;
  for (int i = 1; i <= sol; ++i)
    for (int j = 0; j < ctc[i].size(); ++j) whatCtc[ctc[i][j]] = i;
  for (int i = 1; i <= sol; ++i) {
    bool ok = true;
    for (int j = 0; j < ctc[i].size(); ++j) ok &= verifica(ctc[i][j]);
    if (ok && minim > ctc[i].size()) {
      minim = ctc[i].size();
      indSol = i;
    }
  }
  cout << ctc[indSol].size() << "\n";
  for (int i = 0; i < ctc[indSol].size(); ++i) cout << ctc[indSol][i] << " ";
  cout << "\n";
  return 0;
}
