#include <bits/stdc++.h>
using namespace std;
const int N = 100005;
int n, m, h, i, j, x, y, p, t, sum;
int a[N], f[N], g[N], dfn[N], low[N], ans[N];
int b[N], lst[N], e[N * 2][2], c[N];
bool bz[N];
void link(int x, int y) { e[++t][0] = lst[x], e[t][1] = y, lst[x] = t; }
int find(int x) {
  if (x == f[x])
    return x;
  else
    return f[x] = find(f[x]);
}
void merge(int x, int y) {
  x = find(x), y = find(y);
  f[x] = y, g[y] += g[x];
}
void dg(int x) {
  dfn[x] = low[x] = ++t, c[++c[0]] = x, bz[x] = 1;
  int i = lst[x];
  while (i) {
    int y = e[i][1];
    i = e[i][0];
    if (!dfn[y])
      dg(y), low[x] = min(low[x], low[y]);
    else if (bz[y])
      low[x] = min(low[x], dfn[y]);
  }
  if (low[x] == dfn[x]) {
    while (x != c[c[0]]) merge(x, c[c[0]]), bz[c[c[0]--]] = 0;
    bz[x] = 0, c[0]--;
  }
}
void dg2(int x) {
  if (bz[x]) return;
  int i = lst[x];
  bz[x] = 1, ans[++ans[0]] = x;
  while (i) {
    int y = e[i][1];
    i = e[i][0], dg2(y);
  }
}
int main() {
  scanf("%d%d%d", &n, &m, &h);
  for (i = 1; i <= n; i++) scanf("%d", &a[i]), f[i] = i, g[i] = 1;
  for (i = 1; i <= m; i++) {
    scanf("%d%d", &x, &y);
    if ((a[x] + 1) % h == a[y]) link(x, y), b[x]++;
    if ((a[y] + 1) % h == a[x]) link(y, x), b[y]++;
  }
  for (i = 1; i <= n; i++)
    if (!b[i]) {
      ans[0] = 1, ans[1] = i;
      break;
    }
  if (!ans[0]) {
    t = 0;
    for (i = 1; i <= n; i++)
      if (!dfn[i]) dg(i);
    memset(b, 0, sizeof(b));
    c[0] = 0;
    for (i = 1; i <= n; i++) {
      j = lst[i], x = find(i);
      if (i == x) c[++c[0]] = i;
      while (j) {
        t = e[j][1], j = e[j][0], y = find(t);
        if (x != y) b[x]++;
      }
    }
    ans[0] = n + 1;
    for (i = 1; i <= c[0]; i++)
      if (!b[x = c[i]]) {
        if (g[x] < ans[0]) ans[0] = g[x], p = x;
      }
    memset(bz, 0, sizeof(bz));
    ans[0] = 0, dg2(p);
  }
  printf("%d\n", ans[0]);
  for (i = 1; i <= ans[0]; i++) printf("%d ", ans[i]);
}
