#include <bits/stdc++.h>
using namespace std;
int n, m, h;
vector<int> t;
vector<vector<int>> g, rev_g, cond_g;
vector<int> num_exit;
vector<char> used;
vector<int> color;
vector<int> count_v;
void find_num_exit(int v) {
  used[v] = true;
  for (auto u : g[v]) {
    if (used[u]) continue;
    find_num_exit(u);
  }
  num_exit.push_back(v);
}
void cond(int v, int k) {
  color[v] = k;
  for (auto u : rev_g[v]) {
    if (color[u]) continue;
    cond(u, k);
  }
}
void make_cond_g(int v) {
  used[v] = true;
  count_v[color[v]]++;
  for (auto u : g[v]) {
    if (color[v] != color[u]) {
      cond_g[color[v]].push_back(color[u]);
    }
    if (used[u]) continue;
    make_cond_g(u);
  }
}
int minn = 1e9, minn_k = 0;
void dfs_cond(int v) {
  used[v] = true;
  if (cond_g[v].size() == 0 && count_v[v] < minn) {
    minn = count_v[v];
    minn_k = v;
  }
  for (auto u : cond_g[v]) {
    if (used[u]) continue;
    dfs_cond(u);
  }
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> m >> h;
  t.resize(n + 1);
  g.resize(n + 1);
  rev_g.resize(n + 1);
  for (int i = 1; i <= n; i++) {
    cin >> t[i];
  }
  for (int i = 1; i <= m; i++) {
    int c1, c2;
    cin >> c1 >> c2;
    if ((t[c1] + 1) % h == t[c2]) {
      g[c1].push_back(c2);
      rev_g[c2].push_back(c1);
    }
    if ((t[c2] + 1) % h == t[c1]) {
      g[c2].push_back(c1);
      rev_g[c1].push_back(c2);
    }
  }
  used.resize(n + 1);
  for (int i = 1; i <= n; i++) {
    if (!used[i]) find_num_exit(i);
  }
  used.clear();
  int k = 0;
  color.resize(n + 1);
  reverse(num_exit.begin(), num_exit.end());
  for (auto i : num_exit) {
    if (color[i] == 0) {
      k++;
      cond(i, k);
    }
  }
  used.resize(n + 1);
  count_v.resize(k + 1);
  cond_g.resize(k + 1);
  for (int i = 1; i <= n; i++) {
    if (!used[i]) make_cond_g(i);
  }
  used.clear();
  used.resize(k + 1);
  for (int i = 1; i <= k; i++) {
    if (!used[i]) dfs_cond(i);
  }
  cout << minn << "\n";
  for (int i = 1; i <= n; i++) {
    if (color[i] == minn_k) {
      cout << i << " ";
    }
  }
  return 0;
}
