#include <bits/stdc++.h>
using namespace std;
int sy[100001], u[100001], h, a[100001], n, m, dfn[100001], low[100001],
    fir[100001], nex[200001], sto[200001], tot, a1, b1, t, cnt, zhan[100001],
    num[100001], nex1[200001], nmin[100001], ans, fir1[100001], now;
bool p[100001], p1[100001];
bool cmp(int aa, int bb) { return (aa < bb); }
int getmin(int aa, int bb) {
  if (aa < bb)
    return (aa);
  else
    return (bb);
}
void tarjan(int x) {
  int aa = fir[x];
  p[x] = false;
  p1[x] = true;
  cnt++;
  zhan[cnt] = x;
  t++;
  dfn[x] = t;
  low[x] = t;
  while (aa != 0) {
    if (p[sto[aa]]) {
      tarjan(sto[aa]);
      low[x] = getmin(low[x], low[sto[aa]]);
    } else if (p1[sto[aa]])
      low[x] = getmin(low[x], low[sto[aa]]);
    aa = nex[aa];
  }
  if (dfn[x] == low[x]) {
    bool q = true;
    ans++;
    nmin[ans] = zhan[cnt];
    num[ans] = 0;
    while (q) {
      int bb = zhan[cnt];
      sy[bb] = ans;
      if (dfn[bb] == low[bb]) q = false;
      if (bb < nmin[ans]) nmin[ans] = bb;
      num[ans]++;
      nex1[bb] = fir1[ans];
      fir1[ans] = bb;
      cnt--;
      p1[bb] = false;
    }
  }
}
int main() {
  scanf("%d%d%d", &n, &m, &h);
  for (int i = 1; i <= n; i++) {
    p[i] = true;
    p1[i] = false;
  }
  for (int i = 1; i <= n; i++) scanf("%d", &u[i]);
  tot = 0;
  ans = 0;
  for (int i = 1; i <= m; i++) {
    scanf("%d%d", &a1, &b1);
    if (((u[a1] + 1 - u[b1]) % h) == 0) {
      tot++;
      nex[tot] = fir[a1];
      fir[a1] = tot;
      sto[tot] = b1;
    }
    if (((1 + u[b1] - u[a1]) % h) == 0) {
      tot++;
      nex[tot] = fir[b1];
      fir[b1] = tot;
      sto[tot] = a1;
    }
  }
  cnt = 0;
  t = 0;
  for (int i = 1; i <= n; i++)
    if (p[i]) tarjan(i);
  now = 0;
  num[0] = n + 1;
  for (int i = 1; i <= ans; i++) {
    int dbd = fir1[i];
    bool p = true;
    while (dbd != 0) {
      int aa = fir[dbd];
      while (aa != 0) {
        if (sy[sto[aa]] != sy[dbd]) {
          p = false;
          break;
        }
        aa = nex[aa];
      }
      if (p == false) break;
      dbd = nex1[dbd];
    }
    if (p) {
      if (num[i] < num[now]) now = i;
    }
  }
  int cc = fir1[now];
  tot = 0;
  while (cc != 0) {
    tot++;
    a[tot] = cc;
    cc = nex1[cc];
  }
  sort(a + 1, a + 1 + tot, cmp);
  printf("%d\n", tot);
  for (int i = 1; i <= tot; i++) printf("%d ", a[i]);
}
