#include <bits/stdc++.h>
using namespace std;
int first[100010], n, m, h;
int dfn[100010], low[100010], TIM, sta[100010], top, sz[100010];
int scc[100010], cnt, SCC, u[100010];
bool ok[100010];
struct edge {
  int to, next, val;
} e[100010 << 1];
int input() {
  int f = 1, g = 0;
  char c = getchar();
  while (c < '0' || c > '9') {
    if (c == '-') f = -1;
    c = getchar();
  }
  while (c >= '0' && c <= '9') {
    g = g * 10 + c - '0';
    c = getchar();
  }
  return f * g;
}
void add(int x, int y) {
  e[cnt].to = y;
  e[cnt].next = first[x];
  first[x] = cnt++;
}
void tarjan(int x) {
  dfn[x] = low[x] = ++TIM;
  sta[++top] = x;
  for (int i = first[x]; i != -1; i = e[i].next)
    if (!dfn[e[i].to])
      tarjan(e[i].to), low[x] = min(low[x], low[e[i].to]);
    else if (!scc[e[i].to])
      low[x] = min(low[x], dfn[e[i].to]);
  if (dfn[x] == low[x]) {
    SCC++;
    while (1) {
      scc[sta[top]] = SCC, sz[SCC]++, top--;
      if (sta[top + 1] == x) break;
    }
  }
}
int main() {
  memset(first, -1, sizeof(first));
  n = input(), m = input(), h = input();
  for (int i = 1; i <= n; i++) u[i] = input();
  for (int i = 1; i <= m; i++) {
    int x = input(), y = input();
    if ((u[x] + 1) % h == u[y]) add(x, y);
    if ((u[y] + 1) % h == u[x]) add(y, x);
  }
  for (int i = 1; i <= n; i++)
    if (!dfn[i]) tarjan(i);
  for (int x = 1; x <= n; x++)
    for (int i = first[x]; i != -1; i = e[i].next)
      if (scc[x] != scc[e[i].to]) {
        ok[scc[x]] = 1;
        break;
      }
  int ans = 2000000000, id = 0;
  for (int i = 1; i <= SCC; i++)
    if (!ok[i]) {
      if (ans > sz[i]) ans = sz[i], id = i;
    }
  cout << ans << endl;
  for (int i = 1; i <= n; i++)
    if (scc[i] == id) cout << i << " ";
  cout << endl;
  return 0;
}
