#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
int head[N], dfn[N], low[N], instack[N], st[N], f[N];
int num, cnt, dep, top;
struct node {
  int nxt, ed;
} e[3 * N];
void add(int x, int y) {
  e[num].ed = y;
  e[num].nxt = head[x];
  head[x] = num++;
}
void dfs(int u) {
  instack[u] = 1;
  dfn[u] = low[u] = ++dep;
  st[top++] = u;
  for (int i = head[u]; ~i; i = e[i].nxt) {
    int v = e[i].ed;
    if (!instack[v]) {
      dfs(v);
      low[u] = min(low[u], low[v]);
    } else if (instack[v] == 1)
      low[u] = min(low[u], dfn[v]);
  }
  if (low[u] == dfn[u]) {
    ++cnt;
    while (st[top - 1] != u) {
      f[st[top - 1]] = cnt;
      instack[st[top - 1]] = 2;
      top--;
    }
    f[st[top - 1]] = cnt;
    instack[st[top - 1]] = 2;
    top--;
  }
}
int u[N], du[N], tmp[N];
int main() {
  int n, m, h, c1, c2;
  scanf("%d%d%d", &n, &m, &h);
  memset(head, -1, sizeof(head));
  for (int i = 1; i <= n; i++) scanf("%d", &u[i]);
  for (int i = 1; i <= m; i++) {
    scanf("%d%d", &c1, &c2);
    if ((u[c1] + 1) % h == u[c2]) add(c1, c2);
    if ((u[c2] + 1) % h == u[c1]) add(c2, c1);
  }
  for (int i = 1; i <= n; i++) {
    if (!instack[i]) dfs(i);
  }
  for (int i = 1; i <= n; i++) {
    tmp[f[i]]++;
    for (int j = head[i]; ~j; j = e[j].nxt) {
      int xx = e[j].ed;
      if (f[xx] != f[i]) {
        du[f[i]]++;
      }
    }
  }
  int ans = n + 1, res;
  for (int i = 1; i <= n; i++) {
    if (!du[f[i]]) {
      if (tmp[f[i]] < ans) {
        ans = tmp[f[i]];
        res = f[i];
      }
    }
  }
  printf("%d\n", ans);
  for (int i = 1; i <= n; i++) {
    if (f[i] == res) printf("%d ", i);
  }
  return 0;
}
