#include <bits/stdc++.h>
using namespace std;
vector<int> e[500010];
int n, m, h, a, b, no_sc, tot;
int t[500010];
int dfn[500010], low[500010], num[500010], scc[500010], out[500010];
stack<int> s;
void tarjan(int u) {
  dfn[u] = low[u] = ++tot;
  s.push(u);
  for (int i : e[u]) {
    if (dfn[i] == 0) tarjan(i);
    low[u] = min(low[u], low[i]);
  }
  if (dfn[u] == low[u]) {
    no_sc++;
    while (1) {
      int x = s.top();
      s.pop();
      scc[x] = no_sc;
      num[no_sc]++;
      if (x == u) break;
    }
  }
}
int main() {
  no_sc = 0;
  tot = 0;
  cin >> n >> m >> h;
  for (int i = 1; i <= n; i++) cin >> t[i];
  for (int i = 1; i <= m; i++) {
    cin >> a >> b;
    if ((t[a] + 1) % h == t[b]) e[a].push_back(b);
    if ((t[b] + 1) % h == t[a]) e[b].push_back(a);
  }
  for (int i = 1; i <= n; i++)
    if (dfn[i] == 0) tarjan(i);
  for (int i = 1; i <= n; i++) {
    for (int j : e[i]) {
      if (scc[i] != scc[j]) out[scc[i]]++;
    }
  }
  int ans = 100010, flag;
  for (int i = 1; i <= no_sc; i++) {
    if (num[i] < ans && out[i] == 0) {
      ans = num[i];
      flag = i;
    }
  }
  cout << ans << endl;
  for (int i = 1; i <= n; i++)
    if (scc[i] == flag) cout << i << ' ';
  cout << endl;
  return 0;
}
