#include <bits/stdc++.h>
using namespace std;
const int N = 100004;
int pre[N], vis[N], low[N];
vector<int> g[N];
int u[N], sz[N], sccno[N], out[N];
int clk, cnt;
stack<int> stk;
void dfs(int u) {
  low[u] = pre[u] = ++clk;
  vis[u] = 1;
  stk.push(u);
  for (int i = 0; i < g[u].size(); i++) {
    int v = g[u][i];
    if (!pre[v]) {
      dfs(v);
      low[u] = min(low[u], low[v]);
    } else
      low[u] = min(low[u], pre[v]);
  }
  if (low[u] == pre[u]) {
    cnt++;
    while (1) {
      int x = stk.top();
      vis[x] = 0;
      stk.pop();
      sz[cnt]++;
      sccno[x] = cnt;
      if (x == u) break;
    }
  }
}
int main() {
  int n, m, h;
  scanf("%d %d %d", &n, &m, &h);
  int i;
  for (i = 1; i <= n; i++) scanf("%d", &u[i]);
  for (i = 1; i <= m; i++) {
    int x, y;
    scanf("%d %d", &x, &y);
    if ((u[x] + 1) % h == u[y]) g[x].push_back(y);
    if ((u[y] + 1) % h == u[x]) g[y].push_back(x);
  }
  for (i = 1; i <= n; i++) {
    if (!pre[i]) dfs(i);
  }
  for (i = 1; i <= n; i++) {
    for (int j = 0; j < g[i].size(); j++) {
      int x = i, y = g[i][j];
      if (sccno[x] == sccno[y]) continue;
      out[sccno[x]] = 1;
    }
  }
  int ans = 1e9, idx;
  for (i = 1; i <= cnt; i++) {
    if (!out[i] && sz[i] < ans) {
      ans = sz[i];
      idx = i;
    }
  }
  printf("%d\n", ans);
  for (i = 1; i <= n; i++) {
    if (sccno[i] == idx) printf("%d ", i);
  }
  return 0;
}
