#include <bits/stdc++.h>
using namespace std;
const int N = 101000;
int n, m, h, a[N], fir[N], cnt;
struct node {
  int nxt, to;
} e[N << 1];
void add(int u, int v) {
  e[++cnt].nxt = fir[u];
  fir[u] = cnt;
  e[cnt].to = v;
}
int scc[N], dfn[N], low[N], tot, du[N], color, sz[N];
stack<int> s;
bool in[N];
void tarjan(int u) {
  dfn[u] = low[u] = ++tot;
  s.push(u);
  in[u] = 1;
  int v;
  for (int i = fir[u]; i; i = e[i].nxt) {
    v = e[i].to;
    if (!dfn[v]) {
      tarjan(v);
      low[u] = min(low[u], low[v]);
    } else if (in[v]) {
      low[u] = min(low[u], dfn[v]);
    }
  }
  int num = 0;
  if (low[u] == dfn[u]) {
    ++color;
    do {
      ++num;
      v = s.top();
      s.pop();
      in[v] = 0;
      scc[v] = color;
    } while (low[v] != dfn[v]);
    sz[color] = num;
  }
}
int main() {
  scanf("%d%d%d", &n, &m, &h);
  for (int i = 1; i <= n; ++i) {
    scanf("%d", &a[i]);
  }
  int u, v;
  for (int i = 1; i <= m; ++i) {
    scanf("%d%d", &u, &v);
    if ((a[u] + 1) % h == a[v]) {
      add(u, v);
    }
    if ((a[v] + 1) % h == a[u]) {
      add(v, u);
    }
  }
  for (int i = 1; i <= n; ++i)
    if (!dfn[i]) {
      tarjan(i);
    }
  for (int u = 1; u <= n; ++u) {
    for (int v, i = fir[u]; i; i = e[i].nxt) {
      v = e[i].to;
      if (scc[u] != scc[v]) {
        ++du[scc[u]];
      }
    }
  }
  int ans = 0x3f3f3f3f, col = 0;
  for (int i = 1; i <= color; ++i) {
    if (du[i] == 0) {
      if (ans > sz[i]) {
        ans = sz[i];
        col = i;
      }
    }
  }
  printf("%d\n", ans);
  for (int i = 1; i <= n; ++i)
    if (scc[i] == col) printf("%d ", i);
  return 0;
}
