#include <bits/stdc++.h>
using namespace std;
int n, m, h[100010], H, siz[100010], g, num, tot, b[100010], dfn[100010],
    low[100010], belong[100010], id[100010];
bool insta[100010], flag[100010];
stack<int> sta;
struct edge {
  int x, y, last;
} a[100010 * 2];
void add(int x, int y) {
  a[++tot] = (edge){x, y, b[x]};
  b[x] = tot;
}
bool cmp(int a, int b) { return siz[a] < siz[b]; }
void dfs(int x) {
  dfn[x] = low[x] = ++num;
  sta.push(x);
  insta[x] = 1;
  for (int i = b[x]; i; i = a[i].last) {
    int y = a[i].y;
    if (!dfn[y]) {
      dfs(y);
      low[x] = min(low[x], low[y]);
    } else {
      if (insta[y]) {
        low[x] = min(low[x], low[y]);
      }
    }
  }
  if (low[x] == dfn[x]) {
    int t;
    ++g;
    do {
      siz[g]++;
      t = sta.top();
      sta.pop();
      insta[t] = 0;
      belong[t] = g;
    } while (t != x);
  }
}
int main() {
  scanf("%d%d%d", &n, &m, &H);
  for (int i = 1; i <= n; i++) scanf("%d", &h[i]);
  for (int i = 1; i <= m; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    if ((h[x] + 1) % H == h[y]) {
      add(x, y);
    }
    if ((h[y] + 1) % H == h[x]) {
      add(y, x);
    }
  }
  for (int i = 1; i <= n; i++) {
    if (!dfn[i]) {
      dfs(i);
    }
  }
  for (int i = 1; i <= tot; i++) {
    if (belong[a[i].x] != belong[a[i].y]) flag[belong[a[i].x]] = 1;
  }
  int ansk = 0;
  for (int i = 1; i <= g; i++) {
    if (!flag[i]) {
      if (ansk == 0 || siz[ansk] > siz[i]) {
        ansk = i;
      }
    }
  }
  printf("%d\n", siz[ansk]);
  for (int i = 1; i <= n; i++) {
    if (belong[i] == ansk) printf("%d ", i);
  }
}
