#include <bits/stdc++.h>
#pragma GCC optimize("-O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
using namespace std;
const int MAXN = 1123456;
const int N = 2e5;
const long long inf = 1e18;
mt19937_64 rnd(chrono::system_clock::now().time_since_epoch().count());
template <typename T>
void vout(T s) {
  cout << s << endl;
  exit(0);
}
vector<long long> v[MAXN], cnt, g[MAXN], order, used, c;
int r;
void dfs(long long x) {
  if (used[x]) return;
  used[x] = 1;
  for (auto to : v[x]) dfs(to);
}
void top_sort(long long x) {
  if (used[x]) return;
  used[x] = 1;
  for (auto to : v[x]) top_sort(to);
  order.push_back(x);
}
void build_component(long long x) {
  if (used[x]) {
    if (c[x] != r) cnt[c[x]] = inf;
    return;
  }
  used[x] = 1;
  c[x] = r;
  cnt[r]++;
  for (auto to : g[x]) build_component(to);
}
void main_solve() {
  long long n, m, h;
  cin >> n >> m >> h;
  vector<long long> u(n + 1);
  cnt.clear();
  cnt.resize(n + 1);
  c.clear();
  c.resize(n + 1);
  for (int i = 1; i <= n; i++) {
    cin >> u[i];
    v[i].clear();
  }
  while (m--) {
    long long a, b;
    cin >> a >> b;
    if ((u[a] + 1) % h == u[b]) {
      v[a].push_back(b);
      g[b].push_back(a);
    }
    if ((u[b] + 1) % h == u[a]) {
      v[b].push_back(a);
      g[a].push_back(b);
    }
  }
  used.clear();
  used.resize(n + 1);
  for (int i = 1; i <= n; i++) {
    if (!used[i]) top_sort(i);
  }
  reverse(order.begin(), order.end());
  used.clear();
  used.resize(n + 1);
  r = 0;
  for (auto i : order)
    if (!used[i]) {
      r++;
      build_component(i);
    }
  pair<long long, long long> ans = {n + 1, 0};
  for (int i = 1; i <= n; i++) ans = min(ans, {cnt[c[i]], i});
  used.clear();
  used.resize(n + 1);
  dfs(ans.second);
  cout << ans.first << "\n";
  for (int i = 1; i <= n; i++)
    if (used[i]) cout << i << " ";
  cout << "\n";
}
int main() {
  ios_base ::sync_with_stdio(0);
  cin.tie(0);
  main_solve();
  return 0;
}
