#include <bits/stdc++.h>
using namespace std;
const int MAXN = 100005;
int n, m, h;
int u[MAXN];
int c[2][MAXN];
vector<int> g[MAXN];
vector<int> scc[MAXN];
int scctot;
int stk[MAXN], tp;
int dfn[MAXN], low[MAXN], tot;
bool son[MAXN], mark[MAXN];
void Tarjan(int x) {
  dfn[x] = low[x] = ++tot;
  stk[tp++] = x;
  for (int i = 0, iend = g[x].size(); i < iend; ++i) {
    int t = g[x][i];
    if (dfn[t])
      low[x] = min(low[x], dfn[t]);
    else
      Tarjan(t), low[x] = min(low[x], low[t]);
    if (mark[t]) son[x] = true;
  }
  if (dfn[x] == low[x]) {
    scctot++;
    vector<int> &S = scc[scctot];
    while (true) {
      int now = stk[--tp];
      mark[now] = true;
      S.push_back(now);
      if (now == x) break;
    }
  }
}
int main() {
  scanf("%d %d %d", &n, &m, &h);
  for (int i = 1, iend = n; i <= iend; ++i) scanf("%d", &u[i]);
  for (int i = 1, iend = m; i <= iend; ++i) {
    scanf("%d %d", &c[0][i], &c[1][i]);
    int x = c[0][i], y = c[1][i];
    if ((u[x] + 1) % h == u[y]) g[x].push_back(y);
    if ((u[y] + 1) % h == u[x]) g[y].push_back(x);
  }
  for (int i = 1, iend = n; i <= iend; ++i)
    if (!dfn[i]) Tarjan(i);
  int misz = n + 1, id = -1;
  for (int i = 1, iend = scctot; i <= iend; ++i) {
    bool chk = true;
    for (int j = 0, jend = scc[i].size(); j < jend; ++j)
      if (son[scc[i][j]]) chk = false;
    if (chk && (int)scc[i].size() < misz) misz = scc[i].size(), id = i;
  }
  cout << scc[id].size() << endl;
  for (int i = 0, iend = scc[id].size(); i < iend; ++i)
    printf("%d ", scc[id][i]);
  puts("");
  return 0;
}
