#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
const long long int inf = 2e18;
const long double eps = 1e-9;
const int NN = 1e5 + 2;
vector<vector<int> > adj;
int u[NN];
int curr[NN];
bool vis[NN];
vector<vector<int> > scc;
stack<int> STACK;
void DFS(int source, bool second_DFS) {
  vis[source] = true;
  if (second_DFS) scc[scc.size() - 1].push_back(source);
  for (auto v : adj[source])
    if (!vis[v]) DFS(v, second_DFS);
  if (!second_DFS) STACK.push(source);
}
void solve() {
  int i = 0, j = 0, k = 0, n = 0, m = 0;
  cin >> n >> m >> k;
  ;
  for (i = 1; i < (n + 1); i++) {
    cin >> u[i];
  }
  vector<int> tmp;
  adj.assign(n + 2, tmp);
  set<pair<int, int> > taken;
  while (m--) {
    cin >> i >> j;
    if (i < j) swap(i, j);
    if (taken.find({i, j}) == taken.end()) {
      taken.insert({i, j});
      if ((u[j] + 1) % k == u[i]) {
        adj[j].push_back(i);
      }
      if ((u[i] + 1) % k == u[j]) {
        adj[i].push_back(j);
      };
    }
  }
  for (i = 1; i <= n; i++) {
    for (auto u : adj[i])
      ;
  }
  for (i = 0; i < (n); i++) {
    if (adj[i + 1].size() == 0) {
      ;
      cout << 1 << '\n';
      cout << i + 1;
      return;
    }
  }
  int min_sz = 1e9;
  vector<int> ans;
  for (i = 1; i <= n; i++) {
    if (!vis[i]) {
      DFS(i, 0);
    }
  }
  vector<vector<int> > orig = adj;
  adj.clear();
  adj.assign(n + 1, tmp);
  for (auto p : taken) {
    j = p.second;
    i = p.first;
    if ((u[j] + 1) % k == u[i]) {
      adj[i].push_back(j);
    }
    if ((u[i] + 1) % k == u[j]) {
      adj[j].push_back(i);
    }
  }
  fill(vis, vis + n + 1, 0);
  while (!STACK.empty()) {
    int source = STACK.top();
    STACK.pop();
    if (!vis[source]) {
      scc.emplace_back(tmp);
      DFS(source, 1);
    }
  }
  for (auto& vvv : scc) {
    bool out_edge = 0;
    set<int> curr_comp;
    for (auto node : vvv) {
      curr_comp.insert(node);
    }
    for (auto node : vvv) {
      for (auto x : orig[node]) {
        if (curr_comp.find(x) == curr_comp.end()) {
          out_edge = 1;
          break;
        }
      }
      if (out_edge) break;
    }
    if (!out_edge && vvv.size() < min_sz) {
      ans = vvv;
      min_sz = vvv.size();
    }
  }
  cout << min_sz << '\n';
  for (auto x : ans) {
    cout << x << ' ';
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int T = 1, tc;
  for (tc = 1; tc <= T; tc++) {
    solve();
  }
  return 0;
}
