#include <bits/stdc++.h>
using namespace std;
const int maxN = 1e5 + 3, MOD = 1e9 + 7;
int n, m, h, arr[maxN], bu[maxN], ear[maxN], ct = 0, sz[maxN];
bool sta[maxN], comp[maxN], v[maxN];
vector<int> g[maxN];
stack<int> stac;
int d[maxN], low[maxN], scc[maxN];
bool stacked[maxN];
stack<int> s;
int ticks = 0, current_scc = 0;
void tarjan(int u) {
  d[u] = low[u] = ticks++;
  s.push(u);
  stacked[u] = true;
  const vector<int> &out = g[u];
  for (int k = 0, m = out.size(); k < m; ++k) {
    const int &v = out[k];
    if (d[v] == -1) {
      tarjan(v);
      low[u] = min(low[u], low[v]);
    } else if (stacked[v]) {
      low[u] = min(low[u], low[v]);
    }
  }
  if (d[u] == low[u]) {
    int v;
    do {
      v = s.top();
      s.pop();
      stacked[v] = false;
      scc[v] = current_scc;
    } while (u != v);
    current_scc++;
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0), cout.tie(0);
  cin >> n >> m >> h;
  memset(d, -1, sizeof(d));
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
  }
  for (int i = 0, u, v; i < m; i++) {
    cin >> u >> v;
    u--, v--;
    if ((arr[u] + 1) % h == arr[v]) g[u].push_back(v);
    if ((arr[v] + 1) % h == arr[u]) g[v].push_back(u);
  }
  for (int i = 0; i < n; i++) {
    if (d[i] == -1) tarjan(i);
  }
  for (int i = 0; i < n; i++) {
    for (int el : g[i])
      if (scc[el] != scc[i]) bu[scc[i]]++;
  }
  for (int i = 0; i < n; i++) {
    sz[scc[i]]++;
  }
  int bes = -1;
  for (int i = 0; i < n; i++) {
    if ((sz[i] && bu[i] == 0 && (bes == -1 || sz[i] < sz[bes]))) {
      bes = i;
    }
  }
  cout << sz[bes] << '\n';
  for (int i = 0; i < n; i++) {
    if (scc[i] == bes) cout << i + 1 << ' ';
  }
  cout << '\n';
}
