#include <bits/stdc++.h>
using namespace std;
void dfs1(vector<vector<int64_t>>& g, vector<bool>& used,
          vector<int64_t>& topsort, int64_t v) {
  used[v] = true;
  for (int64_t i = 0; i < g[v].size(); ++i) {
    if (!used[g[v][i]]) {
      dfs1(g, used, topsort, g[v][i]);
    }
  }
  topsort.push_back(v);
}
void dfs2(vector<vector<int64_t>>& g, vector<int64_t>& component, int64_t v,
          int64_t k) {
  component[v] = k;
  for (int64_t i = 0; i < g[v].size(); ++i) {
    if (component[g[v][i]] == 0) {
      dfs2(g, component, g[v][i], k);
    }
  }
}
int main() {
  int64_t n, m, h;
  cin >> n >> m >> h;
  vector<int64_t> color(n);
  vector<vector<int64_t>> g(n);
  vector<vector<int64_t>> gr(n);
  for (int64_t i = 0; i < n; ++i) {
    cin >> color[i];
  }
  vector<pair<int64_t, int64_t>> edge;
  for (int64_t i = 0; i < m; ++i) {
    int64_t v, u;
    cin >> v >> u;
    --v;
    --u;
    if ((color[v] + 1) % h == color[u]) {
      g[v].push_back(u);
      gr[u].push_back(v);
      edge.push_back(make_pair(v, u));
    }
    if ((color[u] + 1) % h == color[v]) {
      g[u].push_back(v);
      gr[v].push_back(u);
      edge.push_back(make_pair(u, v));
    }
  }
  vector<int64_t> topsort;
  vector<bool> used(n);
  for (int64_t i = 0; i < n; ++i) {
    if (!used[i]) {
      dfs1(g, used, topsort, i);
    }
  }
  vector<int64_t> component(n);
  int64_t k = 1;
  for (int64_t i = n - 1; i >= 0; --i) {
    if (component[topsort[i]] == 0) {
      dfs2(gr, component, topsort[i], k);
      ++k;
    }
  }
  vector<int64_t> cnt(k + 1);
  vector<bool> isStok(k + 1, true);
  for (int64_t i = 0; i < n; ++i) {
    ++cnt[component[i]];
  }
  for (int64_t i = 0; i < edge.size(); ++i) {
    if (component[edge[i].first] != component[edge[i].second]) {
      isStok[component[edge[i].first]] = false;
    }
  }
  int64_t mn = 1e9;
  for (int64_t i = 1; i < k; ++i) {
    if (isStok[i] && cnt[i] < mn) {
      mn = cnt[i];
    }
  }
  for (int64_t i = 1; i < k; ++i) {
    if (isStok[i] && cnt[i] == mn) {
      cout << mn << endl;
      for (int j = 0; j < n; ++j) {
        if (component[j] == i) {
          cout << j + 1 << " ";
        }
      }
      return 0;
    }
  }
  return 0;
}
