#include <bits/stdc++.h>
using namespace std;
const int MAXN = (int)1e5 + 10;
int u[MAXN];
vector<int> g[MAXN], grev[MAXN];
vector<int> top_sort;
bool used[MAXN];
int out_deg[MAXN];
int color[MAXN];
vector<int> comp[MAXN];
void dfs(int v) {
  used[v] = true;
  for (int to : g[v]) {
    if (!used[to]) {
      dfs(to);
    }
  }
  top_sort.push_back(v);
}
void coloring(int v, int cnt) {
  used[v] = true;
  color[v] = cnt;
  comp[cnt].push_back(v);
  for (int to : grev[v]) {
    if (!used[to]) {
      coloring(to, cnt);
    }
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  memset(used, 0, sizeof(used));
  int n, m, h;
  cin >> n >> m >> h;
  for (int i = 0; i < n; ++i) {
    cin >> u[i];
  }
  for (int i = 0; i < m; ++i) {
    int a, b;
    cin >> a >> b;
    --a, --b;
    if ((u[a] + 1) % h == u[b]) {
      g[a].push_back(b);
      grev[b].push_back(a);
    }
    if ((u[b] + 1) % h == u[a]) {
      g[b].push_back(a);
      grev[a].push_back(b);
    }
  }
  for (int i = 0; i < n; ++i) {
    if (!used[i]) {
      dfs(i);
    }
  }
  memset(used, 0, sizeof(used));
  int cnt = 0;
  for (int i = n - 1; i >= 0; --i) {
    int v = top_sort[i];
    if (!used[v]) {
      coloring(v, cnt++);
    }
  }
  memset(out_deg, 0, sizeof(out_deg));
  for (int i = 0; i < n; ++i) {
    for (int to : g[i]) {
      if (color[i] != color[to]) {
        out_deg[color[i]]++;
      }
    }
  }
  int num = 0;
  for (int i = 1; i < cnt; ++i) {
    if (out_deg[i] != 0) {
      continue;
    }
    if (out_deg[num] != 0) {
      num = i;
      continue;
    }
    if (comp[i].size() < comp[num].size()) {
      num = i;
    }
  }
  cout << comp[num].size() << "\n";
  for (int v : comp[num]) {
    cout << v + 1 << " ";
  }
  cout << endl;
  return 0;
}
