#include <bits/stdc++.h>
using namespace std;
const int maxn = 1E5 + 77;
struct EDGE {
  int to, next;
} edges[maxn * 4];
int cEdge = 1, head[maxn];
void addEdge(int from, int to) {
  edges[cEdge] = (EDGE){to, head[from]};
  head[from] = cEdge++;
}
int N, M, H, U[maxn];
int inc(int v) {
  ++v;
  if (v >= H)
    return v - H;
  else
    return v;
}
int dfx[maxn], low[maxn], cx, sccno[maxn], cscc, sccsize[maxn], sccout[maxn];
int st[maxn], top;
void dfs(int u) {
  dfx[u] = low[u] = ++cx;
  st[top++] = u;
  for (int k = head[u]; k; k = edges[k].next) {
    int v = edges[k].to;
    if (!dfx[v]) {
      dfs(v);
      low[u] = min(low[u], low[v]);
    } else if (!sccno[v]) {
      low[u] = min(low[u], dfx[v]);
    }
  }
  if (low[u] == dfx[u]) {
    ++cscc;
    while (st[top] != u) {
      sccno[st[--top]] = cscc;
    }
  }
}
void print(int v) {
  static bool first = true;
  if (first) {
    printf("%d", v);
    first = false;
  } else {
    printf(" %d", v);
  }
}
int main() {
  scanf("%d%d%d", &N, &M, &H);
  for (int i = 1; i <= N; ++i) scanf("%d", U + i);
  for (int i = 0; i < M; ++i) {
    int x, y;
    scanf("%d%d", &x, &y);
    if (inc(U[x]) == U[y]) addEdge(x, y);
    if (inc(U[y]) == U[x]) addEdge(y, x);
  }
  for (int i = 1; i <= N; ++i)
    if (!dfx[i]) dfs(i);
  for (int i = 1; i <= N; ++i) {
    sccsize[sccno[i]]++;
    for (int k = head[i]; k; k = edges[k].next) {
      int v = edges[k].to;
      if (sccno[i] != sccno[v]) {
        sccout[sccno[i]]++;
      }
    }
  }
  int ans = 1E9 + 7, X = 0;
  for (int i = 1; i <= cscc; ++i)
    if (sccout[i] == 0 && sccsize[i] < ans) {
      ans = sccsize[i];
      X = i;
    }
  printf("%d\n", sccsize[X]);
  for (int i = 1; i <= N; ++i)
    if (sccno[i] == X) print(i);
  printf("\n");
}
