#include <bits/stdc++.h>
using namespace std;
ofstream out("biconex.out");
ifstream in("biconex.in");
struct Edge {
  int node;
  bool is_critic;
};
const int N_MAX = 100000;
vector<Edge> neighbours[1 + N_MAX];
stack<int> component;
int n, m, h, minim = N_MAX + 1, node_ans, Depth, root_sons, depth[1 + N_MAX],
             height[1 + N_MAX], main_hour[1 + N_MAX], color[1 + N_MAX];
bool visited[1 + N_MAX], not_in_subgraph[1 + N_MAX], is_critic[1 + N_MAX],
    on_stack[1 + N_MAX];
void read() {
  cin >> n >> m >> h;
  for (int i = 1; i <= n; i++) cin >> main_hour[i];
  for (int i = 0; i < m; i++) {
    int x, y;
    cin >> x >> y;
    if (main_hour[x] - main_hour[y] == 1 |
        (main_hour[x] == 0 & main_hour[y] == h - 1))
      neighbours[y].push_back({x, false});
    if (main_hour[y] - main_hour[x] == 1 |
        (main_hour[y] == 0 & main_hour[x] == h - 1))
      neighbours[x].push_back({y, false});
  }
  for (int i = 1; i <= n; i++) depth[i] = -1;
}
void DFS(int node, int root) {
  depth[node] = height[node] = Depth;
  component.push(node);
  on_stack[node] = true;
  Depth++;
  for (Edge& son : neighbours[node]) {
    if (depth[son.node] == -1) {
      DFS(son.node, root);
      height[node] = min(height[node], height[son.node]);
    } else if (on_stack[son.node])
      height[node] = min(height[node], depth[son.node]);
  }
  if (height[node] == depth[node]) {
    int son;
    do {
      son = component.top();
      color[son] = node;
      component.pop();
      on_stack[son] = false;
    } while (son != node);
  }
}
int DFS2(int node, int cnt, bool possible_ans) {
  cnt++;
  visited[node] = true;
  for (Edge son : neighbours[node]) {
    if (color[node] != color[son.node]) {
      possible_ans = false;
      continue;
    }
    if (visited[son.node]) continue;
    cnt = DFS2(son.node, cnt, possible_ans);
    if (!cnt) possible_ans = false;
  }
  if (!possible_ans) cnt = 0;
  return cnt;
}
void solution() {
  for (int i = 1; i <= n; i++)
    if (depth[i] == -1) DFS(i, i);
  for (int i = 1; i <= n; i++) visited[i] = false;
  for (int i = 1; i <= n; i++) {
    if (visited[i]) continue;
    int cnt = DFS2(i, 0, true);
    if (cnt)
      if (minim > cnt) {
        minim = cnt;
        node_ans = i;
      }
  }
}
void DFS_print(int node) {
  cout << node << " ";
  visited[node] = true;
  for (Edge son : neighbours[node]) {
    if (!visited[son.node]) DFS_print(son.node);
  }
}
void print() {
  cout << minim << "\n";
  for (int i = 1; i <= n; i++) visited[i] = false;
  DFS_print(node_ans);
}
int main() {
  read();
  solution();
  print();
  return 0;
}
