#include <bits/stdc++.h>
using namespace std;
const int mx = 1e5 + 10;
int n, m, h, ui[mx], head[mx], tot, ans, anstype;
vector<int> sta;
struct node {
  int y;
  int nxt;
} Edge[mx << 1];
void AddEdge(int x, int y) {
  Edge[tot].y = y;
  Edge[tot].nxt = head[x];
  head[x] = tot++;
}
int out[mx];
int type[mx], typeCnt[mx], top;
bool vis[mx];
void dfs1(int x) {
  if (vis[x]) return;
  vis[x] = 1;
  for (int i = head[x]; ~i; i = Edge[i].nxt) dfs1(Edge[i].y);
  sta.push_back(x);
}
void Dfs(int x) {
  if (type[x]) return;
  type[x] = top;
  typeCnt[top]++;
  for (int i = head[x]; ~i; i = Edge[i].nxt) Dfs(Edge[i].y);
}
int main() {
  memset(head, -1, sizeof(head));
  top = tot = 0;
  ans = 1e9;
  scanf("%d%d%d", &n, &m, &h);
  for (int i = 1; i <= n; i++) scanf("%d", ui + i);
  int a, b, flag = 0;
  while (m--) {
    scanf("%d%d", &a, &b);
    if ((ui[a] + 1) % h == ui[b]) vis[a] = 1, AddEdge(a, b);
    if ((ui[b] + 1) % h == ui[a]) vis[b] = 1, AddEdge(b, a);
  }
  for (int i = 1; i <= n; i++)
    if (!vis[i]) return 0 * printf("1\n%d", i);
  memset(vis, 0, sizeof(vis));
  for (int i = 1; i <= n; i++)
    if (!vis[i]) dfs1(i);
  for (int i = 0; i < n; i++)
    if (!type[sta[i]]) top++, Dfs(sta[i]);
  for (int i = 1; i <= n; i++) {
    if (out[type[i]]) continue;
    for (int j = head[i]; ~j; j = Edge[j].nxt) {
      int son = Edge[j].y;
      if (type[son] != type[i]) {
        out[type[i]]++;
        break;
      }
    }
  }
  for (int i = 1; i <= top; i++)
    if (!out[i] && ans > typeCnt[i]) ans = typeCnt[i], anstype = i;
  printf("%d\n", ans);
  for (int i = 1; i <= n; i++)
    if (type[i] == anstype) printf("%d ", i);
  return puts("");
}
