#include <bits/stdc++.h>
using namespace std;
const int maxn = 1000 * 100 + 10;
int n, m, h, T[maxn];
vector<int> G[2][maxn], q, vCol[maxn];
int mark[maxn];
void add(int u, int v) {
  G[0][u].push_back(v);
  G[1][v].push_back(u);
}
void dfs(int root, int yal, int col) {
  mark[root] = col;
  if (yal == 1) vCol[col].push_back(root);
  for (int j = 0; j < G[yal][root].size(); j++) {
    int tmp = G[yal][root][j];
    if (mark[tmp] == 0) dfs(tmp, yal, col);
  }
  if (yal == 0) q.push_back(root);
}
int main() {
  scanf("%d%d%d", &n, &m, &h);
  int ans = n;
  for (int i = 0; i < n; i++) scanf("%d", &T[i]);
  while (m--) {
    int u, v;
    scanf("%d%d", &u, &v);
    u--, v--;
    if ((T[u] + 1) % h == T[v]) add(u, v);
    if ((T[v] + 1) % h == T[u]) add(v, u);
  }
  for (int i = 0; i < n; i++)
    if (!mark[i]) dfs(i, 0, 1);
  for (int i = 0; i < maxn; i++) mark[i] = 0;
  int col = 0;
  for (int i = q.size() - 1; i >= 0; i--)
    if (!mark[q[i]]) {
      col++;
      dfs(q[i], 1, col);
    }
  int myCol = 0;
  for (int i = 1; i <= col; i++) {
    int flag = 1;
    for (int j = 0; j < vCol[i].size(); j++) {
      int u = vCol[i][j];
      for (int l = 0; l < G[0][u].size(); l++) {
        int v = G[0][u][l];
        if (mark[u] != mark[v]) {
          flag = 0;
          break;
        }
      }
    }
    if (flag and ans >= vCol[i].size()) {
      ans = vCol[i].size();
      myCol = i;
    }
  }
  printf("%d\n", ans);
  for (int i = 0; i < vCol[myCol].size(); i++)
    printf("%d ", vCol[myCol][i] + 1);
  printf("\n");
  return 0;
}
