#include <bits/stdc++.h>
using namespace std;
const int NN = 200005;
vector<int> vv[NN];
void _addedge(int x, int y) { vv[x].push_back(y); }
int dfn[NN], low[NN], stk[NN], blo[NN], block, Cnt, Now;
int ins[NN];
void tarjan(int n) {
  int i, j;
  low[n] = dfn[n] = ++Cnt, ins[stk[++Now] = n] = 1;
  for (i = 0; i < vv[n].size(); i++)
    if (dfn[j = vv[n][i]] == 0)
      tarjan(j), low[n] = min(low[n], low[j]);
    else if (ins[j])
      low[n] = min(low[n], low[j]);
  if (dfn[n] == low[n] && ++block) do
      blo[i = stk[Now--]] = block, ins[i] = 0;
    while (i != n);
}
int uu[NN];
vector<int> ans[NN];
bool vs[NN];
void check(int n) {
  for (int i = 1; i <= n; i++) {
    for (int j = 0; j < vv[i].size(); j++)
      if (blo[i] != blo[vv[i][j]]) vs[blo[i]] = 1;
  }
  for (int i = 1; i <= n; i++) ans[blo[i]].push_back(i);
  int best = n + 1;
  int index = 0;
  for (int i = 1; i <= block; i++)
    if (!vs[i]) {
      if (best > ans[i].size()) {
        best = ans[i].size();
        index = i;
      }
    }
  printf("%d\n", ans[index].size());
  for (int i = 0; i < ans[index].size(); i++)
    printf("%d%c", ans[index][i], i == ans[index].size() ? '\n' : ' ');
}
int main() {
  int n, m, k;
  cin >> n >> m >> k;
  for (int i = 1; i <= n; i++) scanf("%d", &uu[i]);
  for (int i = 0; i < m; i++) {
    int x, y;
    scanf("%d %d", &x, &y);
    int v1 = uu[x], v2 = uu[y];
    if (v1 < v2) {
      if (v1 + 1 == v2) _addedge(x, y);
      if (v1 == 0 && v2 == k - 1) _addedge(y, x);
    }
    if (v2 < v1) {
      if (v2 + 1 == v1) _addedge(y, x);
      if (v2 == 0 && v1 == k - 1) _addedge(x, y);
    }
  }
  for (int i = 1; i <= n; i++)
    if (dfn[i] == 0) tarjan(i);
  check(n);
  return 0;
}
