#include <bits/stdc++.h>
using namespace std;
#pragma comment(linker, "/STACK:60777216")
const int max_n = 100050;
int n;
vector<int> neigh[max_n];
int val[max_n];
int c;
int s[max_n], s_ed;
int b[2 * max_n], b_ed;
void run_dfs(int v) {
  s[++s_ed] = v;
  val[v] = s_ed;
  b[++b_ed] = val[v];
  for (int j = 0; j < int(neigh[v].size()); j++) {
    int w = neigh[v][j];
    if (val[w] == -1)
      run_dfs(w);
    else
      while (val[w] < b[b_ed]) b_ed--;
  }
  if (val[v] == b[b_ed]) {
    b_ed--;
    c++;
    while (val[v] <= s_ed) val[s[s_ed--]] = c;
  }
}
void strong() {
  s_ed = b_ed = -1;
  for (int v = 0; v < n; v++) val[v] = -1;
  c = n - 1;
  for (int v = 0; v < n; v++)
    if (val[v] == -1) run_dfs(v);
  for (int v = 0; v < n; v++)
    if (val[v] != -1) val[v] -= n;
}
const int inf = 1000000000;
int ans = inf;
int ans_v;
bool vis[max_n] = {false};
bool is_sink;
int dfs(int v) {
  assert(vis[v] == false);
  int sz = 1;
  vis[v] = true;
  for (int w : neigh[v]) {
    if (val[w] == val[v] && !vis[w]) {
      sz += dfs(w);
    }
    if (val[w] != val[v]) is_sink = false;
  }
  return sz;
}
void print(int v) {
  assert(vis[v] == false);
  printf("%d ", v + 1);
  vis[v] = true;
  for (int w : neigh[v])
    if (!vis[w]) print(w);
}
void run() {
  for (int i = 0; i < n; i++)
    if (!vis[i]) {
      is_sink = true;
      int sz = dfs(i);
      if (is_sink && ans > sz) {
        ans = sz;
        ans_v = i;
      }
    }
  for (int i = 0; i < n; i++) vis[i] = false;
  printf("%d\n", ans);
  print(ans_v);
  printf("\n");
}
int u[100050];
int c1[100050], c2[100050];
int main() {
  scanf("%d", &n);
  int m, h;
  scanf("%d %d", &m, &h);
  for (int i = 1; i <= n; i++) scanf("%d", &u[i]);
  for (int i = 0; i < m; i++) scanf("%d %d", &c1[i], &c2[i]);
  for (int i = 0; i < m; i++) {
    if ((u[c1[i]] + 1) % h == u[c2[i]]) neigh[c1[i] - 1].push_back(c2[i] - 1);
    if ((u[c2[i]] + 1) % h == u[c1[i]]) neigh[c2[i] - 1].push_back(c1[i] - 1);
  }
  strong();
  run();
  return 0;
}
