#include <bits/stdc++.h>
using namespace std;
string to_string(string s) { return '"' + s + '"'; }
string to_string(const char* s) { return to_string((string)s); }
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto& x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
const long double eps = 1e-12;
const int N = 1e5 + 9;
int a[N], out[N], c[N];
vector<int> g[N], gr[N], comp[N], ord;
bool vis[N];
void dfs(int u) {
  vis[u] = 1;
  for (int v : g[u]) {
    if (!vis[v]) {
      dfs(v);
    }
  }
  ord.push_back(u);
}
void dfsr(int u, int comps) {
  comp[comps].push_back(u);
  c[u] = comps;
  vis[u] = 1;
  for (int v : gr[u]) {
    if (!vis[v]) {
      dfsr(v, comps);
    }
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, m, h;
  cin >> n >> m >> h;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  for (int i = 0; i < m; i++) {
    int u, v;
    cin >> u >> v;
    if ((a[u] + 1) % h == a[v]) {
      out[u]++;
      g[u].push_back(v);
      gr[v].push_back(u);
    }
    if ((a[v] + 1) % h == a[u]) {
      out[v]++;
      g[v].push_back(u);
      gr[u].push_back(v);
    }
  }
  for (int i = 1; i <= n; i++) {
    sort(g[i].begin(), g[i].end());
    g[i].resize(unique(g[i].begin(), g[i].end()) - g[i].begin());
    sort(gr[i].begin(), gr[i].end());
    gr[i].resize(unique(gr[i].begin(), gr[i].end()) - gr[i].begin());
  }
  for (int i = 1; i <= n; i++) {
    if (!vis[i]) dfs(i);
  }
  reverse(ord.begin(), ord.end());
  memset(vis, 0, sizeof vis);
  int comps = 0;
  for (int i : ord) {
    if (!vis[i]) {
      comps++;
      dfsr(i, comps);
    }
  }
  int ans = -1;
  for (int i = 1; i <= comps; i++) {
    int cnt = 0;
    for (int j : comp[i]) {
      for (int k : g[j])
        if (c[k] != i) cnt++;
    }
    if (cnt == 0 && (ans == -1 || comp[ans].size() > comp[i].size())) ans = i;
  }
  cout << comp[ans].size() << endl;
  for (int i : comp[ans]) cout << i << " ";
  cout << endl;
  return 0;
}
