#include <bits/stdc++.h>
using namespace std;
struct edge {
  long long v, next;
} e[200005];
long long top = 1;
long long head[200005];
void Add_Edge(long long u, long long v) {
  e[++top] = edge{v, head[u]};
  head[u] = top;
}
long long n, m, h, cnt, Index;
long long value[200005];
long long chu[200005], dfn[200005], low[200005], size[200005], belong[200005];
bool vis[200005];
stack<long long> s;
long long Abs(long long x) { return x > 0 ? x : -x; }
void Tarjan(long long u) {
  vis[u] = 1;
  s.push(u);
  dfn[u] = low[u] = ++Index;
  for (register long long i = head[u]; i; i = e[i].next) {
    long long v = e[i].v;
    if (!dfn[v]) {
      Tarjan(v);
      low[u] = min(low[u], low[v]);
    } else if (vis[v])
      low[u] = min(low[u], dfn[v]);
  }
  if (low[u] == dfn[u]) {
    ++cnt;
    while (1) {
      long long v = s.top();
      s.pop();
      vis[v] = 0;
      size[cnt]++;
      belong[v] = cnt;
      if (v == u) break;
    }
  }
}
long long read() {
  long long x = 0;
  char c = getchar();
  long long f = 1;
  while (c < '0' || c > '9') {
    if (c == '-') f = -f;
    c = getchar();
  }
  while (c >= '0' && c <= '9') {
    x = (x << 3) + (x << 1) + c - '0';
    c = getchar();
  }
  return x * f;
}
void write(long long x) {
  if (x < 0) {
    x = -x;
    putchar('-');
  }
  if (x > 9) write(x / 10);
  putchar(x % 10 + '0');
}
signed main() {
  n = read(), m = read(), h = read();
  for (register long long i = 1; i <= n; ++i) value[i] = read();
  long long Ans = 0;
  for (register long long i = 1; i <= m; ++i) {
    long long u = read(), v = read();
    if ((value[u] + 1) % h == value[v]) Add_Edge(u, v);
    if ((value[v] + 1) % h == value[u]) Add_Edge(v, u);
  }
  for (register long long i = 1; i <= n; ++i)
    if (!dfn[i]) Tarjan(i);
  for (register long long i = 1; i <= n; ++i)
    for (register long long j = head[i]; j; j = e[j].next) {
      long long v = e[j].v;
      if (belong[i] != belong[v]) chu[belong[i]]++;
    }
  long long ans = 0;
  size[0] = 0x3f3f3f3f3f;
  for (register long long i = 1; i <= cnt; ++i)
    if (!chu[i])
      if (size[i] < size[ans]) ans = i;
  write(size[ans]), putchar('\n');
  for (register long long i = 1; i <= n; ++i)
    if (belong[i] == ans) write(i), putchar(' ');
  putchar('\n');
  return 0;
}
