#include <bits/stdc++.h>
using namespace std;
const int MAXN = 123456;
int u[MAXN], sz[MAXN], col[MAXN];
bool visit[MAXN];
vector<int> G[MAXN], rG[MAXN], fG[MAXN];
stack<int> stk;
set<int> outdeg[MAXN];
void dfs1(int cur) {
  visit[cur] = 1;
  for (auto i : G[cur])
    if (!visit[i]) dfs1(i);
  stk.push(cur);
}
void dfs2(int cur, int color) {
  col[cur] = color;
  sz[color]++;
  for (int i : rG[cur])
    if (!col[i]) dfs2(i, color);
}
int kosaragu(int n) {
  for (int i = 1; i <= n; i++)
    if (!visit[i]) dfs1(i);
  int sum = 1;
  while (!stk.empty()) {
    int tp = stk.top();
    stk.pop();
    if (!col[tp]) dfs2(tp, sum++);
  }
  return sum;
}
int main() {
  int n, m, h;
  while (~scanf("%d %d %d", &n, &m, &h)) {
    for (int i = 1; i <= n; i++) scanf("%d", &u[i]);
    for (int i = 1; i <= m; i++) {
      int x, y;
      scanf("%d %d", &x, &y);
      int xx = u[x], yy = u[y];
      if (xx > yy) {
        swap(xx, yy);
        swap(x, y);
      }
      if (xx == yy - 1) {
        G[x].push_back(y);
        rG[y].push_back(x);
      }
      if (xx == (yy + 1) % h) {
        G[y].push_back(x);
        rG[x].push_back(y);
      }
    }
    int col_num = kosaragu(n);
    for (int i = 1; i <= n; i++) {
      for (auto j : G[i]) {
        if (col[j] != col[i]) outdeg[col[i]].insert(col[j]);
      }
    }
    int ans = n, ans_c = 1;
    for (int i = 1; i < col_num; i++) {
      if ((int)outdeg[i].size() == 0 && sz[i] <= ans) {
        ans = sz[i];
        ans_c = i;
      }
    }
    printf("%d\n", ans);
    vector<int> OK;
    for (int i = 1; i <= n; i++) {
      if (col[i] == ans_c) OK.push_back(i);
    }
    for (int i : OK) printf("%d ", i);
    puts("");
  }
  return 0;
}
