#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 100005;
int n;
vector<int> g[MAX_N];
int siz[MAX_N];
namespace Tarjan {
int n, m, H;
int A[MAX_N];
stack<int> stc;
int dfn[MAX_N], low[MAX_N];
bool vis[MAX_N], in_stack[MAX_N];
int Index;
int com[MAX_N];
int tot;
vector<int> g[MAX_N];
void tarjan(int u) {
  dfn[u] = low[u] = ++Index;
  vis[u] = true;
  stc.push(u);
  in_stack[u] = true;
  int v;
  for (int i = 0; i < (int)g[u].size(); i++) {
    v = g[u][i];
    if (!vis[v]) {
      tarjan(v);
      low[u] = min(low[u], low[v]);
    } else if (in_stack[v]) {
      low[u] = min(low[u], dfn[v]);
    }
  }
  if (dfn[u] == low[u]) {
    tot++;
    do {
      v = stc.top();
      stc.pop();
      in_stack[v] = false;
      com[v] = tot;
    } while (u != v);
  }
}
void init() {
  cin >> n >> m >> H;
  for (int i = 1; i <= n; i++) cin >> A[i];
  for (int i = 1; i <= m; i++) {
    int u, v;
    cin >> u >> v;
    if ((A[u] + 1) % H == A[v]) {
      g[u].push_back(v);
    }
    if ((A[v] + 1) % H == A[u]) {
      g[v].push_back(u);
    }
  }
}
void get_new_graph(int &nn, vector<int> ng[]) {
  for (int i = 1; i <= n; i++)
    if (!vis[i]) tarjan(i);
  nn = tot;
  for (int i = 1; i <= n; i++) {
    siz[com[i]]++;
    for (int j = 0; j < (int)g[i].size(); j++) {
      int u = i, v = g[i][j];
      if (com[u] != com[v]) {
        ng[com[u]].push_back(com[v]);
      }
    }
  }
}
void print(int color) {
  for (int i = 1; i <= n; i++)
    if (com[i] == color) cout << i << ' ';
  cout << endl;
}
}  // namespace Tarjan
int main() {
  Tarjan::init();
  Tarjan::get_new_graph(n, g);
  int cnt = 0;
  for (int i = 1; i <= n; i++)
    if (g[i].empty()) cnt++;
  int mi = 1e9, pos = 0;
  for (int i = 1; i <= n; i++) {
    if (g[i].empty()) {
      if (mi > siz[i]) {
        mi = siz[i];
        pos = i;
      }
    }
  }
  cout << mi << endl;
  Tarjan::print(pos);
  return 0;
}
