#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:16777216")
using namespace std;
const int inf = (int)1e9 + 5;
const long long INF = (long long)1e18 + 5;
long long n, N;
vector<vector<long long>> a, ar, g, components;
vector<long long> order, comp;
vector<bool> vis;
void dfs(long long v) {
  vis[v] = true;
  for (auto to : a[v])
    if (!vis[to]) dfs(to);
  order.push_back(v);
}
void dfs2(long long v) {
  vis[v] = true;
  for (auto to : ar[v])
    if (!vis[to]) dfs2(to);
  comp.push_back(v);
}
void dfs3(long long v) {
  vis[v] = true;
  for (auto to : g[v])
    if (!vis[to]) dfs3(to);
  order.push_back(v);
}
void init() {
  a.resize(n);
  ar.resize(n);
  vis.assign(n, false);
}
void solve() {
  long long m, h;
  cin >> n >> m >> h;
  init();
  vector<long long> times(n);
  for (long long i = 0; i < n; i++) cin >> times[i];
  long long x, y;
  for (long long i = 0; i < m; i++) {
    cin >> x >> y;
    x--;
    y--;
    if ((times[x] + 1) % h == times[y]) {
      a[x].push_back(y);
      ar[y].push_back(x);
    }
    if ((times[y] + 1) % h == times[x]) {
      a[y].push_back(x);
      ar[x].push_back(y);
    }
  }
  for (long long i = 0; i < n; i++)
    if (!vis[i]) dfs(i);
  reverse(order.begin(), order.end());
  (void)0;
  fill(vis.begin(), vis.end(), false);
  vector<long long> comp_id(n);
  for (long long i = 0; i < n; i++) {
    x = order[i];
    if (vis[x]) continue;
    comp.clear();
    dfs2(x);
    for (auto v : comp) comp_id[v] = components.size();
    components.push_back(comp);
  }
  (void)0;
  N = components.size();
  g.resize(N);
  for (long long i = 0; i < n; i++) {
    for (auto j : a[i]) {
      long long v = comp_id[i], to = comp_id[j];
      if (v == to) continue;
      g[v].push_back(to);
    }
  }
  long long best_ind = -1;
  vis.assign(N, false);
  for (long long i = 0; i < N; i++) {
    if (vis[i]) continue;
    order.clear();
    dfs3(i);
    for (auto cur_ind : order) {
      if (g[cur_ind].size() != 0) continue;
      if (best_ind == -1 ||
          components[cur_ind].size() < components[best_ind].size())
        best_ind = cur_ind;
    }
  }
  cout << components[best_ind].size() << endl;
  for (auto e : components[best_ind]) cout << e + 1 << " ";
}
int main() {
  string filename = "acm";
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.precision(15);
  solve();
  (void)0;
  return 0;
}
