#include <bits/stdc++.h>
using namespace std;
long long curr_comp = 0;
void toposort(long long idx, vector<vector<long long>> &adj,
              vector<char> &visited, vector<long long> &st) {
  visited[idx] = 1;
  for (auto i : adj[idx]) {
    if (!visited[i]) toposort(i, adj, visited, st);
  }
  st.push_back(idx);
}
void sec_pass(long long idx, vector<vector<long long>> &adj,
              vector<char> &visited, vector<long long> &comps,
              vector<long long> &curr) {
  visited[idx] = 1;
  comps[idx] = curr_comp;
  curr.push_back(idx);
  for (auto i : adj[idx]) {
    if (!visited[i]) {
      sec_pass(i, adj, visited, comps, curr);
    }
  }
}
long long res = INT_MAX;
vector<long long> ans;
void scc(vector<vector<long long>> &adj, vector<long long> &comps) {
  long long n = comps.size();
  vector<long long> st;
  vector<char> visited(n, 0);
  for (long long i = 0; i < n; i++) {
    if (!visited[i]) {
      toposort(i, adj, visited, st);
    }
  }
  reverse((st).begin(), (st).end());
  vector<vector<long long>> cadj(n);
  for (long long i = 0; i < n; i++) {
    for (auto j : adj[i]) cadj[j].push_back(i);
  }
  visited = vector<char>(n, 0);
  for (auto i : st) {
    if (!visited[i]) {
      vector<long long> curr;
      sec_pass(i, cadj, visited, comps, curr);
      curr_comp++;
      bool f = 0;
      for (auto v : curr) {
        for (auto j : cadj[v]) {
          if (comps[j] != comps[v]) {
            f = 1;
            break;
          }
        }
        if (f) break;
      }
      if (!f && curr.size() < res) {
        res = curr.size();
        ans = curr;
      }
    }
  }
}
int main() {
  long long(n), (m), (h);
  scanf("%lld%lld%lld", &(n), &(m), &(h));
  ;
  vector<long long> hrs((n));
  for (long long i = 0; i < n; i++) scanf("%lld", &hrs[i]);
  ;
  vector<vector<long long>> adj(n);
  for (long long i = 0; i < (m); i++) {
    long long(a), (b);
    scanf("%lld%lld", &(a), &(b));
    ;
    --a;
    --b;
    if ((hrs[a] + 1) % h == hrs[b]) {
      adj[b].push_back(a);
    }
    if ((hrs[b] + 1) % h == hrs[a]) {
      adj[a].push_back(b);
    }
  }
  vector<long long> comps(n, -1);
  scc(adj, comps);
  printf("%lld\n", res);
  for (auto i : ans) printf("%lld ", i + 1);
  printf("\n");
  return 0;
}
