#include <bits/stdc++.h>
using namespace std;
const int N = (int)1e5 + 100;
const int INF = (int)1e9;
int h[N], sz[N], sn[N], ok[N], st[N], used[N];
vector<int> g[N], gr[N];
int scnt;
int cnt = 0;
void dfs1(int v) {
  if (used[v]) return;
  used[v] = true;
  for (size_t i = 0; i < g[v].size(); ++i) dfs1(g[v][i]);
  st[++cnt] = v;
}
void dfs2(int v) {
  if (sn[v]) {
    if (sn[v] != scnt) ok[sn[v]] = 1;
    return;
  }
  sn[v] = scnt;
  sz[scnt]++;
  for (size_t i = 0; i < gr[v].size(); ++i) dfs2(gr[v][i]);
}
int n, m, u, v, to, k;
int main() {
  cin >> n >> m >> k;
  for (int i = 1; i <= n; i++) cin >> h[i];
  for (int i = 1; i <= m; i++) {
    cin >> u >> v;
    if ((h[v] - h[u] + k) % k == 1) {
      g[u].push_back(v);
      gr[v].push_back(u);
    }
    if ((h[u] - h[v] + k) % k == 1) {
      g[v].push_back(u);
      gr[u].push_back(v);
    }
  }
  for (int i = 1; i <= n; ++i) dfs1(i);
  for (int i = n; i >= 1; --i) {
    if (!sn[st[i]]) {
      scnt++;
      dfs2(st[i]);
    }
  }
  int res = INF;
  int vv = 0;
  sz[0] = n + 1;
  for (int i = 1; i <= scnt; i++) {
    if (!ok[i] && res > sz[i]) res = sz[i], vv = i;
  }
  cout << res << endl;
  for (int i = 1; i <= n; i++)
    if (vv == sn[i]) cout << i << " ";
  return 0;
}
