#include <bits/stdc++.h>
using namespace std;
using uint = unsigned int;
using ll = long long;
using pii = pair<int, int>;
int nr;
int u[100010], comp[100010], sz[100010];
bool vis[100010], bad[100010];
vector<int> ord;
vector<int> adj[100010], adjt[100010];
void addEdge(int a, int b) {
  adj[a].push_back(b);
  adjt[b].push_back(a);
}
void dfs(int v) {
  if (vis[v]) return;
  vis[v] = true;
  for (auto u : adj[v]) dfs(u);
  ord.push_back(v);
}
void getComp(int v) {
  if (vis[v]) return;
  vis[v] = true;
  comp[v] = nr;
  ++sz[nr];
  for (auto u : adjt[v]) getComp(u);
}
int main() {
  ios_base::sync_with_stdio(false);
  int i, n, m, h, c1, c2, ans;
  cin >> n >> m >> h;
  for (i = 1; i <= n; ++i) cin >> u[i];
  for (i = 1; i <= m; ++i) {
    cin >> c1 >> c2;
    if ((u[c1] + 1) % h == u[c2]) addEdge(c1, c2);
    if ((u[c2] + 1) % h == u[c1]) addEdge(c2, c1);
  }
  for (i = 1; i <= n; ++i) dfs(i);
  memset(vis, 0, sizeof vis);
  reverse(ord.begin(), ord.end());
  nr = 0;
  for (auto v : ord) {
    ++nr;
    getComp(v);
  }
  for (i = 1; i <= n; ++i)
    for (auto j : adj[i])
      if (comp[i] != comp[j]) bad[comp[i]] = true;
  ans = -1;
  for (i = 1; i <= n; ++i)
    if (sz[i] > 0 && !bad[i]) {
      if (ans == -1 || sz[ans] > sz[i]) ans = i;
    }
  cout << sz[ans] << '\n';
  for (i = 1; i <= n; ++i)
    if (comp[i] == ans) cout << i << ' ';
  cout << '\n';
  return 0;
}
