#include <bits/stdc++.h>
using namespace std;
struct Edge {
  int to, nxt;
} edge[100005 << 2];
int n, m, t, h[100005], head[100005], tot, d[100005][2];
int c[100005], low[100005], dfn[100005], stk[100005], ins[100005], ind, top;
int cnt;
vector<int> scc[100005];
void tarjan(int x) {
  dfn[x] = low[x] = ++ind;
  stk[++top] = x;
  ins[x] = 1;
  for (int i = head[x]; i != -1; i = edge[i].nxt) {
    int y = edge[i].to;
    if (!dfn[y]) {
      tarjan(y);
      low[x] = min(low[x], low[y]);
    } else if (ins[y])
      low[x] = min(low[x], dfn[y]);
  }
  if (dfn[x] == low[x]) {
    cnt++;
    int y;
    do {
      y = stk[top--];
      ins[y] = 0;
      c[y] = cnt;
      scc[cnt].push_back(y);
    } while (x != y);
  }
}
void init() {
  tot = 0;
  memset(head, -1, sizeof head);
}
void addedge(int u, int v) {
  edge[tot].nxt = head[u];
  edge[tot].to = v;
  head[u] = tot++;
}
int in[100005], out[100005];
int main() {
  init();
  cin >> n >> m >> t;
  for (int i = 1; i <= n; i++) scanf("%d", &h[i]);
  for (int i = 1; i <= m; i++) scanf("%d%d", &d[i][0], &d[i][1]);
  for (int i = 1; i <= m; i++) {
    if ((h[d[i][0]] + 1) % t == h[d[i][1]]) addedge(d[i][0], d[i][1]);
    if ((h[d[i][1]] + 1) % t == h[d[i][0]]) addedge(d[i][1], d[i][0]);
  }
  for (int i = 1; i <= n; i++)
    if (!dfn[i]) tarjan(i);
  for (int x = 1; x <= n; x++)
    for (int i = head[x]; i != -1; i = edge[i].nxt) {
      int y = edge[i].to;
      if (c[x] == c[y]) continue;
      in[c[y]]++;
      out[c[x]]++;
    }
  int ans = 0x3f3f3f3f, k;
  for (int i = 1; i <= cnt; i++)
    if (out[i] == 0 && scc[i].size() < ans) k = i, ans = scc[i].size();
  cout << ans << endl;
  for (int i = 0; i < scc[k].size(); i++) printf("%d ", scc[k][i]);
}
