#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e5;
const int LOGN = 0;
const int MOD = 1e9 + 7;
const int INF = 1e9 + 10;
const long long INFLL = (long long)1e18 + 10;
int N, M, H;
int u[MAXN + 10];
pair<int, int> c[MAXN + 10];
vector<int> adjl[MAXN + 10];
vector<int> tadjl[MAXN + 10];
bool visited[MAXN + 10], assigned[MAXN + 10];
list<int> l;
vector<int> components[MAXN + 10];
int component_of[MAXN + 10];
bool has_out[MAXN + 10];
void read() {
  cin >> N >> M >> H;
  for (int(i) = 1; (i) <= (N); ++(i)) cin >> u[i];
  for (int(i) = 1; (i) <= (M); ++(i)) cin >> c[i].first >> c[i].second;
  return;
}
int next_hour(int x) { return (x + 1) % H; }
void build() {
  for (int(i) = 1; (i) <= (M); ++(i)) {
    if (next_hour(u[c[i].first]) == u[c[i].second]) {
      adjl[c[i].first].push_back(c[i].second);
      tadjl[c[i].second].push_back(c[i].first);
    }
    if (next_hour(u[c[i].second]) == u[c[i].first]) {
      adjl[c[i].second].push_back(c[i].first);
      tadjl[c[i].first].push_back(c[i].second);
    }
  }
  return;
}
void visit(int node) {
  if (!visited[node]) {
    visited[node] = true;
    for (auto(it) : (adjl[node])) visit(it);
    l.push_front(node);
  }
  return;
}
void assign(int node, int root) {
  if (!assigned[node]) {
    assigned[node] = true;
    components[root].push_back(node);
    component_of[node] = root;
    for (auto(it) : (tadjl[node])) assign(it, root);
  }
  return;
}
void kosaraju() {
  for (int(i) = 1; (i) <= (N); ++(i)) visit(i);
  for (auto(it) : (l)) assign(it, it);
  return;
}
void select() {
  pair<int, int> ans = pair<int, int>(INF, INF);
  for (int(i) = 1; (i) <= (N); ++(i)) {
    if (components[i].size()) {
      for (auto(it) : (components[i])) {
        for (auto(neigh) : (adjl[it])) {
          if (component_of[neigh] != i) has_out[i] = true;
        }
      }
      if (!has_out[i]) ans = min(ans, pair<int, int>(components[i].size(), i));
    }
  }
  cout << ans.first;
  cout << "\n";
  for (auto(it) : (components[ans.second])) cout << it << " ";
  cout << "\n";
  return;
}
int main() {
  ios_base::sync_with_stdio(false);
  read();
  build();
  kosaraju();
  select();
  return 0;
}
