#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
int n, m, h, w[N], df[N], low[N], cnt, ans, stk[N], vs[N], top;
int head[N], to[N << 1], nxt[N << 1], tot;
int bel[N], sz[N], cir, siz[N], idx[N];
vector<int> g[N], qw[N];
inline void lk(int u, int v) {
  to[++tot] = v;
  nxt[tot] = head[u];
  head[u] = tot;
}
void dfs(int x) {
  df[x] = low[x] = ++cnt;
  stk[++top] = x;
  vs[x] = 1;
  int i, j;
  for (i = g[x].size() - 1; ~i; --i) {
    j = g[x][i];
    if (!df[j]) {
      dfs(j);
      low[x] = min(low[x], low[j]);
    } else if (vs[j]) {
      low[x] = min(low[x], df[j]);
    }
  }
  if (df[x] == low[x]) {
    cir++;
    for (; stk[top + 1] != x; top--) {
      vs[stk[top]] = 0;
      sz[cir]++;
      bel[stk[top]] = cir;
      qw[cir].push_back(stk[top]);
    }
  }
}
int main() {
  int i, j, k, x, y, z;
  scanf("%d%d%d", &n, &m, &h);
  for (i = 1; i <= n; ++i) scanf("%d", &w[i]);
  for (i = 1; i <= m; ++i) {
    scanf("%d%d", &x, &y);
    lk(x, y);
    lk(y, x);
  }
  for (i = 1; i <= n; ++i) {
    x = w[i] + 1;
    if (x == h) x = 0;
    for (j = head[i]; j; j = nxt[j])
      if (w[to[j]] == x) g[i].push_back(to[j]);
  }
  ans = N;
  for (i = 1; i <= n; ++i)
    if (!df[i]) dfs(i);
  for (i = 1; i <= n; ++i) {
    x = bel[i];
    for (j = g[i].size() - 1; ~j; --j) {
      y = bel[g[i][j]];
      if (x == y) continue;
      idx[x]++;
      break;
    }
  }
  for (i = 1; i <= cir; ++i)
    if (!idx[i] && ans > sz[i]) {
      ans = sz[i];
      j = i;
    }
  printf("%d\n", ans);
  for (i = qw[j].size() - 1; ~i; --i) printf("%d ", qw[j][i]);
  return 0;
}
