#include <bits/stdc++.h>
using pii = std::pair<int, int>;
using pll = std::pair<long long, long long>;
const int maxn = 1e5 + 100;
std::vector<int> v[maxn], rev[maxn];
inline void add_edge(int i, int j) {
  v[i].push_back(j);
  rev[j].push_back(i);
}
int component[maxn];
std::vector<int> in_component[maxn];
std::vector<int> sorted;
char seen[maxn];
void sort_down(int x) {
  seen[x] = 1;
  for (int y : v[x])
    if (!seen[y]) sort_down(y);
  sorted.push_back(x);
}
char seen2[maxn];
void enumerate_component(int x, int cur) {
  seen2[x] = 1;
  component[x] = cur;
  in_component[cur].push_back(x);
  for (int y : rev[x])
    if (!seen2[y]) enumerate_component(y, cur);
}
int u[maxn], c1[maxn], c2[maxn];
int output[maxn];
int main() {
  int n = 5;
  std::ios::sync_with_stdio(false);
  int m, h;
  std::cin >> n >> m >> h;
  for (int i = 0; i < n; i++) std::cin >> u[i + 1];
  for (int i = 0; i < m; i++) {
    std::cin >> c1[i] >> c2[i];
    if (u[c1[i]] > u[c2[i]]) std::swap(c1[i], c2[i]);
    int t1 = u[c1[i]];
    int t2 = u[c2[i]];
    if (t2 == t1 + 1) {
      add_edge(c1[i], c2[i]);
    }
    if (t2 == h - 1 && t1 == 0) {
      add_edge(c2[i], c1[i]);
    }
  }
  for (int i = 1; i <= n; i++)
    if (!seen[i]) sort_down(i);
  for (int i = n; i >= 1; i--)
    if (!seen2[sorted[i - 1]]) enumerate_component(sorted[i - 1], i);
  for (int i = 1; i <= n; i++)
    for (int j : v[i])
      if (component[i] != component[j]) output[component[i]]++;
  pii ans = {0x3f3f3f3f, 0};
  for (int i = 1; i <= n; i++) {
    if (in_component[i].size() && output[i] == 0)
      ans = std::min(ans, {in_component[i].size(), i});
  }
  std::cout << ans.first << "\n";
  for (auto y : in_component[ans.second]) std::cout << y << " ";
  std::cout << "\n";
  return 0;
}
