#include <bits/stdc++.h>
struct r {
  int to, last;
} e[200050];
int dfn[100050], low[100050], sta[100050], bn, t,
    num = 1, head[100050], st, b[100050], bnum[200050], ti[100050];
void add(int u, int v) {
  e[num].to = v;
  e[num].last = head[u];
  head[u] = num++;
}
bool insta[100050], f[100050];
void tarjan(int u) {
  dfn[u] = low[u] = ++t;
  sta[++st] = u;
  insta[u] = 1;
  int y;
  for (int i = head[u]; i; i = e[i].last) {
    if (!dfn[y = e[i].to]) {
      tarjan(y);
      low[u] = std::min(low[u], low[y]);
    } else if (insta[y])
      low[u] = std::min(low[u], dfn[y]);
  }
  if (low[u] == dfn[u]) {
    int j;
    bn++;
    do {
      j = sta[st--];
      b[j] = bn;
      insta[j] = 0;
      bnum[bn]++;
    } while (j != u);
  }
}
int main() {
  int n, m, u, v, h;
  scanf("%d%d%d", &n, &m, &h);
  for (int i = 1; i <= n; i++) scanf("%d", &ti[i]);
  for (int i = 1; i <= m; i++) {
    scanf("%d%d", &u, &v);
    if ((ti[u] + 1) % h == ti[v]) add(u, v);
    if ((ti[v] + 1) % h == ti[u]) add(v, u);
  }
  for (int i = 1; i <= n; i++)
    if (!dfn[i]) tarjan(i);
  for (int i = 1; i <= n; i++)
    if (!f[b[i]])
      for (int j = head[i]; j; j = e[j].last)
        if (b[i] != b[e[j].to]) {
          f[b[i]] = 1;
          continue;
        }
  int ans = 2147483647, p;
  for (int i = 1; i <= bn; i++)
    if (!f[i] && ans > bnum[i]) ans = bnum[i], p = i;
  printf("%d\n", ans);
  for (int i = 1; i <= n; i++)
    if (b[i] == p) printf("%d ", i);
}
