#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
using namespace std;
void err(istream_iterator<string> it) {}
template <typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
  cout << *it << " = " << a << "\n";
  err(++it, args...);
}
const long long N = 1e5 + 5, M = 1001, inf = 1e18;
vector<int> gr[N], gt[N], gc[N], order, comp(N);
vector<int> deg(N), s(N);
vector<bool> used(N);
int cycle;
void dfsa(int u) {
  used[u] = true;
  for (int v : gr[u])
    if (not used[v]) dfsa(v);
  order.push_back(u);
}
void dfsb(int u) {
  used[u] = true;
  comp[u] = cycle;
  s[cycle]++;
  for (int v : gt[u])
    if (not used[v]) dfsb(v);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  int n, m, h;
  cin >> n >> m >> h;
  int t[n + 1];
  for (int i = 0; i < n; i++) cin >> t[i + 1];
  ;
  set<pair<int, int> > done;
  for (int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    if (done.find({a, b}) != done.end()) {
      continue;
    }
    if ((t[a] + 1) % h == t[b]) {
      gr[a].push_back(b);
      gt[b].push_back(a);
    }
    if ((t[b] + 1) % h == t[a]) {
      gr[b].push_back(a);
      gt[a].push_back(b);
    }
    done.insert({a, b});
    done.insert({b, a});
  }
  for (int u = 1; u < n + 1; u++)
    if (not used[u]) dfsa(u);
  reverse(order.begin(), order.end());
  used.assign(n + 1, false);
  for (int u : order)
    if (not used[u]) {
      cycle++;
      dfsb(u);
    }
  for (int u = 1; u < n + 1; u++) {
    for (int v : gr[u]) {
      int x, y;
      x = comp[u];
      y = comp[v];
      if (x != y) {
        deg[x]++;
      }
    }
  }
  long long ans = -1, val = inf;
  for (int i = 1; i < cycle + 1; i++) {
    if (deg[i] == 0 and s[i] <= val) {
      ans = i;
      val = s[i];
    }
  }
  cout << s[ans] << "\n";
  for (int i = 1; i < n + 1; i++)
    if (comp[i] == ans) {
      cout << i << " ";
    }
}
