#include <bits/stdc++.h>
using namespace std;
int read() {
  int data = 0, w = 1;
  char ch = 0;
  while (ch != '-' && (ch < '0' || ch > '9')) ch = getchar();
  if (ch == '-') {
    w = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    data = (data << 3) + (data << 1) + ch - '0';
    ch = getchar();
  }
  data *= w;
  return data;
}
void write(int x) {
  if (x < 0) {
    putchar('-');
    x = -x;
  }
  if (x > 9) write(x / 10);
  putchar(x % 10 + '0');
}
void wrs(int x) {
  write(x);
  putchar(' ');
}
int bb[1000005][4], h[1000005], scc, belong[100005], cnt, r, n, m, sz[1000005],
    dfn[1000005], vis[1000005], ans = 0x3f3f3f3f, low[1000005], top,
                                stk[1000005], mo, kk, a[1000005];
void add(int x, int y) {
  bb[++r][0] = y;
  bb[r][1] = h[x];
  bb[r][2] = x;
  h[x] = r;
}
void dfs(int k) {
  dfn[k] = low[k] = ++cnt;
  stk[++top] = k;
  for (int i = h[k]; i; i = bb[i][1])
    if (!dfn[bb[i][0]]) {
      dfs(bb[i][0]);
      low[k] = min(low[bb[i][0]], low[k]);
    } else if (!belong[bb[i][0]])
      low[k] = min(low[bb[i][0]], low[k]);
  if (low[k] == dfn[k]) {
    scc++;
    while (stk[top + 1] != k) {
      belong[stk[top--]] = scc;
      sz[scc]++;
    }
  }
}
int main() {
  n = read();
  m = read();
  mo = read();
  for (int i = 1; i <= n; a[i++] = read())
    ;
  for (int i = 0; i < m; i++) {
    int x = read(), y = read();
    if ((a[x] + 1) % mo == a[y]) add(x, y);
    if ((a[y] + 1) % mo == a[x]) add(y, x);
  }
  for (int i = 1; i <= n; i++)
    if (!dfn[i]) dfs(i);
  for (int i = 1; i <= m; i++)
    if (belong[bb[i][2]] != belong[bb[i][0]]) vis[belong[bb[i][2]]] = 1;
  for (int i = 1; i <= scc; i++)
    if (!vis[i] && sz[i] < ans) {
      kk = i;
      ans = sz[i];
    }
  write(ans);
  putchar('\n');
  for (int i = 1; i <= n; i++)
    if (belong[i] == kk) wrs(i);
  return 0;
}
