#include <bits/stdc++.h>
#pragma GCC optimize("O3", "unroll-loops")
using namespace std;
const long long inf = numeric_limits<long long>::max() / 2;
const long double eps = 1e-9;
const long double pi = acos(-1);
struct graph {
  long long vn;
  vector<set<long long> > es;
  graph() {}
  graph(long long v) {
    vn = v;
    es.resize(vn + 1);
  }
  void insert(long long v, long long u) { es[v].insert(u); }
};
long long N, M, H;
graph g, gt;
vector<long long> u;
vector<long long> tsort;
vector<bool> used;
void dfs(long long v) {
  used[v] = true;
  for (long long u : g.es[v]) {
    if (used[u]) {
      continue;
    }
    dfs(u);
  }
  tsort.push_back(v);
}
vector<vector<long long> > cs;
vector<long long> color;
void dfs2(long long v, long long c) {
  used[v] = true;
  cs.back().push_back(v);
  color[v] = c;
  for (long long u : gt.es[v]) {
    if (used[u]) {
      continue;
    }
    dfs2(u, c);
  }
}
void solve() {
  used.assign(g.vn + 1, false);
  for (long long i = 1; i <= g.vn; i++) {
    if (!used[i]) {
      dfs(i);
    }
  }
  reverse((tsort).begin(), (tsort).end());
  used.assign(g.vn + 1, false);
  color.assign(g.vn + 1, -1);
  long long c = 0;
  for (long long v : tsort) {
    if (!used[v]) {
      cs.push_back({});
      dfs2(v, c);
      ++c;
    }
  }
  vector<long long> ind;
  for (long long i = 0; i < c; i++) {
    bool ok = true;
    for (long long v : cs[i]) {
      for (long long u : g.es[v]) {
        if (color[u] != i) {
          ok = false;
        }
      }
    }
    if (ok) {
      ind.push_back(i);
    }
  }
  long long minn = ind[0];
  for (long long i : ind) {
    if ((long long)((cs[i]).size()) < (long long)((cs[minn]).size())) {
      minn = i;
    }
  }
  cout << (long long)((cs[minn]).size()) << "\n";
  for (long long v : cs[minn]) {
    cout << v << " ";
  }
}
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cin >> N >> M >> H;
  u.resize(N + 1);
  for (long long i = 1; i <= N; i++) {
    cin >> u[i];
  }
  g = graph(N);
  gt = graph(N);
  for (long long i = 0; i < M; i++) {
    long long c1, c2;
    cin >> c1 >> c2;
    long long h1, h2;
    h1 = u[c1], h2 = u[c2];
    if (u[c1] == 0) {
      h1 = H;
    }
    if (h1 - h2 == 1) {
      g.insert(c2, c1);
      gt.insert(c1, c2);
    }
    h1 = u[c1], h2 = u[c2];
    if (u[c2] == 0) {
      h2 = H;
    }
    if (h2 - h1 == 1) {
      g.insert(c1, c2);
      gt.insert(c2, c1);
    }
  }
  solve();
  return 0;
}
