#include <bits/stdc++.h>
using namespace std;
const long long inf = 1E9;
std::vector<long long> g[100005], gg[100005];
long long N, M;
long long vis[100005];
std::stack<long long> order;
std::vector<long long> components;
void dfs1(long long at) {
  if (vis[at]) return;
  vis[at] = 1;
  for (auto it : g[at])
    if (vis[it] == 0) dfs1(it);
  order.push(at);
}
long long dfs2(long long root, long long at) {
  if (vis[at] == root) return 0;
  if (vis[at] != -1) return inf;
  vis[at] = root;
  long long ret = 1;
  for (auto it : gg[at]) {
    if (vis[it] != root) {
      ret = ret + dfs2(root, it);
    }
  }
  components.push_back(at);
  return ret;
}
int main() {
  long long h;
  cin >> N >> M >> h;
  std::vector<long long> a(N);
  for (auto &it : a) cin >> it;
  while (M--) {
    long long x, y;
    cin >> x >> y;
    x--;
    y--;
    if ((a[x] + 1) % h == a[y]) {
      g[y].push_back(x);
      gg[x].push_back(y);
    }
    if ((a[y] + 1) % h == a[x]) {
      g[x].push_back(y);
      gg[y].push_back(x);
    }
  }
  memset(vis, 0, sizeof(vis));
  for (long long i = 0; i < N; i++)
    if (vis[i] == 0) dfs1(i);
  memset(vis, -1, sizeof(vis));
  long long ans = inf;
  std::vector<long long> cc;
  while (order.empty() == false) {
    long long x = order.top();
    order.pop();
    if (vis[x] == -1) {
      components = std::vector<long long>();
      if (ans >= dfs2(x, x)) {
        cc = components;
        ans = cc.size();
      }
    }
  }
  cout << cc.size() << endl;
  ;
  for (auto it : cc) cout << it + 1 << " ";
  return 0;
}
