#include <bits/stdc++.h>
#pragma warning(disable : 4996)
using namespace std;
vector<vector<int>> g;
vector<vector<int>> gt;
vector<int> used1, used2, order;
void dfs1(int v) {
  used1[v] = 1;
  for (int i = 0; i < g[v].size(); i++) {
    int to = g[v][i];
    if (!used1[to]) dfs1(to);
  }
  order.push_back(v);
}
int cnt_comp = 0;
vector<int> comp;
vector<set<int>> component;
vector<vector<int>> comp_g;
void dfs2(int v) {
  comp[v] = cnt_comp;
  used2[v] = true;
  component[cnt_comp].insert(v);
  for (int i = 0; i < gt[v].size(); i++) {
    int to = gt[v][i];
    if (!used2[to]) dfs2(to);
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(0);
  ;
  int n, m, h;
  cin >> n >> m >> h;
  vector<int> vertex(n);
  for (int i = 0; i < n; i++) cin >> vertex[i];
  g.resize(n);
  gt.resize(n);
  used1.resize(n);
  used2.resize(n);
  comp.resize(n);
  for (int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    if ((vertex[a] + 1) % h == vertex[b]) {
      g[a].push_back(b);
      gt[b].push_back(a);
    }
    if ((vertex[b] + 1) % h == vertex[a]) {
      g[b].push_back(a);
      gt[a].push_back(b);
    }
  }
  for (int i = 0; i < n; i++)
    if (!used1[i]) dfs1(i);
  reverse(order.begin(), order.end());
  for (int i = 0; i < order.size(); i++)
    if (!used2[order[i]]) {
      component.push_back({});
      dfs2(order[i]);
      cnt_comp++;
    }
  comp_g.resize(cnt_comp);
  for (int i = 0; i < n; i++)
    for (int j = 0; j < g[i].size(); j++) {
      int to = g[i][j];
      if (comp[i] != comp[to]) comp_g[comp[i]].push_back(comp[to]);
    }
  int ans = -1;
  for (int i = 0; i < cnt_comp; i++)
    if (comp_g[i].size() == 0 &&
        (ans == -1 || component[ans].size() > component[i].size()))
      ans = i;
  cout << component[ans].size() << '\n';
  for (int x : component[ans]) cout << x + 1 << ' ';
  return 0;
}
