#include <bits/stdc++.h>
using namespace std;
stack<int> p;
vector<int> op[1000005];
int dfn[1000005], low[1000005], len = 0;
int a[1000005], n, m, h, chu[1000005], scc[1000005], sc, num[1000005];
int Min(int x, int y) { return x < y ? x : y; }
void tarjan(int x) {
  dfn[x] = low[x] = ++len;
  p.push(x);
  for (int j = 0; j < op[x].size(); j++) {
    if (dfn[op[x][j]] == 0) {
      tarjan(op[x][j]);
      low[x] = Min(low[x], low[op[x][j]]);
    } else if (scc[op[x][j]] == 0)
      low[x] = Min(low[x], dfn[op[x][j]]);
  }
  if (dfn[x] == low[x]) {
    sc++;
    while (1) {
      int k = p.top();
      p.pop();
      scc[k] = sc;
      num[sc]++;
      if (x == k) break;
    }
  }
}
int main() {
  scanf("%d%d%d", &n, &m, &h);
  int x, y;
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  for (int i = 1; i <= m; i++) {
    scanf("%d%d", &x, &y);
    if ((a[x] + 1) % h == a[y]) op[x].push_back(y);
    if ((a[y] + 1) % h == a[x]) op[y].push_back(x);
  }
  for (int i = 1; i <= n; i++)
    if (dfn[i] == 0) tarjan(i);
  for (int i = 1; i <= n; i++) {
    for (int j = 0; j < op[i].size(); j++) {
      if (scc[i] != scc[op[i][j]]) chu[scc[i]]++;
    }
  }
  int min = 9999999, ans;
  for (int i = 1; i <= n; i++) {
    if (chu[scc[i]] == 0 && min > num[scc[i]]) {
      min = num[scc[i]];
      ans = scc[i];
    }
  }
  printf("%d\n", min);
  for (int i = 1; i <= n; i++) {
    if (scc[i] == ans) printf("%d ", i);
  }
  return 0;
}
