#include <bits/stdc++.h>
using namespace std;
const int N = 200010;
struct edge {
  int la, b;
} con[N];
int tot, fir[N];
void add(int from, int to) {
  con[++tot] = (edge){fir[from], to};
  fir[from] = tot;
}
int dfn[N], sta[N], top, low[N], deg[N], col[N], n, cnt, m, h, tms[N];
vector<int> gro[N];
void dfs(int pos) {
  dfn[pos] = low[pos] = ++top;
  sta[top] = pos;
  for (int i = fir[pos]; i; i = con[i].la) {
    if (!dfn[con[i].b]) {
      dfs(con[i].b);
      low[pos] = min(low[pos], low[con[i].b]);
    } else if (!col[con[i].b])
      low[pos] = min(low[pos], low[con[i].b]);
  }
  if (low[pos] == dfn[pos]) {
    cnt++;
    while (top >= dfn[pos]) {
      gro[cnt].push_back(sta[top]);
      col[sta[top--]] = cnt;
    }
  }
}
int main() {
  int a, b, ans;
  scanf("%d%d%d", &n, &m, &h);
  for (int i = 1; i <= n; ++i) scanf("%d", &tms[i]);
  for (int i = 1; i <= m; ++i) {
    scanf("%d%d", &a, &b);
    if ((tms[a] + 1) % h == tms[b]) add(a, b);
    if (tms[a] == (tms[b] + 1) % h) add(b, a);
  }
  for (int i = 1; i <= n; ++i)
    if (!dfn[i]) dfs(i);
  for (int pos = 1; pos <= n; ++pos)
    for (int i = fir[pos]; i; i = con[i].la)
      if (col[con[i].b] != col[pos]) deg[col[pos]]++;
  ans = 1;
  for (int i = 2; i <= cnt; ++i)
    if (!deg[i]) {
      if (gro[i].size() < gro[ans].size()) ans = i;
    }
  printf("%d\n", gro[ans].size());
  for (int i = 0; i < (int)gro[ans].size(); ++i) printf("%d ", gro[ans][i]);
  puts("");
  return 0;
}
