#include <bits/stdc++.h>
using namespace std;
mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());
vector<vector<long long>> g, gt;
vector<bool> used;
vector<long long> ord, comp, len;
void dfs1(long long s) {
  used[s] = true;
  for (auto x : g[s])
    if (!used[x]) dfs1(x);
  ord.push_back(s);
}
void dfs2(long long s, long long clr) {
  used[s] = true;
  comp[s] = clr;
  len[len.size() - 1]++;
  for (auto x : gt[s])
    if (!used[x]) dfs2(x, clr);
}
signed main() {
  ios::sync_with_stdio(false), cin.tie(0), cout.tie(0), cout.precision(20);
  long long n, m, h;
  cin >> n >> m >> h;
  vector<long long> u(n);
  vector<pair<long long, long long>> edges;
  g.resize(n), gt.resize(n), used.assign(n, false), comp.resize(n);
  for (long long i = 0; i < n; i++) cin >> u[i];
  for (long long i = 0; i < m; i++) {
    long long x, y;
    cin >> x >> y;
    x--, y--;
    if ((u[x] + 1) % h == u[y]) {
      g[x].push_back(y);
      edges.push_back({x, y});
      gt[y].push_back(x);
    }
    if ((u[y] + 1) % h == u[x]) {
      g[y].push_back(x);
      edges.push_back({y, x});
      gt[x].push_back(y);
    }
  }
  for (long long i = 0; i < n; i++)
    if (!used[i]) dfs1(i);
  used.assign(n, false);
  long long cur = 0;
  len.push_back(0);
  for (long long i = 0; i < n; i++) {
    long long x = ord[n - i - 1];
    if (!used[x]) {
      cur++;
      len.push_back(0);
      dfs2(x, cur);
    }
  }
  cout << "\n";
  if (cur == 1) {
    cout << n << "\n";
    for (long long i = 1; i <= n; i++) cout << i << " ";
    return 0;
  }
  vector<pair<long long, long long>> cnt(cur + 1, {0, 0});
  for (long long i = 0; i < edges.size(); i++) {
    if (comp[edges[i].first] != comp[edges[i].second]) {
      cnt[comp[edges[i].first]].first++;
      cnt[comp[edges[i].second]].second++;
    }
  }
  long long ans = 1e9, clr;
  for (long long i = 1; i < cnt.size(); i++)
    if (cnt[i].first == 0 && len[i] < ans) {
      ans = len[i];
      clr = i;
    }
  cout << ans << "\n";
  for (long long i = 0; i < n; i++)
    if (comp[i] == clr) cout << i + 1 << " ";
  return 0;
}
