#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 1;
int h;
vector<vector<int>> g(N), tree(N);
vector<int> used(N, 0), u(N), comp, comp_size, order, comp_node(N);
void dfs(int v) {
  used[v] = 1;
  for (auto &to : g[v]) {
    if (!used[to] && (u[v] + 1) % h == u[to]) {
      dfs(to);
    }
  }
  order.push_back(v);
}
void find_comp(int v) {
  used[v] = 1;
  comp.push_back(v);
  for (auto &to : g[v]) {
    if (!used[to] && (u[to] + 1) % h == u[v]) {
      find_comp(to);
    }
  }
}
int main() {
  int n, m;
  cin >> n >> m >> h;
  for (int i = 0; i < n; ++i) {
    cin >> u[i];
  }
  for (int i = 0; i < m; ++i) {
    int e, v;
    cin >> e >> v;
    g[--e].push_back(--v);
    g[v].push_back(e);
  }
  for (int i = 0; i < n; ++i) {
    if (!used[i]) {
      dfs(i);
    }
  }
  used.assign(n + 1, 0);
  int cnt_comp = 0;
  for (int i = n - 1; i >= 0; --i) {
    if (!used[order[i]]) {
      find_comp(order[i]);
      for (int j : comp) {
        comp_node[j] = cnt_comp;
      }
      comp_size.push_back(comp.size());
      comp.clear();
      ++cnt_comp;
    }
  }
  used.assign(n + 1, 0);
  for (int i = 0; i < n; ++i) {
    for (auto &to : g[i]) {
      if (comp_node[i] != comp_node[to] && (u[i] + 1) % h == u[to]) {
        tree[comp_node[i]].push_back(comp_node[to]);
      }
    }
  }
  int comp_num, mn = 1e9;
  for (int i = 0; i < cnt_comp; ++i) {
    if (!tree[i].size() && comp_size[i] < mn) {
      mn = comp_size[i];
      comp_num = i;
    }
  }
  cout << mn << endl;
  for (int i = 0; i < n; ++i) {
    if (comp_node[i] == comp_num) {
      cout << i + 1 << " ";
    }
  }
}
