#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 5;
int n;
vector<int> adj[maxn], bac[maxn], has[maxn];
int order[maxn], vs[maxn], comp[maxn];
int cnt, m, h, a[maxn];
map<pair<int, int>, int> mm;
vector<pair<int, int> > edge;
int ra[maxn];
void dfs1(int u) {
  vs[u] = 1;
  for (auto v : adj[u]) {
    if (vs[v]) continue;
    dfs1(v);
  }
  order[cnt++] = u;
}
void dfs2(int u, int c) {
  comp[u] = c;
  has[c].push_back(u);
  for (auto v : bac[u]) {
    if (~comp[v]) continue;
    dfs2(v, c);
  }
}
int main() {
  cin >> n >> m >> h;
  for (int i = (0); i < (n); i++) {
    cin >> a[i];
  }
  for (int i = (0); i < (m); i++) {
    int x, y;
    cin >> x >> y;
    x--;
    y--;
    if ((a[x] + 1) % h == a[y]) {
      if (!mm.count(make_pair(x, y))) {
        adj[x].push_back(y);
        bac[y].push_back(x);
        mm[make_pair(x, y)] = 1;
        edge.push_back(make_pair(x, y));
      }
    }
    if ((a[y] + 1) % h == a[x]) {
      if (!mm.count(make_pair(y, x))) {
        adj[y].push_back(x);
        bac[x].push_back(y);
        mm[make_pair(y, x)] = 1;
        edge.push_back(make_pair(y, x));
      }
    }
  }
  for (int i = (0); i < (n); i++) {
    if (!vs[i]) dfs1(i);
    comp[i] = -1;
  }
  int c = 0;
  for (int i = (n)-1; i >= 0; i--) {
    int u = order[i];
    if (!~comp[u]) dfs2(u, c++);
  }
  for (int i = (0); i < (((int)edge.size())); i++) {
    int c1 = comp[edge[i].first];
    int c2 = comp[edge[i].second];
    if (c1 != c2) {
      ra[c1] = 1;
    }
  }
  int found = -1;
  for (int i = (0); i < (c); i++) {
    if (ra[i]) continue;
    if (!~found || ((int)has[i].size()) < ((int)has[found].size())) {
      found = i;
    }
  }
  printf("%d\n", ((int)has[found].size()));
  for (auto u : has[found]) {
    printf("%d ", u + 1);
  }
  return 0;
}
