#include <bits/stdc++.h>
using namespace std;
stack<int> s;
vector<int> e[100005], sct[100005];
int dfn[100005], low[100005], tim, bel[100005], scc;
bool vis[100005];
void tarjan(int u) {
  dfn[u] = low[u] = ++tim;
  vis[u] = 1;
  s.push(u);
  for (int v, i = 0; i < e[u].size(); ++i)
    if (!dfn[v = e[u][i]]) {
      tarjan(v);
      low[u] = min(low[v], low[u]);
    } else if (vis[v])
      low[u] = min(dfn[v], low[u]);
  if (dfn[u] == low[u]) {
    ++scc;
    do {
      u = s.top();
      s.pop();
      vis[u] = 0;
      bel[u] = scc;
      sct[scc].push_back(u);
    } while (dfn[u] != low[u]);
  }
}
int n, deg[100005];
inline void shrink_point() {
  for (int i = 1; i <= n; ++i)
    for (int j = 0; j < e[i].size(); ++j)
      if (bel[i] != bel[e[i][j]]) ++deg[bel[i]];
}
int m, h, t[100005], ans, siz = 100005;
int main() {
  scanf("%d %d %d", &n, &m, &h);
  for (int i = 1; i <= n; ++i) scanf("%d", &t[i]);
  for (int u, v, i = 1; i <= m; ++i) {
    scanf("%d %d", &u, &v);
    if ((t[u] + 1) % h == t[v]) e[u].push_back(v);
    if ((t[v] + 1) % h == t[u]) e[v].push_back(u);
  }
  for (int i = 1; i <= n; ++i)
    if (!dfn[i]) tarjan(i);
  shrink_point();
  for (int i = 1; i <= scc; ++i)
    if (deg[i] == 0 && sct[i].size() < siz) {
      ans = i;
      siz = sct[i].size();
    }
  printf("%d\n", sct[ans].size());
  sort(sct[ans].begin(), sct[ans].end());
  for (int i = 0; i < sct[ans].size(); ++i) printf("%d ", sct[ans][i]);
  return 0;
}
