#include <bits/stdc++.h>
using namespace std;
const int M = 100010;
int n, m, h, tot, num, cnt, top;
int c[M], head[M], dfn[M], low[M], a[M], vis[M], siz[M];
int color[M * 2], flg, minn, du[M * 2];
struct Edge {
  int y, nxt;
} side[M * 2];
void add(int x, int y) {
  side[++tot].nxt = head[x];
  side[tot].y = y;
  head[x] = tot;
}
void tarjan(int x) {
  dfn[x] = low[x] = ++cnt;
  a[++top] = x;
  vis[x] = 1;
  for (int i = head[x]; i; i = side[i].nxt) {
    int y = side[i].y;
    if (!dfn[y])
      tarjan(y), low[x] = min(low[x], low[y]);
    else if (vis[y])
      low[x] = min(low[x], dfn[y]);
  }
  if (dfn[x] == low[x]) {
    num++;
    int y;
    do {
      y = a[top--];
      vis[y] = 0;
      color[y] = num;
      siz[num]++;
    } while (x != y);
  }
}
int main() {
  scanf("%d%d%d", &n, &m, &h);
  for (int i = 1; i <= n; i++) scanf("%d", &c[i]);
  for (int i = 1, xx, yy; i <= m; i++) {
    scanf("%d%d", &xx, &yy);
    if ((c[xx] + 1) % h == c[yy]) add(xx, yy);
    if ((c[yy] + 1) % h == c[xx]) add(yy, xx);
  }
  for (int i = 1; i <= n; i++)
    if (!dfn[i]) tarjan(i);
  for (int i = 1; i <= n; i++)
    for (int j = head[i]; j; j = side[j].nxt) {
      int y = side[j].y;
      if (color[i] != color[y]) du[color[i]]++;
    }
  minn = 646584864;
  for (int i = 1; i <= num; i++)
    if (!du[i] && siz[i] < minn) {
      minn = siz[i];
      flg = i;
    }
  printf("%d\n", minn);
  for (int i = 1; i <= n; i++)
    if (color[i] == flg) cout << i << " ";
}
