#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int counter, sccCounter;
vector<bool> visited, inStack;
vector<vector<int>> adjlist;
vector<int> d, low, sccs;
stack<int> s;
void visit(int v) {
  visited[v] = true;
  d[v] = low[v] = counter++;
  s.push(v);
  inStack[v] = true;
  for (auto u : adjlist[v]) {
    if (!visited[u]) {
      visit(u);
      low[v] = min(low[v], low[u]);
    } else if (inStack[u]) {
      low[v] = min(low[v], low[u]);
    }
  }
  if (d[v] == low[v]) {
    int u;
    do {
      u = s.top();
      s.pop();
      inStack[u] = false;
      sccs[u] = sccCounter;
    } while (u != v);
    sccCounter++;
  }
}
void scc() {
  visited.assign(adjlist.size(), false);
  d.assign(adjlist.size(), -1);
  low.assign(adjlist.size(), -1);
  inStack.assign(adjlist.size(), false);
  sccs.resize(adjlist.size(), -1);
  counter = sccCounter = 0;
  for (int i = 0; i < (int)adjlist.size(); i++) {
    if (!visited[i]) {
      visit(i);
    }
  }
}
int u[100007];
bool sccNotOkay[100007];
int sccSize[100007];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  int n, m, h;
  cin >> n >> m >> h;
  adjlist.resize(n);
  for (int i = 0; i < n; i++) cin >> u[i];
  for (int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    --a;
    --b;
    if ((u[a] + 1) % h == u[b]) adjlist[a].push_back(b);
    if ((u[b] + 1) % h == u[a]) adjlist[b].push_back(a);
  }
  scc();
  for (int i = 0; i < n; i++) {
    ++sccSize[sccs[i]];
    for (const auto &next : adjlist[i]) {
      if (sccs[i] != sccs[next]) sccNotOkay[sccs[i]] = true;
    }
  }
  int res = 10000000;
  int minScc = -1;
  for (int i = 0; i < sccCounter; i++) {
    if (sccNotOkay[i]) continue;
    if (sccSize[i] < res) {
      res = sccSize[i];
      minScc = i;
    }
  }
  cout << res << endl;
  for (int i = 0; i < n; i++) {
    if (sccs[i] == minScc) {
      cout << (i + 1) << " ";
    }
  }
  cout << endl;
}
