#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
int si[N], a[N], id[N], cnt, dfn[N], low[N], times, stk[N], top;
bool st[N];
vector<int> h[N];
void tarjan(int u) {
  stk[top++] = u, dfn[u] = low[u] = ++times, st[u] = true;
  for (int i = 0; i < h[u].size(); i++) {
    int j = h[u][i];
    if (!dfn[j]) {
      tarjan(j);
      low[u] = min(low[u], low[j]);
    } else if (st[j])
      low[u] = min(low[u], dfn[j]);
  }
  if (low[u] == dfn[u]) {
    int y;
    cnt++;
    do {
      y = stk[--top], st[y] = false;
      id[y] = cnt, si[cnt]++;
    } while (u != y);
  }
}
int main() {
  int n, m, k;
  scanf("%d %d %d", &n, &m, &k);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  for (int i = 1; i <= m; i++) {
    int as, b;
    scanf("%d%d", &as, &b);
    if ((a[as] + 1) % k == a[b]) h[as].push_back(b);
    if ((a[b] + 1) % k == a[as]) h[b].push_back(as);
  }
  for (int i = 1; i <= n; i++) {
    if (!dfn[i]) tarjan(i);
  }
  static int d[N];
  for (int i = 1; i <= n; i++)
    for (int j = 0; j < h[i].size(); j++) {
      int k = h[i][j];
      int x = id[i], y = id[k];
      if (x != y) d[x]++;
    }
  int Min = 1e9, temp = -1;
  for (int i = 1; i <= cnt; i++) {
    if (!d[i] && Min > si[i]) Min = si[i], temp = i;
  }
  printf("%d\n", Min);
  for (int i = 1; i <= n; i++)
    if (id[i] == temp) printf("%d ", i);
  return 0;
}
