#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9 + 7;
const long long MAXN = 1e6 + 5;
const long long INF = 1e6 + 5;
const double PI = 3.14159265359;
bool u[MAXN], Del[MAXN];
int n, m, cnt, mn = INF, h, col[MAXN], a[MAXN];
vector<int> tp;
vector<vector<int> > g(MAXN), gr(MAXN), comp(MAXN);
void dfs(int v) {
  u[v] = true;
  for (auto to : g[v])
    if (!u[to]) dfs(to);
  tp.push_back(v);
}
void dfs2(int v) {
  col[v] = cnt;
  comp[cnt].push_back(v);
  for (auto to : gr[v]) {
    if (col[to] != cnt) {
      Del[col[to]] = true;
    }
    if (!col[to]) dfs2(to);
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  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 ((a[u] - a[v] + h) % h == 1) g[v].push_back(u), gr[u].push_back(v);
    if ((a[v] - a[u] + h) % h == 1) g[u].push_back(v), gr[v].push_back(u);
  }
  for (int i = 1; i <= n; ++i)
    if (!u[i]) dfs(i);
  for (int i = 1; i <= n; ++i) {
    if (!col[tp[n - i]]) {
      ++cnt;
      dfs2(tp[n - i]);
    }
  }
  for (int i = 1; i <= cnt; ++i)
    if (!Del[i]) mn = min(mn, (int)comp[i].size());
  cout << mn << "\n";
  for (int i = 1; i <= cnt; ++i) {
    if (comp[i].size() == mn && !Del[i]) {
      for (auto it : comp[i]) {
        cout << it << " ";
      }
      return 0;
    }
  }
}
