#include <bits/stdc++.h>
const double Pi = acos(-1.0);
using namespace std;
const int maxN = 100005;
int n, m, h;
int u[maxN];
vector<int> G[maxN];
int disc[maxN], low[maxN], t;
vector<int> S;
int scc[maxN], cnt;
bool in[maxN];
void tarjan(int cur) {
  if (G[cur].empty()) {
    printf("1\n%d\n", cur);
    exit(0);
  }
  disc[cur] = low[cur] = ++t;
  S.push_back(cur);
  in[cur] = true;
  for (int i = 0; i < (int)G[cur].size(); i++) {
    int nxt = G[cur][i];
    if (!disc[nxt]) {
      tarjan(nxt);
      low[cur] = min(low[nxt], low[cur]);
    } else if (in[nxt])
      low[cur] = min(disc[nxt], low[cur]);
  }
  if (disc[cur] == low[cur]) {
    scc[cur] = ++cnt;
    in[cur] = false;
    int nxt;
    while (S.back() != cur) {
      nxt = S.back();
      S.pop_back();
      scc[nxt] = cnt;
      in[nxt] = false;
    }
    S.pop_back();
  }
}
bool mark[maxN];
int csz[maxN];
int main(int argc, char** argv) {
  scanf("%d %d %d", &n, &m, &h);
  for (int i = 1; i <= n; i++) scanf("%d", &u[i]);
  int c1, c2;
  for (int i = 0; i < m; i++) {
    scanf("%d %d", &c1, &c2);
    if ((u[c1] + 1) % h == u[c2]) G[c1].push_back(c2);
    if ((u[c2] + 1) % h == u[c1]) G[c2].push_back(c1);
  }
  for (int i = 1; i <= n; i++) {
    if (!disc[i]) tarjan(i);
  }
  for (int i = 1; i <= n; i++) {
    csz[scc[i]]++;
    if (mark[scc[i]]) continue;
    for (int j = 0; j < (int)G[i].size(); j++) {
      if (scc[G[i][j]] != scc[i]) mark[scc[i]] = true;
    }
  }
  int ans = INT_MAX, best;
  for (int i = 1; i <= cnt; i++) {
    if (!mark[i] && csz[i] < ans) {
      ans = csz[i];
      best = i;
    }
  }
  printf("%d\n", ans);
  for (int i = 1; i <= n; i++) {
    if (scc[i] == best) printf("%d ", i);
  }
  return 0;
}
