#include <bits/stdc++.h>
using namespace std;
vector<int> graph[100000 + 100], g1[100000 + 100], g2[100000 + 100], ts;
vector<vector<int> > scc;
int vis1[100000 + 100], vis2[100000 + 100], lst, pos[100000 + 100],
    mnt[100000 + 100];
void dfs1(int u) {
  vis1[u] = 1;
  for (auto it : g1[u]) {
    if (!vis1[it]) {
      dfs1(it);
    }
  }
  ts.push_back(u);
}
void dfs2(int u) {
  scc.back().push_back(u);
  vis2[u] = 1;
  pos[u] = lst;
  for (auto it : g2[u]) {
    if (!vis2[it]) {
      dfs2(it);
    }
  }
}
int main() {
  int n, m, h;
  scanf("%d%d%d", &n, &m, &h);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &mnt[i]);
  }
  for (int i = 1; i <= m; i++) {
    int c1, c2;
    scanf("%d%d", &c1, &c2);
    graph[c1].push_back(c2);
    graph[c2].push_back(c1);
  }
  for (int i = 1; i <= n; i++) {
    for (auto it : graph[i]) {
      int u = it;
      if ((mnt[i] + 1) % h == mnt[u]) {
        g1[i].push_back(it);
        g2[it].push_back(i);
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    if (!vis1[i]) {
      dfs1(i);
    }
  }
  for (int i = n - 1; i >= 0; i--) {
    if (!vis2[ts[i]]) {
      scc.emplace_back();
      lst++;
      dfs2(ts[i]);
    }
  }
  vector<int> ans;
  int mn = 1e6;
  for (int i = 0; i < lst; i++) {
    bool flag = true;
    for (auto it : scc[i]) {
      for (auto cur : g1[it]) {
        if (pos[cur] != i + 1) {
          flag = false;
        }
      }
    }
    if (flag && (int)scc[i].size() < mn) {
      ans.clear();
      ans = scc[i];
      mn = ans.size();
    }
  }
  printf("%d\n", mn);
  for (auto it : ans) {
    printf("%d ", it);
  }
  printf("\n");
}
