#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = double;
using pll = pair<ll, ll>;
using vll = vector<ll>;
using vpll = vector<pll>;
using vvll = vector<vll>;
void stDfs(ll k, const vector<vector<ll>>& g, vector<bool>& v, stack<ll>& st) {
  if (v[k]) return;
  v[k] = true;
  for (ll i = 0; i < (ll)g[k].size(); ++i) stDfs(g[k][i], g, v, st);
  st.push(k);
}
void markDfs(ll k, vector<vector<ll>>& g, vector<ll>& res, ll comp) {
  if (res[k] != -1) return;
  res[k] = comp;
  for (ll i = 0; i < (ll)g[k].size(); ++i) markDfs(g[k][i], g, res, comp);
}
vector<ll> strongComp(vector<vector<ll>>& g) {
  vector<vector<ll>> gt(g.size());
  for (ll i = 0; i < (ll)g.size(); ++i) {
    for (ll j = 0; j < (ll)g[i].size(); ++j) {
      gt[g[i][j]].push_back(i);
    }
  }
  vector<bool> v(g.size());
  stack<ll> st;
  for (ll i = 0; i < (ll)g.size(); ++i) {
    if (!v[i]) stDfs(i, gt, v, st);
  }
  vector<ll> res(g.size(), -1);
  ll comp = 0;
  while (st.size()) {
    markDfs(st.top(), g, res, comp++);
    while (st.size() && res[st.top()] != -1) st.pop();
  }
  return res;
}
vector<vector<ll>> condensationGraph(vector<vector<ll>>& g) {
  vector<ll> c = strongComp(g);
  ll total = c[0];
  for (ll i = 0; i < (ll)c.size(); ++i) total = max(total, c[i]);
  vector<vector<ll>> rg(total + 1);
  for (ll i = 0; i < (ll)g.size(); ++i) {
    for (ll j = 0; j < (ll)g[i].size(); ++j) {
      if (c[i] != c[g[i][j]]) {
        rg[c[i]].push_back(c[g[i][j]]);
      }
    }
  }
  return rg;
}
int main() {
  ios::sync_with_stdio(0);
  cout.tie(0);
  cin.tie(0);
  ll n, m, h;
  cin >> n >> m >> h;
  vector<vector<ll>> g(n);
  vector<ll> a(n);
  for (ll i = 0; i < (ll)n; ++i) cin >> a[i];
  for (ll i = 0; i < (ll)m; ++i) {
    ll u, v;
    cin >> u >> v;
    u--;
    v--;
    if (a[u] == (a[v] + 1) % h) g[v].push_back(u);
    if (a[v] == (a[u] + 1) % h) g[u].push_back(v);
  }
  vector<ll> comps = strongComp(g);
  vector<vector<ll>> cond = condensationGraph(g);
  vector<ll> sizes(cond.size());
  for (ll i = 0; i < (ll)comps.size(); ++i) {
    sizes[comps[i]]++;
  }
  ll best = (1LL << 40);
  for (ll i = 0; i < (ll)sizes.size(); ++i)
    if (cond[i].empty()) best = min(best, sizes[i]);
  cout << best << endl;
  for (ll i = 0; i < (ll)sizes.size(); ++i) {
    if (sizes[i] == best && cond[i].empty()) {
      for (ll j = 0; j < (ll)comps.size(); ++j) {
        if (comps[j] == i) {
          cout << j + 1 << ' ';
        }
      }
      cout << endl;
      break;
    }
  }
  return 0;
}
