#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
template <class T>
using V = vector<T>;
template <class T>
using VV = V<V<T>>;
using VI = V<int>;
using VVI = VV<int>;
using VL = V<ll>;
using VVL = VV<ll>;
template <typename T, size_t N>
struct MakeVector {
  template <typename... Args,
            typename R = vector<decltype(MakeVector<T, N - 1>::make_vector(
                declval<Args>()...))>>
  static R make_vector(std::size_t first, Args... sizes) {
    auto inner = MakeVector<T, N - 1>::make_vector(sizes...);
    return R(first, inner);
  }
};
template <typename T>
struct MakeVector<T, 1> {
  template <typename R = std::vector<T>>
  static R make_vector(std::size_t size, const T& value) {
    return R(size, value);
  }
};
template <typename T, typename... Args>
auto make_vector(Args... args)
    -> decltype(MakeVector<T, sizeof...(Args) - 1>::make_vector(args...)) {
  return MakeVector<T, sizeof...(Args) - 1>::make_vector(args...);
}
VVI g, gt;
VI comp;
VI visited, order;
void dfs1(int v) {
  visited[v] = 1;
  for (auto u : g[v])
    if (!visited[u]) dfs1(u);
  order.push_back(v);
}
void dfs2(int v) {
  comp.push_back(v);
  visited[v] = 1;
  for (auto u : gt[v])
    if (!visited[u]) dfs2(u);
}
int main() {
  int n, m, h;
  cin >> n >> m >> h;
  g.resize(n);
  gt.resize(n);
  visited.resize(n, 0);
  VI upd(n);
  for (int i = 0; i < n; i++) cin >> upd[i];
  for (int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    a--, b--;
    if ((upd[a] + 1) % h == upd[b]) {
      g[a].push_back(b);
      gt[b].push_back(a);
    }
    if ((upd[b] + 1) % h == upd[a]) {
      g[b].push_back(a);
      gt[a].push_back(b);
    }
  }
  for (int i = 0; i < n; i++)
    if (!visited[i]) dfs1(i);
  visited.resize(0);
  visited.resize(n, 0);
  VI ans;
  VI colors(n, -1);
  int color = 0;
  for (int i = 0; i < n; i++) {
    int v = order[n - 1 - i];
    if (visited[v]) continue;
    dfs2(v);
    for (auto x : comp) {
      colors[x] = color;
    }
    bool ok = true;
    for (auto x : comp) {
      for (auto y : g[x]) {
        if (colors[y] != color) ok = false;
      }
    }
    if (ok && (ans.empty() || ans.size() > comp.size())) ans = comp;
    comp.clear();
    color++;
  }
  cout << ans.size() << endl;
  for (auto i : ans) cout << i + 1 << " ";
  return 0;
}
