#include <bits/stdc++.h>
using namespace std;
int n, m, h, d[100005], num[100005], topo[100005], cnt = 0, pofn[100005],
                                                   p[100005], dd[100005];
vector<int> a[100005], b[100005];
void dfs1(int h) {
  num[h] = 1;
  int n = b[h].size() - 1;
  for (int i = 0; i <= n; ++i) {
    if (!num[b[h][i]]) dfs1(b[h][i]);
  }
  topo[++cnt] = h;
}
void dfs2(int h) {
  pofn[h] = cnt;
  p[cnt]++;
  int n = a[h].size() - 1;
  for (int i = 0; i <= n; ++i) {
    if (!pofn[a[h][i]]) {
      dfs2(a[h][i]);
    } else {
      if (pofn[a[h][i]] != cnt) dd[pofn[a[h][i]]] = 1;
    }
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  scanf("%d%d%d", &n, &m, &h);
  for (int i = 1; i <= n; ++i) scanf("%d", &d[i]);
  int x, y;
  for (int i = 1; i <= m; ++i) {
    scanf("%d%d", &x, &y);
    if ((d[x] - d[y] + h) % h == 1) a[x].push_back(y), b[y].push_back(x);
    if ((d[y] - d[x] + h) % h == 1) a[y].push_back(x), b[x].push_back(y);
  }
  for (int i = 1; i <= n; ++i) {
    if (!num[i]) dfs1(i);
  }
  cnt = 0;
  for (int i = n; i >= 1; --i) {
    if (!pofn[topo[i]]) cnt++, dfs2(topo[i]);
  }
  int res = 0;
  p[0] = 2e5;
  for (int i = 1; i <= cnt; ++i) {
    if (!dd[i] && p[i] < p[res]) res = i;
  }
  printf("%d\n", p[res]);
  for (int i = 1; i <= n; ++i)
    if (pofn[i] == res) printf("%d ", i);
}
