#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using db = double;
using pii = pair<int, int>;
const int mxn = 100006;
using ai = int[mxn];
int n, m, h;
vi e[mxn];
int u[mxn];
ai dfn, low, scc;
int cnt, scnt;
stack<int, vi> sta;
bool ins[mxn];
int tarjan(int x) {
  dfn[x] = low[x] = ++cnt;
  sta.push(x);
  ins[x] = true;
  for (auto i : e[x])
    low[x] = min(low[x], dfn[i] ? dfn[ins[i] ? i : x] : tarjan(i));
  if (low[x] == dfn[x]) {
    ++scnt;
    int t;
    do {
      t = sta.top();
      sta.pop();
      ins[t] = false;
      scc[t] = scnt;
    } while (t != x);
  }
  return low[x];
}
int deg[mxn];
vi S[mxn];
int main() {
  cin >> n >> m >> h;
  for (int i = 1; i <= n; ++i) scanf("%d", &u[i]);
  for (int i = 0; i < m; ++i) {
    int x, y;
    scanf("%d%d", &x, &y);
    if ((u[x] + 1) % h == u[y]) e[x].push_back(y);
    swap(x, y);
    if ((u[x] + 1) % h == u[y]) e[x].push_back(y);
  }
  for (int i = 1; i <= n; ++i)
    if (!dfn[i]) tarjan(i);
  for (int i = 1; i <= n; ++i) S[scc[i]].push_back(i);
  for (int i = 1; i <= n; ++i)
    for (auto j : e[i])
      if (scc[i] != scc[j]) ++deg[scc[i]];
  int t = 0;
  for (int i = 1; i <= scnt; ++i)
    if (!deg[i])
      if (!t || S[t].size() > S[i].size()) t = i;
  cout << S[t].size() << endl;
  for (auto i : S[t]) printf("%d ", i);
  puts("");
  return 0;
}
