#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e18;
const long double EPS = 1e-7;
vector<set<long long> > g, rg, new_g;
vector<long long> u, comp;
vector<vector<long long> > ver_in_comp;
long long n, m, h, cc = 0;
long long nxt(long long t) {
  if (t == h - 1) {
    return 0;
  }
  return t + 1;
}
void add_edge(long long a, long long b) {
  if (nxt(u[a]) == u[b]) {
    g[a].insert(b);
    rg[b].insert(a);
  }
}
void dfs_order(long long v, vector<bool>& used, vector<long long>& order) {
  used[v] = true;
  for (long long to : g[v]) {
    if (!used[to]) {
      dfs_order(to, used, order);
    }
  }
  order.push_back(v);
}
void dfs_comp(long long v) {
  comp[v] = cc;
  for (long long to : rg[v]) {
    if (comp[to] == -1) {
      dfs_comp(to);
    }
  }
}
void set_comp() {
  comp.resize(n, -1);
  vector<long long> order;
  vector<bool> used(n, false);
  for (long long i = 0; i < n; ++i) {
    if (!used[i]) {
      dfs_order(i, used, order);
    }
  }
  for (long long i = n - 1; i >= 0; --i) {
    if (comp[order[i]] == -1) {
      dfs_comp(order[i]);
      ++cc;
    }
  }
}
void set_new_g() {
  new_g.resize(cc);
  for (long long i = 0; i < n; ++i) {
    for (long long to : g[i]) {
      if (comp[i] != comp[to]) {
        new_g[comp[i]].insert(comp[to]);
      }
    }
  }
}
void set_ver_in_comp() {
  ver_in_comp.resize((signed)new_g.size());
  for (long long i = 0; i < n; ++i) {
    ver_in_comp[comp[i]].push_back(i);
  }
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> m >> h;
  g.resize(n);
  rg.resize(n);
  u.resize(n);
  for (long long& it : u) {
    cin >> it;
  }
  for (long long i = 0; i < m; ++i) {
    long long a, b;
    cin >> a >> b;
    --a;
    --b;
    add_edge(a, b);
    add_edge(b, a);
  }
  set_comp();
  set_new_g();
  set_ver_in_comp();
  long long p_ans = -1;
  for (long long i = 0; i < (signed)new_g.size(); ++i) {
    if (new_g[i].empty()) {
      if (p_ans == -1 ||
          (signed)ver_in_comp[i].size() < (signed)ver_in_comp[p_ans].size()) {
        p_ans = i;
      }
    }
  }
  cout << (signed)ver_in_comp[p_ans].size() << endl;
  for (long long it : ver_in_comp[p_ans]) {
    cout << it + 1 << " ";
  }
  cout << endl;
  return 0;
}
