#include <bits/stdc++.h>
using namespace std;
int x, y, z, a, b, dis[100005], low[100005], sz = 2e18, s, ss;
vector<int> q[100005], pq, v;
void dfs(int n) {
  static int indx = 1;
  dis[n] = low[n] = indx++;
  pq.push_back(n);
  for (auto i : q[n]) {
    if (!dis[i]) {
      dfs(i);
      low[n] = min(low[n], low[i]);
    } else {
      low[n] = min(low[n], dis[i]);
    }
  }
  if (dis[n] == low[n]) {
    int index = pq.size() - 1, sz2 = 1;
    while (pq[index] != n) {
      index--, sz2++;
    }
    if (sz2 < sz) {
      sz = sz2;
      s = index, ss = pq.size() - 1;
    }
  }
}
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  ;
  scanf("%d%d%d", &x, &y, &z);
  for (int i = 0; i < x; i++) {
    scanf("%d", &a);
    v.push_back(a);
  }
  for (int i = 0; i < y; i++) {
    scanf("%d%d", &a, &b);
    int fn = (v[a - 1] + 1) % z, fs = (v[b - 1] + 1) % z;
    if (fn == v[b - 1]) {
      q[a].push_back(b);
    }
    if (v[a - 1] == fs) {
      q[b].push_back(a);
    }
  }
  for (int i = 1; i <= x; i++) {
    if (!dis[i]) {
      dfs(i);
    }
  }
  cout << sz << endl;
  for (; s <= ss; s++) {
    printf("%d ", pq[s]);
  }
  printf("\n");
  return 0;
}
