#include <bits/stdc++.h>
using namespace std;
inline long long read() {
  long long k = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    k = k * 10 + ch - '0';
    ch = getchar();
  }
  return k * f;
}
inline void write(long long x) {
  if (x < 0) putchar('-'), x = -x;
  if (x > 9) write(x / 10);
  putchar(x % 10 + '0');
}
inline void writeln(long long x) {
  write(x);
  puts("");
}
bool vis[100010];
long long s[100010], top = 0, dist[100010], f[100010], H;
long long n, m, a[100010], b[100010], dfn[100010], low[100010], l[100010],
    d[100010];
long long nedge = 0, p[200010], nex[200010], head[200010], dx[200010];
inline void addedge(long long a, long long b) {
  p[++nedge] = b;
  nex[nedge] = head[a];
  head[a] = nedge;
}
long long cnt = 0;
inline void dfs(long long x) {
  dfn[x] = low[x] = ++cnt;
  s[++top] = x;
  vis[x] = 1;
  for (long long k = head[x]; k; k = nex[k])
    if (!dfn[p[k]]) {
      dfs(p[k]);
      low[x] = min(low[x], low[p[k]]);
    } else if (vis[p[k]])
      low[x] = min(low[x], dfn[p[k]]);
  if (dfn[x] == low[x]) {
    d[0]++;
    long long k = 0;
    do {
      k = s[top--];
      vis[k] = 0;
      l[k] = d[0];
      d[d[0]]++;
    } while (k != x);
  }
}
map<pair<long long, long long>, bool> M;
signed main() {
  n = read();
  m = read();
  H = read();
  for (long long i = 1; i <= n; i++) a[i] = read();
  for (long long i = 1; i <= m; i++) {
    long long x = read(), y = read();
    if (!M[make_pair(x, y)])
      M[make_pair(x, y)] = 1;
    else
      continue;
    if ((a[x] + 1) % H == a[y]) addedge(x, y);
    if ((a[y] + 1) % H == a[x]) addedge(y, x);
  }
  for (long long i = 1; i <= n; i++)
    if (!dfn[i]) dfs(i);
  for (long long i = 1; i <= n; i++)
    for (long long k = head[i]; k; k = nex[k])
      if (l[i] != l[p[k]]) dx[l[i]]++;
  long long ans, minn = 1e9;
  for (long long i = 1; i <= d[0]; i++)
    if (!dx[i]) {
      if (minn > d[i]) minn = d[i], ans = i;
    }
  writeln(minn);
  for (long long i = 1; i <= n; i++)
    if (l[i] == ans) write(i), putchar(' ');
  return 0;
}
