#include <bits/stdc++.h>
using namespace std;
inline long long gcd(long long a, long long b) {
  while (b != 0) {
    long long c = a % b;
    a = b;
    b = c;
  }
  return a;
}
inline long long lowbit(long long x) { return x & (-x); }
const double PI = 3.14159265358979323846;
const int inf = 0x3f3f3f3f;
const long long INF = 0x3f3f3f3f3f3f3f3f;
const long long mod = 998244353;
inline long long rd() {
  long long x = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = (x << 3) + (x << 1) + (ch ^ 48);
    ch = getchar();
  }
  return x * f;
}
const double eps = 1e-6;
const int M = 1e6 + 10;
const int N = 1e6 + 10;
struct Edge {
  int to, next;
} e[N << 1];
int head[N], tot;
void add(int x, int y) {
  e[++tot] = {y, head[x]};
  head[x] = tot;
}
int n, m, h;
int stk[N], dfn[N], low[N], c[N];
int num, cnt, top;
bool ins[N];
vector<int> scc[N];
void tarjan(int x) {
  dfn[x] = low[x] = ++num;
  stk[++top] = x, ins[x] = 1;
  for (int i = head[x]; i != -1; i = e[i].next) {
    int y = e[i].to;
    if (!dfn[y]) {
      tarjan(y);
      low[x] = min(low[x], low[y]);
    } else if (ins[y]) {
      low[x] = min(low[x], dfn[y]);
    }
  }
  if (dfn[x] == low[x]) {
    cnt++;
    int tmp;
    do {
      tmp = stk[top--], ins[tmp] = 0;
      c[tmp] = cnt;
      scc[cnt].push_back(tmp);
    } while (x != tmp);
  }
}
void init() {
  tot = num = cnt = top = 0;
  memset(head, -1, sizeof(int) * (n + 5));
}
int a[N];
int out[N];
int main() {
  n = rd(), m = rd(), h = rd();
  init();
  for (int i = 1; i <= n; i++) a[i] = rd();
  while (m--) {
    int u = rd(), v = rd();
    if ((a[u] + 1) % h == a[v]) add(u, v);
    if ((a[v] + 1) % h == a[u]) add(v, u);
  }
  for (int i = 1; i <= n; i++) {
    if (!dfn[i]) tarjan(i);
  }
  for (int x = 1; x <= n; x++) {
    for (int i = head[x]; i != -1; i = e[i].next) {
      int y = e[i].to;
      if (c[x] == c[y]) continue;
      out[c[x]]++;
    }
  }
  int ans = inf, pos = 0;
  for (int i = 1; i <= n; i++) {
    if (!out[c[i]] && scc[c[i]].size() < ans) {
      ans = scc[c[i]].size();
      pos = c[i];
    }
  }
  printf("%d\n", ans);
  for (int i = 1; i <= n; i++) {
    if (c[i] == pos) printf("%d ", i);
  }
  cout << endl;
}
