#include <bits/stdc++.h>
using namespace std;
int n, m, h;
int t[100010];
struct edge {
  int to, nxt;
} e[100010 << 2];
int edgenum = 0;
int lin[100010] = {0};
void add(int a, int b) {
  ++edgenum;
  e[edgenum].to = b;
  e[edgenum].nxt = lin[a];
  lin[a] = edgenum;
  return;
}
stack<int> s;
int dfn[100010], low[100010], tot = 0;
bool v[100010];
int ins[100010], siz[100010];
int scc = 0;
void tarjan(int k) {
  dfn[k] = low[k] = ++tot;
  s.push(k);
  v[k] = true;
  for (int i = lin[k]; i != 0; i = e[i].nxt) {
    if (dfn[e[i].to] == 0) {
      tarjan(e[i].to);
      low[k] = min(low[k], low[e[i].to]);
    } else if (v[e[i].to]) {
      low[k] = min(low[k], dfn[e[i].to]);
    }
  }
  if (low[k] >= dfn[k]) {
    int t;
    ++scc;
    do {
      t = s.top();
      s.pop();
      v[t] = false;
      ins[t] = scc;
      siz[scc]++;
    } while (t != k);
  }
  return;
}
int deg[100010];
int main() {
  scanf("%d%d%d", &n, &m, &h);
  for (int i = 1; i <= n; ++i) {
    scanf("%d", &t[i]);
  }
  int c1, c2;
  for (int i = 1; i <= m; ++i) {
    scanf("%d%d", &c1, &c2);
    if ((t[c1] + 1) % h == t[c2]) add(c1, c2);
    if ((t[c2] + 1) % h == t[c1]) add(c2, c1);
  }
  for (int i = 1; i <= n; ++i) {
    if (dfn[i] == 0) {
      tarjan(i);
    }
  }
  memset(deg, 0, sizeof(deg));
  for (int k = 1; k <= n; ++k) {
    for (int i = lin[k]; i != 0; i = e[i].nxt) {
      if (ins[k] != ins[e[i].to]) {
        ++deg[ins[k]];
      }
    }
  }
  int ans = -1;
  for (int i = 1; i <= scc; ++i) {
    if (deg[i] == 0) {
      if (ans == -1 || siz[i] < siz[ans]) {
        ans = i;
      }
    }
  }
  cout << siz[ans] << endl;
  for (int i = 1; i <= n; ++i) {
    if (ins[i] == ans) {
      printf("%d ", i);
    }
  }
  puts("");
  return 0;
}
