#include <bits/stdc++.h>
using namespace std;
vector<vector<int> > vv, ans, graf;
vector<int> c, used, sorted, colored, tru;
void top_sort(int v) {
  used[v] = true;
  for (int i = 0; i < vv[v].size(); i++)
    if (!used[vv[v][i]]) top_sort(vv[v][i]);
  sorted.push_back(v);
}
void color(int v, int col, vector<int> &cur) {
  if (colored[v] != -1) {
    if (colored[v] != col) tru[colored[v]] = 1;
    return;
  }
  cur.push_back(v);
  colored[v] = col;
  for (int i = 0; i < graf[v].size(); i++) {
    int to = graf[v][i];
    color(to, col, cur);
  }
}
int main() {
  int n, m, h;
  cin >> n >> m >> h;
  vv.resize(n + 1);
  c.resize(n + 1);
  used.resize(n + 1);
  colored.resize(n + 1, -1);
  graf.resize(n + 1);
  tru.resize(n + 1);
  for (int i = 1; i <= n; i++) cin >> c[i];
  for (int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    if (c[a] == (c[b] + 1) % h) vv[b].push_back(a), graf[a].push_back(b);
    if (c[b] == (c[a] + 1) % h) vv[a].push_back(b), graf[b].push_back(a);
  }
  for (int i = 1; i <= n; i++)
    if (!used[i]) top_sort(i);
  int col = -1;
  for (int i = n - 1; i >= 0; i--) {
    int v = sorted[i];
    if (colored[v] == -1) {
      vector<int> cur_ans;
      col++;
      color(v, col, cur_ans);
      ans.push_back(cur_ans);
    }
  }
  int mn(1e6);
  vector<int> otv;
  for (int i = 0; i <= col; i++)
    if (ans[i].size() < mn && !tru[i]) {
      mn = ans[i].size();
      otv = ans[i];
    }
  cout << mn << "\n";
  for (int i = 0; i < mn; i++) cout << otv[i] << ' ';
}
