#include <bits/stdc++.h>
#pragma GCC optimize("O3")
using namespace std;
const int N = 200005;
stack<int> sta;
vector<int> s[N], g[N], scc[N];
int dfs_cnt = 0, pre[N] = {0}, sccno[N] = {0}, scc_cnt = 0, is[N] = {0},
    add[N] = {0};
int dfs(int u) {
  int lowu, lowv, i;
  lowu = pre[u] = ++dfs_cnt;
  sta.push(u);
  for (i = 0; i < s[u].size(); i++) {
    int v = s[u][i];
    if (pre[v] == 0) {
      lowv = dfs(v);
      lowu = min(lowu, lowv);
    } else if (pre[v] < pre[u] && sccno[v] == 0) {
      lowu = min(lowu, pre[v]);
    }
  }
  if (lowu == pre[u]) {
    ++scc_cnt;
    while (sta.size()) {
      int first = sta.top();
      sta.pop();
      sccno[first] = scc_cnt;
      scc[scc_cnt].push_back(first);
      if (first == u) break;
    }
  }
  return lowu;
}
int val[N];
int main() {
  int n, m, h;
  cin >> n >> m >> h;
  for (int i = 1; i <= n; i++) {
    scanf("%d", &val[i]);
  }
  for (int i = 0; i < m; i++) {
    int first, second;
    scanf("%d%d", &first, &second);
    if ((val[first] + 1) % h == val[second]) s[first].push_back(second);
    if ((val[second] + 1) % h == val[first]) s[second].push_back(first);
  }
  for (int i = 1; i <= n; i++) {
    if (pre[i] == 0) {
      dfs(i);
    }
  }
  int ans = -1, id;
  for (int i = 1; i <= scc_cnt; i++) {
    int flag = 1;
    for (auto second : scc[i]) {
      for (auto first : s[second]) {
        if (sccno[first] != i) flag = 0;
      }
    }
    if (flag) {
      if (ans == -1 || (int)scc[i].size() < ans) ans = scc[i].size(), id = i;
    }
  }
  printf("%d\n", ans);
  sort(scc[id].begin(), scc[id].end());
  for (auto first : scc[id]) printf("%d ", first);
}
