#include <bits/stdc++.h>
using namespace std;
const double eps = 1e-7;
const long double PI = acos(0.0) * 2.0;
const int maxn = 1e6 + 10;
const int mod = 1e9 + 7;
vector<int> G[maxn];
int pre[maxn], lowlink[maxn], sccno[maxn], dfs_clock, scc_cnt;
stack<int> S;
void dfs(int u) {
  pre[u] = lowlink[u] = ++dfs_clock;
  S.push(u);
  for (int i = 0; i < G[u].size(); i++) {
    int v = G[u][i];
    if (!pre[v]) {
      dfs(v);
      lowlink[u] = min(lowlink[u], lowlink[v]);
    } else if (!sccno[v]) {
      lowlink[u] = min(lowlink[u], pre[v]);
    }
  }
  if (lowlink[u] == pre[u]) {
    scc_cnt++;
    for (;;) {
      int x = S.top();
      S.pop();
      sccno[x] = scc_cnt;
      if (x == u) break;
    }
  }
}
void find_scc(int n) {
  dfs_clock = scc_cnt = 0;
  memset(sccno, 0, sizeof(sccno));
  memset(pre, 0, sizeof(pre));
  for (int i = 0; i < n; i++)
    if (!pre[i]) dfs(i);
}
int n, m, h;
int u[maxn];
int c[maxn][2];
inline void add(int u, int v) { G[u].push_back(v); }
vector<int> sc[maxn];
int in[maxn];
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cin >> n >> m >> h;
  for (int t = (1); t < (n + 1); ++t) cin >> u[t];
  for (int t = (1); t < (m + 1); ++t) {
    for (int e = (0); e < (2); ++e) cin >> c[t][e];
    for (int e = (0); e < (2); ++e) {
      if ((u[c[t][e]] + 1) % h == u[c[t][e ^ 1]])
        add(c[t][e] - 1, c[t][e ^ 1] - 1);
    }
  }
  find_scc(n);
  for (int t = (0); t < (n); ++t) {
    sc[sccno[t]].push_back(t);
  }
  for (int t = (1); t < (m + 1); ++t) {
    for (int e = (0); e < (2); ++e) {
      if (sccno[c[t][e] - 1] == sccno[c[t][e ^ 1] - 1]) continue;
      if ((u[c[t][e]] + 1) % h == u[c[t][e ^ 1]]) ++in[sccno[c[t][e] - 1]];
    }
  }
  long long ans = 1e8;
  int y;
  for (int i = 1; i <= scc_cnt; ++i) {
    if (!in[i]) {
      if (ans > sc[i].size()) {
        ans = sc[i].size();
        y = i;
      }
    }
  }
  cout << ans << "\n";
  for (auto e : sc[y]) cout << e + 1 << " ";
}
