#include <bits/stdc++.h>
using namespace std;
int n, m, h;
int a[300005];
int lv, comp;
int d[300005], low[300005], scc[300005];
bool vis[300005], nope[300005];
int cnt[300005];
stack<int> s;
vector<int> edge[300005];
void tarjan(int v) {
  d[v] = low[v] = lv++;
  vis[v] = true;
  s.push(v);
  for (int i = 0; i < edge[v].size(); ++i) {
    int u = edge[v][i];
    if (d[u] == -1) {
      tarjan(u);
      low[v] = min(low[v], low[u]);
    } else if (vis[u]) {
      low[v] = min(low[v], low[u]);
    }
  }
  if (d[v] == low[v]) {
    int u;
    do {
      u = s.top();
      s.pop();
      vis[u] = false;
      scc[u] = comp;
    } while (v != u);
    comp++;
  }
}
int main() {
  scanf("%d%d%d", &n, &m, &h);
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
    scc[i] = -1;
    d[i] = -1;
  }
  for (int i = 0; i < m; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    --x;
    --y;
    if ((a[x] + 1) % h == a[y]) edge[x].push_back(y);
    if ((a[y] + 1) % h == a[x]) edge[y].push_back(x);
  }
  for (int i = 0; i < n; i++) {
    if (d[i] == -1) {
      tarjan(i);
    }
  }
  for (int i = 0; i < n; i++) {
    cnt[scc[i]]++;
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < edge[i].size(); j++) {
      if (scc[i] != scc[edge[i][j]]) nope[scc[i]] = true;
    }
  }
  int cid = -1;
  for (int i = 0; i < n; i++) {
    if (nope[scc[i]]) continue;
    if (cid == -1 || cnt[scc[i]] < cnt[cid]) cid = scc[i];
  }
  printf("%d\n", cnt[cid]);
  vector<int> ans_v;
  for (int i = 0; i < n; i++) {
    if (scc[i] == cid) {
      ans_v.push_back(i + 1);
    }
  }
  for (int i = 0; i < ans_v.size(); i++) {
    if (i) printf(" ");
    printf("%d", ans_v[i]);
  }
  puts("");
  return 0;
}
