#include <bits/stdc++.h>
using namespace std;
const int MAXN = (int)(2e5) + 2;
const int MOD = (int)(1e9) + 7;
vector<int> g[MAXN], gr[MAXN], cg[MAXN], hg[MAXN], ord;
bool used[MAXN];
int n, m, h, a[MAXN], k;
void dfs(int v) {
  used[v] = 1;
  for (int i = 0; i < g[v].size(); i++) {
    int to = g[v][i];
    if (!used[to]) dfs(to);
  }
  ord.push_back(v);
}
int col[MAXN];
vector<int> vec[MAXN];
void dfs1(int v) {
  used[v] = 1;
  col[v] = k;
  vec[k].push_back(v);
  for (int i = 0; i < gr[v].size(); i++) {
    int to = gr[v][i];
    if (!used[to]) dfs1(to);
  }
}
map<pair<int, int>, bool> e;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cin >> n >> m >> h;
  for (int i = 1; i <= n; i++) cin >> a[i];
  for (int i = 1; i <= m; i++) {
    int u, v;
    cin >> u >> v;
    if (e[make_pair(u, v)]) continue;
    e[make_pair(u, v)] = e[make_pair(v, u)] = 1;
    hg[v].push_back(u);
    hg[u].push_back(v);
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 0; j < hg[i].size(); j++) {
      if (a[i] + 1 == a[hg[i][j]] || (a[i] == h - 1 && a[hg[i][j]] == 0)) {
        g[i].push_back(hg[i][j]);
        gr[hg[i][j]].push_back(i);
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    if (!used[i]) {
      dfs(i);
    }
  }
  memset(used, 0, sizeof used);
  for (int i = ord.size() - 1; i >= 0; i--) {
    int v = ord[i];
    if (!used[v]) {
      k++;
      dfs1(v);
    }
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 0; j < g[i].size(); j++) {
      if (col[i] != col[g[i][j]]) cg[col[i]].push_back(col[g[i][j]]);
    }
  }
  int mn = MOD;
  int id = -1;
  for (int i = 1; i <= k; i++) {
    if (cg[i].empty()) {
      if (mn > vec[i].size()) {
        mn = vec[i].size();
        id = i;
      }
    }
  }
  cout << vec[id].size() << endl;
  for (int i = 0; i < vec[id].size(); i++) cout << vec[id][i] << " ";
  return 0;
}
