#include <bits/stdc++.h>
using namespace std;
vector<int> graph[100010];
int visited[100010], num[100010], low[100010], A[100010], part[100010];
vector<int> st, comp[100010];
int ct = 1, comp_no = 0;
void tarjan(int s) {
  num[s] = low[s] = ct++;
  st.push_back(s);
  visited[s] = 1;
  for (int i = 0; i < graph[s].size(); i++) {
    if (!num[graph[s][i]]) tarjan(graph[s][i]);
    if (visited[graph[s][i]]) low[s] = min(low[s], low[graph[s][i]]);
  }
  if (low[s] == num[s]) {
    while (1) {
      int x = st.back();
      comp[comp_no].push_back(st.back());
      visited[st.back()] = 0;
      st.pop_back();
      part[x] = comp_no;
      if (x == s) break;
    }
    comp_no++;
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  int n, m, h;
  cin >> n >> m >> h;
  for (int i = 0; i < n; i++) cin >> A[i];
  for (int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    a--, b--;
    if ((A[a] + 1) % h == A[b]) graph[a].push_back(b);
    if ((A[b] + 1) % h == A[a]) graph[b].push_back(a);
  }
  for (int i = 0; i < n; i++) {
    if (!num[i]) tarjan(i);
  }
  int mini = 1000000000, ind = -1;
  for (int i = 0; i < comp_no; i++) {
    int mk = 0;
    for (int j = 0; j < comp[i].size(); j++) {
      for (int k = 0; k < graph[comp[i][j]].size(); k++) {
        if (part[graph[comp[i][j]][k]] != part[comp[i][j]]) {
          mk = 1;
          break;
        }
      }
      if (mk) break;
    }
    if (!mk) {
      if (mini > comp[i].size()) {
        mini = comp[i].size();
        ind = i;
      }
    }
  }
  cout << mini << '\n';
  for (int i = 0; i < comp[ind].size(); i++) cout << comp[ind][i] + 1 << " ";
  cout << '\n';
}
