#include <bits/stdc++.h>
using namespace std;
const int INF = 2e9;
const int N = 1e5 + 11;
bitset<N> u;
int n, m, h, tin[N], tout[N], timer = 0, col[N];
vector<int> hs(N);
vector<vector<int>> g(N), or_g(N), rev_or_g(N), comps(N), mg(N);
void dfs(const int &v) {
  u[v] = 1;
  tin[v] = timer++;
  for (int to : or_g[v]) {
    if (!u[to]) {
      dfs(to);
    }
  }
  tout[v] = timer++;
}
int ccol = 0;
void color(const int &v) {
  u[v] = 1;
  col[v] = ccol;
  comps[ccol].push_back(v);
  for (int to : rev_or_g[v]) {
    if (!u[to]) {
      color(to);
    }
  }
}
inline bool cmp(const int &v, const int &u) { return tout[v] > tout[u]; }
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  cin >> n >> m >> h;
  vector<int> order(n);
  for (int i = 0; i < n; ++i) {
    cin >> hs[i];
    order[i] = i;
  }
  for (int i = 0; i < m; ++i) {
    int v, u;
    cin >> v >> u;
    v--;
    u--;
    g[v].push_back(u);
    g[u].push_back(v);
  }
  for (int i = 0; i < n; ++i) {
    if (!u[i]) {
      queue<int> q;
      q.push(i);
      u[i] = 1;
      while (!q.empty()) {
        int v = q.front();
        q.pop();
        for (int to : g[v]) {
          if ((hs[v] + 1) % h == hs[to]) {
            if (!u[to]) {
              u[to] = 1;
              q.push(to);
            }
            or_g[v].push_back(to);
            rev_or_g[to].push_back(v);
          }
        }
      }
    }
  }
  u.reset();
  for (int i = 0; i < n; ++i) {
    if (!u[i]) {
      dfs(i);
    }
  }
  u.reset();
  sort(order.begin(), order.end(), cmp);
  for (int v : order) {
    if (!u[v]) {
      color(v);
      ccol++;
    }
  }
  for (int i = 0; i < ccol; ++i) {
    for (int v : comps[i]) {
      for (int j : or_g[v]) {
        if (col[v] != col[j]) {
          mg[i].push_back(col[j]);
        }
      }
    }
  }
  int min_sz = INF, ind = -1;
  for (int i = 0; i < ccol; ++i) {
    if (mg[i].size() == 0) {
      if (min_sz > comps[i].size()) {
        ind = i;
        min_sz = comps[i].size();
      }
    }
  }
  cout << min_sz << "\n";
  for (int i : comps[ind]) {
    cout << i + 1 << " ";
  }
  return 0;
}
