#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 100;
int n, m, h, timer, cnt;
int a[maxn], dfn[maxn], low[maxn], scc[maxn], sz[maxn];
bool vis[maxn], exist[maxn], fuck[maxn];
vector<int> g[maxn], stk;
void tarjan(int u) {
  dfn[u] = low[u] = ++timer;
  vis[u] = 1;
  exist[u] = 1;
  stk.push_back(u);
  for (int v : g[u]) {
    if (vis[v]) {
      if (exist[v] && low[u] > dfn[v]) {
        low[u] = dfn[v];
      }
    } else {
      tarjan(v);
      low[u] = min(low[u], low[v]);
    }
  }
  if (dfn[u] == low[u]) {
    ++cnt;
    int v;
    do {
      v = stk.back();
      stk.pop_back();
      exist[v] = 0;
      scc[v] = cnt;
      ++sz[cnt];
    } while (stk.size() && u != v);
  }
  return;
}
int main() {
  scanf("%d%d%d", &n, &m, &h);
  for (int i = 1; i <= n; ++i) {
    scanf("%d", a + i);
  }
  while (m--) {
    int u, v;
    scanf("%d%d", &u, &v);
    if (a[v] == (a[u] + 1) % h) {
      g[u].push_back(v);
    }
    swap(u, v);
    if (a[v] == (a[u] + 1) % h) {
      g[u].push_back(v);
    }
  }
  for (int i = 1; i <= n; ++i) {
    if (!dfn[i]) {
      tarjan(i);
    }
  }
  for (int u = 1; u <= n; ++u) {
    for (int v : g[u]) {
      if (scc[v] != scc[u]) {
        fuck[scc[u]] = 1;
      }
    }
  }
  int ans = n + 1, rem;
  for (int i = 1; i <= cnt; ++i) {
    if (!fuck[i] && sz[i] < ans) {
      ans = sz[i];
      rem = i;
    }
  }
  printf("%d\n", ans);
  for (int i = 1; i <= n; ++i) {
    if (scc[i] == rem) {
      printf("%d ", i);
    }
  }
  return 0;
}
