#include <bits/stdc++.h>
using namespace std;
const int N = 100005;
int n, m, h, top, clock_, cnm, idx;
int t[N], dfn[N], low[N], sta[N], siz[N], col[N], ou[N];
vector<int> g[N];
void Tarjan(int x) {
  dfn[x] = low[x] = ++clock_;
  sta[++top] = x;
  for (int v : g[x]) {
    if (!dfn[v]) {
      Tarjan(v);
      low[x] = min(low[x], low[v]);
    } else if (!col[v]) {
      low[x] = min(low[x], dfn[v]);
    }
  }
  if (dfn[x] == low[x]) {
    col[x] = ++cnm;
    siz[cnm] = 1;
    for (; sta[top] != x; --top) col[sta[top]] = cnm, ++siz[cnm];
    --top;
  }
}
int main() {
  scanf("%d%d%d", &n, &m, &h);
  for (int i = 1; i <= n; ++i) scanf("%d", &t[i]);
  for (int i = 1, x, y; i <= m; ++i) {
    scanf("%d%d", &x, &y);
    if ((t[x] + 1) % h == t[y]) g[x].push_back(y);
    if ((t[y] + 1) % h == t[x]) g[y].push_back(x);
  }
  for (int i = 1; i <= n; ++i) {
    if (!dfn[i]) Tarjan(i);
  }
  for (int i = 1; i <= n; ++i) {
    for (int v : g[i]) {
      if (col[i] != col[v]) ou[col[i]] = 1;
    }
  }
  siz[0] = n + 1;
  for (int i = 1; i <= n; ++i) {
    if (!ou[col[i]] && siz[idx] > siz[col[i]]) idx = col[i];
  }
  printf("%d\n", siz[idx]);
  for (int i = 1; i <= n; ++i) {
    if (col[i] == idx) printf("%d ", i);
  }
  return 0;
}
