#include <bits/stdc++.h>
using namespace std;
struct SCC {
  int n, comp;
  vector<vector<int> > g, gt;
  vector<int> seq, vis;
  void dfs(int u, const vector<vector<int> >& adj) {
    for (int v : adj[u])
      if (vis[v] == -1) {
        vis[v] = comp;
        dfs(v, adj);
      }
    seq.push_back(u);
  }
  SCC() {}
  SCC(int n) : n(n), g(n), gt(n) {}
  void add_edge(int u, int v) {
    g[u].push_back(v);
    gt[v].push_back(u);
  }
  pair<int, vector<int> > find_SCC() {
    vis.assign(n, -1);
    comp = 0;
    for (int i = 0; i < n; i++)
      if (vis[i] == -1) {
        vis[i] = comp;
        dfs(i, g);
      }
    vis.assign(n, -1);
    comp = 0;
    for (int i = n - 1; i >= 0; i--) {
      int u = seq[i];
      if (vis[u] == -1) {
        vis[u] = comp;
        dfs(u, gt);
        comp++;
      }
    }
    return {comp, vis};
  }
  vector<vector<int> > get_dag() {
    map<pair<int, int>, int> mmap;
    vector<vector<int> > dag(comp, vector<int>());
    for (int u = 0; u < n; u++)
      for (int v : g[u]) {
        if (vis[u] == vis[v]) continue;
        if (!mmap.count(pair<int, int>(vis[u], vis[v]))) {
          dag[vis[u]].push_back(vis[v]);
          mmap[pair<int, int>(vis[u], vis[v])] = 1;
        }
      }
    return dag;
  }
};
const int mod = 1000000000 + 7;
int addm(int& a, int b) { return (a += b) < mod ? a : a -= mod; }
template <class T, class U>
bool smin(T& a, U b) {
  return a > b ? (a = b, 1) : 0;
}
template <class T, class U>
bool smax(T& a, U b) {
  return a < b ? (a = b, 1) : 0;
}
int n, m, h;
SCC cc;
int u[100000];
int c[100000][2];
vector<int> outt[100000], comps[100000];
pair<int, vector<int> > scc;
bool inex(int i, int j) {
  i = u[i];
  j = u[j];
  return i + 1 == j || (i + 1 == h && j == 0);
}
bool noout(int i) {
  for (int j = 0; j < comps[i].size(); j++)
    for (int k = 0; k < outt[comps[i][j]].size(); k++)
      if (scc.second[outt[comps[i][j]][k]] != i) return 0;
  return 1;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> m >> h;
  cc = SCC(n);
  for (int i = 0; i < n; i++) cin >> u[i];
  for (int i = 0; i < m; i++) {
    cin >> c[i][0] >> c[i][1];
    c[i][0]--;
    c[i][1]--;
    if (inex(c[i][0], c[i][1])) {
      cc.add_edge(c[i][0], c[i][1]);
      outt[c[i][0]].push_back(c[i][1]);
    }
    if (inex(c[i][1], c[i][0])) {
      cc.add_edge(c[i][1], c[i][0]);
      outt[c[i][1]].push_back(c[i][0]);
    }
  }
  scc = cc.find_SCC();
  for (int i = 0; i < n; i++) comps[scc.second[i]].push_back(i);
  int mi = -1;
  for (int i = 0; i < scc.first; i++)
    if (noout(i) && (mi == -1 || comps[mi].size() > comps[i].size())) mi = i;
  cout << comps[mi].size() << endl;
  for (int i = 0; i < comps[mi].size(); i++) {
    if (i) cout << ' ';
    cout << comps[mi][i] + 1;
  }
  cout << endl;
}
