#include <bits/stdc++.h>
using namespace std;
template <class TCost>
class Graph {
 public:
  struct Edge {
    long from, to;
    TCost cost;
    Edge(long _from, long _to, TCost _cost)
        : from(_from), to(_to), cost(_cost){};
  };
  long size;
  bool zeroIndexed;
  vector<Edge> edges;
  vector<vector<pair<long, TCost>>> adjacencyList;
  Graph(){};
  Graph(long _size, bool _zeroIndexed = true) {
    zeroIndexed = _zeroIndexed;
    if (!zeroIndexed) _size++;
    size = _size;
    adjacencyList.resize(_size);
  };
  ~Graph() = default;
};
template <class TCost>
class DirectedGraph : public Graph<TCost> {
 public:
  DirectedGraph(){};
  DirectedGraph(long _size, bool _zeroIndexed)
      : Graph<TCost>(_size, _zeroIndexed){};
  DirectedGraph(long _size) : Graph<TCost>(_size){};
  void addEdge(long from, long to, TCost cost = 0) {
    this->edges.push_back({from, to, cost});
    this->adjacencyList[from].push_back({to, cost});
  }
  void printEdges() {
    for (auto edge : this->edges) {
      cout << edge.from << ' ' << edge.to << endl;
    }
  }
};
template <class TCost>
class SCC {
 public:
  static void TarjanRecursion(long v, long &indexCount, vector<long> &index,
                              vector<long> &low, stack<long> &S,
                              DirectedGraph<TCost> &graph,
                              vector<bool> &onStack,
                              vector<vector<long>> &components) {
    index[v] = indexCount;
    low[v] = indexCount;
    indexCount++;
    S.push(v);
    onStack[v] = true;
    for (auto edge : graph.adjacencyList[v]) {
      long w = edge.first;
      if (!index[w]) {
        TarjanRecursion(w, indexCount, index, low, S, graph, onStack,
                        components);
        low[v] = min(low[v], low[w]);
      } else if (onStack[w]) {
        low[v] = min(low[v], index[w]);
      }
    }
    if (low[v] == index[v]) {
      vector<long> component;
      long w;
      do {
        w = S.top();
        S.pop();
        onStack[w] = false;
        component.push_back(w);
      } while (w != v);
      components.push_back(component);
    }
  }
  static vector<vector<long>> Tarjan(DirectedGraph<TCost> graph) {
    long indexCount = 1;
    vector<long> index(graph.size), low(graph.size);
    vector<bool> onStack(graph.size);
    stack<long> S;
    vector<vector<long>> components;
    for (long i = (graph.zeroIndexed ? 0 : 1); i < graph.size; i++) {
      if (!index[i]) {
        TarjanRecursion(i, indexCount, index, low, S, graph, onStack,
                        components);
      }
    }
    return components;
  }
};
long long n, m, h, u[100001], out[100001], sccnr[1000001], discard[100001];
int main() {
  ios_base::sync_with_stdio(false);
  cout.precision(30);
  cout.tie(0);
  cin.tie(0);
  cin >> n >> m >> h;
  for (__typeof(n + 1) i = (1) - ((1) > (n + 1));
       i != (n + 1) - ((1) > (n + 1)); i += 1 - 2 * ((1) > (n + 1)))
    cin >> u[i];
  DirectedGraph<long long> g(n, false);
  for (__typeof(m) i = (0) - ((0) > (m)); i != (m) - ((0) > (m));
       i += 1 - 2 * ((0) > (m))) {
    long long c1, c2;
    cin >> c1 >> c2;
    if ((u[c1] + 1) % h == u[c2]) g.addEdge(c1, c2), out[c1]++;
    if ((u[c2] + 1) % h == u[c1]) g.addEdge(c2, c1), out[c2]++;
  }
  vector<vector<long>> rs = SCC<long long>::Tarjan(g);
  for (__typeof(rs.size()) i = (0) - ((0) > (rs.size()));
       i != (rs.size()) - ((0) > (rs.size()));
       i += 1 - 2 * ((0) > (rs.size()))) {
    for (auto x : rs[i]) {
      sccnr[x] = i;
    }
  }
  for (auto edge : g.edges) {
    if (sccnr[edge.from] != sccnr[edge.to]) {
      discard[sccnr[edge.from]] = 1;
    }
  }
  long long best = INT32_MAX;
  for (__typeof(rs.size()) i = (0) - ((0) > (rs.size()));
       i != (rs.size()) - ((0) > (rs.size())); i += 1 - 2 * ((0) > (rs.size())))
    if (!discard[i] && rs[i].size() < best) best = (long long)rs[i].size();
  cout << best << endl;
  for (auto x : rs) {
    if (x.size() == best) {
      for (auto y : x) cout << y << ' ';
      return 0;
    }
  }
  return 0;
}
