#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int N = 200005;
int n, m, h, u[N];
vector<int> g[N], gt[N];
void add(int x, int y) {
  g[x].push_back(y);
  gt[y].push_back(x);
}
vector<int> order;
int used[N];
void dfs(int v) {
  used[v] = 1;
  for (auto& to : g[v])
    if (!used[to]) {
      dfs(to);
    }
  order.push_back(v);
}
int color[N];
int clr;
int cnt[N];
void dfsr(int v) {
  color[v] = clr;
  ++cnt[clr];
  used[v] = 1;
  for (auto& to : gt[v])
    if (!used[to]) {
      dfsr(to);
    }
}
int deg[N];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n >> m >> h;
  for (int i = 0; i < (n); ++i) cin >> u[i];
  for (int i = 0; i < (m); ++i) {
    int x, y;
    cin >> x >> y;
    --x;
    --y;
    if ((u[x] + 1) % h == u[y]) add(x, y);
    if ((u[y] + 1) % h == u[x]) add(y, x);
  }
  for (int i = 0; i < (n); ++i)
    if (!used[i]) dfs(i);
  fill(used, used + n, 0);
  reverse(order.begin(), order.end());
  for (auto& v : order)
    if (!used[v]) {
      dfsr(v);
      ++clr;
    }
  for (int v = 0; v < (n); ++v)
    for (auto& to : g[v])
      if (color[to] != color[v]) ++deg[color[v]];
  int mn = n + 1, col;
  for (int c = 0; c < (clr); ++c)
    if (!deg[c]) {
      if (mn > cnt[c]) {
        mn = cnt[c];
        col = c;
      }
    }
  vector<int> result;
  for (int v = 0; v < (n); ++v)
    if (color[v] == col) result.push_back(v);
  cout << ((int)(result).size()) << '\n';
  for (auto& e : result) cout << e + 1 << ' ';
  cout << '\n';
  return 0;
}
