#include <bits/stdc++.h>
using namespace std;
struct SCC {
  int V, group_cnt;
  vector<vector<int> > adj, radj;
  vector<int> group_num, vis;
  stack<int> stk;
  SCC(int V) : V(V), group_cnt(0), group_num(V), vis(V), adj(V), radj(V) {}
  void add_edge(int v1, int v2) {
    adj[v1].push_back(v2);
    radj[v2].push_back(v1);
  }
  void fill_forward(int x) {
    vis[x] = true;
    for (int i = 0; i < adj[x].size(); i++) {
      if (!vis[adj[x][i]]) {
        fill_forward(adj[x][i]);
      }
    }
    stk.push(x);
  }
  void fill_backward(int x) {
    vis[x] = false;
    group_num[x] = group_cnt;
    for (int i = 0; i < radj[x].size(); i++) {
      if (vis[radj[x][i]]) {
        fill_backward(radj[x][i]);
      }
    }
  }
  int get_scc() {
    for (int i = 0; i < V; i++) {
      if (!vis[i]) fill_forward(i);
    }
    group_cnt = 0;
    while (!stk.empty()) {
      if (vis[stk.top()]) {
        fill_backward(stk.top());
        group_cnt++;
      }
      stk.pop();
    }
    return group_cnt;
  }
};
const int max_N = 1e5 + 10;
set<int> E[max_N];
int u[max_N];
vector<int> comp[max_N];
bool outgoing[max_N];
int solve(int x);
int main() {
  do {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
  } while (0);
  int N, M, H;
  cin >> N >> M >> H;
  for (int i = 1; i <= N; ++i) {
    cin >> u[i];
  }
  for (int i = 1; i <= M; ++i) {
    int c1, c2;
    cin >> c1 >> c2;
    if ((u[c1] + 1) % H == u[c2]) {
      E[c1].insert(c2);
    }
    if ((u[c2] + 1) % H == u[c1]) {
      E[c2].insert(c1);
    }
  }
  SCC scc(N);
  for (int u = 1; u <= N; ++u) {
    for (auto& v : E[u]) {
      scc.add_edge(u - 1, v - 1);
    }
  }
  int n = scc.get_scc();
  for (int u = 1; u <= N; ++u) {
    int id = scc.group_num[u - 1];
    comp[id].push_back(u);
    ;
  }
  for (int u = 1; u <= N; ++u) {
    for (auto& v : E[u]) {
      int idu = scc.group_num[u - 1];
      int idv = scc.group_num[v - 1];
      if (idu != idv) {
        outgoing[idu] = true;
      }
    }
  }
  int best = -1;
  for (int u = 0; u < n; ++u) {
    if (!outgoing[u] && (best == -1 || comp[u].size() < comp[best].size())) {
      best = u;
    }
  }
  assert(best != -1);
  cout << comp[best].size() << endl;
  for (auto& x : comp[best]) {
    cout << x << ' ';
  }
  cout << endl;
}
