#include <bits/stdc++.h>
using namespace std;
const int N = 100100;
int n, m, h, st[N], sz[N], vis[N], cnt, scnt, vd[N], sn[N], a[N];
vector<int> vec[N], vec2[N];
void dfs1(int x) {
  if (vis[x]) return;
  vis[x] = 1;
  for (int i = 0; i < vec[x].size(); i++) dfs1(vec[x][i]);
  st[++cnt] = x;
}
void dfs2(int x) {
  if (sn[x]) {
    if (sn[x] != scnt) vd[sn[x]] = 1;
    return;
  }
  sn[x] = scnt;
  sz[scnt]++;
  for (int i = 0; i < vec2[x].size(); i++) dfs2(vec2[x][i]);
}
int main() {
  scanf("%d%d%d", &n, &m, &h);
  for (int i = 1; i <= n; i++) scanf("%d", a + i);
  for (int i = 1; i <= m; i++) {
    int u, v;
    scanf("%d%d", &u, &v);
    if ((a[u] - a[v] + h) % h == 1) vec[v].push_back(u), vec2[u].push_back(v);
    if ((a[v] - a[u] + h) % h == 1) vec[u].push_back(v), vec2[v].push_back(u);
  }
  for (int i = 1; i <= n; i++) dfs1(i);
  for (int i = n; i; i--)
    if (!sn[st[i]]) {
      scnt++;
      dfs2(st[i]);
    }
  int ans = 0;
  sz[0] = n + 1;
  for (int i = 1; i <= scnt; i++)
    if (!vd[i] && sz[i] < sz[ans]) ans = i;
  printf("%d\n", sz[ans]);
  for (int i = 1; i <= n; i++)
    if (sn[i] == ans) printf("%d ", i);
  return 0;
}
