#include <bits/stdc++.h>
using namespace std;
int n, m, h, counter = 0;
vector<int> U, num, dfs_num, dfs_low, vis1, vis2;
vector<vector<int> > adj, adj2, scc;
stack<int> st;
void tarjanSCC(int v) {
  dfs_num[v] = dfs_low[v] = counter++;
  st.push(v);
  vis1[v] = vis2[v] = 1;
  for (int i = 0; i < adj[v].size(); ++i) {
    if (dfs_num[adj[v][i]] == -1) tarjanSCC(adj[v][i]);
    if (vis1[adj[v][i]]) dfs_low[v] = min(dfs_low[v], dfs_low[adj[v][i]]);
  }
  if (dfs_low[v] == dfs_num[v]) {
    vector<int> aux;
    while (true) {
      int v2 = st.top();
      st.pop();
      aux.push_back(v2);
      vis1[v2] = 0;
      if (v == v2) break;
    }
    scc.push_back(aux);
  }
}
void solve() {
  dfs_num = dfs_low = vector<int>(n, -1);
  vis1 = vis2 = vector<int>(n);
  for (int i = 0; i < n; ++i) {
    if (!vis2[i]) tarjanSCC(i);
  }
  vector<int> ind(n);
  for (int i = 0; i < scc.size(); ++i) {
    for (int j = 0; j < scc[i].size(); ++j) {
      ind[scc[i][j]] = i;
    }
  }
  adj2 = vector<vector<int> >(scc.size());
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < adj[i].size(); ++j) {
      if (ind[adj[i][j]] != ind[i]) {
        adj2[ind[i]].push_back(ind[adj[i][j]]);
      }
    }
  }
}
vector<int> ANS, vis;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> m >> h;
  U = vector<int>(n);
  adj = vector<vector<int> >(n);
  for (int i = 0; i < n; ++i) cin >> U[i];
  for (int i = 0; i < m; ++i) {
    int a, b;
    cin >> a >> b;
    a--, b--;
    if ((U[a] + 1) % h == U[b]) adj[a].push_back(b);
    if ((U[b] + 1) % h == U[a]) adj[b].push_back(a);
  }
  solve();
  vis = ANS = vector<int>(adj2.size(), -1);
  int mn = 1e9;
  for (int i = 0; i < adj2.size(); ++i) {
    if (adj2[i].size() == 0) {
      mn = min(mn, (int)scc[i].size());
    }
  }
  cout << mn << "\n";
  for (int i = 0; i < adj2.size(); ++i) {
    if (adj2[i].size() == 0 && mn == scc[i].size()) {
      for (int j = 0; j < scc[i].size(); ++j) {
        cout << scc[i][j] + 1 << " ";
      }
      cout << "\n";
      break;
    }
  }
  return 0;
}
