#include <bits/stdc++.h>
int u[100010];
int next[200010];
int last[100010];
int num[200010];
int col[100010];
int dfn[100010];
int low[100010];
int stack[100010];
bool bz[100010];
int color[100010];
int ans[100010];
int chu[100010];
int tot;
int min(int x, int y) {
  if (x < y)
    return x;
  else
    return y;
}
void insert(int x, int y) {
  tot++;
  next[tot] = last[x];
  last[x] = tot;
  num[tot] = y;
}
void tarjan(int x) {
  dfn[x] = ++tot;
  low[x] = dfn[x];
  stack[++stack[0]] = x;
  bz[x] = true;
  for (int i = last[x]; i; i = next[i]) {
    if (!dfn[num[i]]) {
      tarjan(num[i]);
      low[x] = min(low[x], low[num[i]]);
    } else {
      if (bz[x]) low[x] = min(low[x], low[num[i]]);
    }
  }
  if (dfn[x] == low[x]) {
    col[0]++;
    while (stack[stack[0]] != x) {
      col[col[0]]++;
      color[stack[stack[0]]] = col[0];
      bz[stack[stack[0]--]] = false;
    }
    col[col[0]]++;
    color[stack[stack[0]]] = col[0];
    bz[stack[stack[0]--]] = false;
  }
}
int main() {
  int n, m, h;
  scanf("%d%d%d", &n, &m, &h);
  int i;
  for (i = 1; i <= n; i++) scanf("%d", &u[i]);
  int x, y;
  for (i = 1; i <= m; i++) {
    scanf("%d%d", &x, &y);
    if ((u[x] + 1) % h == u[y]) insert(x, y);
    if ((u[y] + 1) % h == u[x]) insert(y, x);
  }
  tot = 0;
  for (i = 1; i <= n; i++)
    if (!dfn[i]) tarjan(i);
  for (i = 1; i <= n; i++)
    for (int j = last[i]; j; j = next[j])
      if (color[i] != color[num[j]]) chu[color[i]]++;
  int ma = 100010;
  int p = 0;
  for (i = 1; i <= col[0]; i++)
    if (col[i] < ma && chu[i] == 0) ma = col[i], p = i;
  int k = 0;
  for (i = 1; i <= n; i++)
    if (color[i] == p) ans[++k] = i;
  printf("%d\n", k);
  for (i = 1; i <= k; i++) printf("%d ", ans[i]);
  return 0;
}
