#include <bits/stdc++.h>
using namespace std;
vector<long long> Next[100005];
vector<long long> last[100005];
vector<long long> This;
set<int> visit;
long long all[100005];
long long where[100005] = {0};
long long now = 1;
long long con[100005] = {0};
long long ans[100005] = {0};
bool have[100005] = {0};
stack<long long> how;
void F(long long here) {
  if (have[here]) return;
  have[here] = 1;
  for (auto i : last[here]) F(i);
  how.push(here);
}
void F2(long long here, long long &x) {
  if (have[here]) {
    visit.insert(where[here]);
    return;
  }
  This.push_back(here);
  have[here] = 1;
  x++;
  for (auto i : Next[here]) F2(i, x);
  where[here] = now;
}
void Pri(long long here) {
  if (have[here]) return;
  have[here] = 1;
  printf("%d ", here);
  for (auto i : Next[here]) Pri(i);
}
int main() {
  long long N, M, H, a, b, Ans = 2147483647, t, where, i, j;
  scanf("%lld %lld %lld", &N, &M, &H);
  for (i = 1; i <= N; i++) scanf("%lld", &all[i]);
  for (i = 0; i < M; i++) {
    scanf("%lld %lld", &a, &b);
    if ((all[a] + 1) % H == all[b]) {
      Next[a].push_back(b);
      last[b].push_back(a);
    }
    if ((all[b] + 1) % H == all[a]) {
      Next[b].push_back(a);
      last[a].push_back(b);
    }
  }
  for (j = 1; j <= N; j++) have[j] = 0;
  for (i = 1; i <= N; i++)
    if (!have[i]) F(i);
  for (j = 1; j <= N; j++) have[j] = 0;
  while (!how.empty()) {
    if (!have[how.top()]) {
      t = 0;
      This.clear();
      visit.clear();
      F2(how.top(), t);
      for (auto i : visit) t += con[i];
      for (auto i : This) ans[i] = t;
      con[now++] = t;
      This.clear();
    }
    how.pop();
  }
  for (i = 1; i <= N; i++) {
    if (ans[i] < Ans) {
      Ans = ans[i];
      where = i;
    }
  }
  printf("%lld\n", Ans);
  for (j = 1; j <= N; j++) have[j] = 0;
  Pri(where);
  return 0;
}
