#include <bits/stdc++.h>
using namespace std;
const int N = 100000 + 5;
class SCC {
 private:
  int n, cnt;
  vector<vector<int>> G, rG;
  vector<int> ord, id;
  vector<bool> vis;
  void dfs(int u) {
    vis[u] = true;
    for (int v : G[u])
      if (!vis[v]) {
        dfs(v);
      }
    ord.push_back(u);
  }
  void rdfs(int u) {
    vis[u] = true;
    id[u] = cnt;
    for (int v : rG[u])
      if (!vis[v]) {
        rdfs(v);
      }
  }

 public:
  void init(int n_) {
    n = n_;
    id.resize(n);
    G.resize(n, vector<int>());
    rG.resize(n, vector<int>());
  }
  void add_edge(int s, int t) {
    G[s].push_back(t);
    rG[t].push_back(s);
  }
  void solve() {
    ord.clear();
    vis.resize(n, false);
    for (int i = 0; i < n; i++)
      if (!vis[i]) {
        dfs(i);
      }
    reverse(ord.begin(), ord.end());
    fill(vis.begin(), vis.end(), false);
    cnt = 0;
    for (int i : ord)
      if (!vis[i]) {
        rdfs(i);
        cnt++;
      }
  }
  int get_id(int x) { return id[x]; }
  int count() { return cnt; }
} scc;
int arr[N];
vector<pair<int, int>> egs;
vector<int> in;
vector<set<int>> eve;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n, m, h;
  cin >> n >> m >> h;
  for (int i = 0; i < n; i++) cin >> arr[i];
  scc.init(n);
  for (int i = 0; i < m; i++) {
    int u, v;
    cin >> u >> v;
    u--, v--;
    if ((arr[u] + 1) % h == arr[v]) {
      scc.add_edge(v, u);
      egs.emplace_back(v, u);
    }
    if ((arr[v] + 1) % h == arr[u]) {
      scc.add_edge(u, v);
      egs.emplace_back(u, v);
    }
  }
  scc.solve();
  in.resize(scc.count());
  for (auto e : egs) {
    int s, t;
    tie(s, t) = e;
    int u = scc.get_id(s), v = scc.get_id(t);
    if (u == v) continue;
    in[v] += 1;
  }
  eve.resize(scc.count());
  for (int i = 0; i < n; i++) eve[scc.get_id(i)].insert(i);
  int wh = -1;
  for (int i = 0; i < scc.count(); i++)
    if (in[i] == 0) {
      if (wh == -1 or eve[i].size() < eve[wh].size()) wh = i;
    }
  if (wh == -1) wh = 0;
  cout << eve[wh].size() << '\n';
  for (auto x : eve[wh]) cout << x + 1 << " ";
  return 0;
}
