#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const int maxn = 110000;
int n, m, h;
int head[maxn], num;
struct road {
  int to, next;
} edge[maxn * 2];
void add(int u, int v) {
  edge[num].to = v;
  edge[num].next = head[u];
  head[u] = num++;
}
int dfn[maxn], low[maxn], block[maxn];
int id, cnt, vis[maxn], numxx[maxn];
int out[maxn];
stack<int> q;
void dfs(int u, int fa) {
  dfn[u] = low[u] = ++id;
  q.push(u);
  vis[u] = 1;
  for (int i = head[u]; i != -1; i = edge[i].next) {
    int v = edge[i].to;
    if (!dfn[v]) {
      dfs(v, u);
      low[u] = min(low[v], low[u]);
    } else if (vis[v])
      low[u] = min(low[u], dfn[v]);
  }
  if (dfn[u] == low[u]) {
    cnt++;
    int v;
    do {
      v = q.top();
      vis[v] = 0;
      q.pop();
      block[v] = cnt;
      numxx[cnt]++;
    } while (v != u);
  }
}
int tim[maxn];
void init() {
  id = num = cnt = 0;
  memset(dfn, 0, sizeof(dfn));
  memset(low, 0, sizeof(low));
  memset(edge, 0, sizeof(edge));
  memset(numxx, 0, sizeof(numxx));
  memset(block, 0, sizeof(block));
  memset(vis, 0, sizeof(vis));
  while (!q.empty()) q.pop();
  memset(head, -1, sizeof(head));
  memset(out, 0, sizeof(out));
}
int main() {
  while (scanf("%d%d%d", &n, &m, &h) != EOF) {
    init();
    for (int i = 1; i <= n; i++) {
      scanf("%d", &tim[i]);
    }
    for (int i = 1; i <= m; i++) {
      int a, b;
      scanf("%d%d", &a, &b);
      if ((tim[a] + 1) % h == tim[b]) add(a, b);
      if ((tim[b] + 1) % h == tim[a]) add(b, a);
    }
    for (int i = 1; i <= n; i++) {
      if (!dfn[i]) dfs(i, -1);
    }
    for (int i = 1; i <= n; i++) {
      for (int j = head[i]; j != -1; j = edge[j].next) {
        int v = edge[j].to;
        if (block[v] != block[i]) {
          out[block[i]]++;
        }
      }
    }
    int ans = INF;
    int flag = 0;
    for (int i = 1; i <= cnt; i++) {
      if (out[i] == 0) {
        if (ans > numxx[i]) {
          ans = numxx[i];
          flag = i;
        }
      }
    }
    cout << ans << endl;
    for (int i = 1; i <= n; i++) {
      int putt = 0;
      if (block[i] == flag) {
        ans--;
        putt = 1;
      }
      if (ans != 0 && putt == 1)
        cout << i << " ";
      else if (ans == 0 && putt == 1)
        cout << i << endl;
    }
  }
}
