#include <bits/stdc++.h>
using namespace std;
int n, m, h;
int a[300005];
int cnt[300005];
bool nope[300005];
vector<int> edge[300005];
class SCC {
 public:
  int n;
  int lv;
  vector<int> num, low, cid;
  vector<int> vis;
  vector<vector<int> > comp;
  stack<int> s;
  SCC(int n, vector<int> edge[]) : n(n), lv(0), num(n), low(n), cid(n), vis(n) {
    for (int v = 0; v < n; v++) {
      cid[v] = -1;
      num[v] = -1;
    }
    for (int v = 0; v < n; v++) {
      if (num[v] == -1) dfs(v, edge, comp);
    }
  }
  void dfs(int v, vector<int> edge[], vector<vector<int> > &r) {
    num[v] = low[v] = lv++;
    vis[v] = true;
    s.push(v);
    for (int i = 0; i < edge[v].size(); ++i) {
      int u = edge[v][i];
      if (num[u] == -1) {
        dfs(u, edge, r);
        low[v] = min(low[v], low[u]);
      } else if (vis[u]) {
        low[v] = min(low[v], low[u]);
      }
    }
    if (num[v] == low[v]) {
      int u;
      vector<int> nc;
      do {
        u = s.top();
        s.pop();
        vis[u] = false;
        cid[u] = r.size();
        nc.push_back(u);
      } while (v != u);
      r.push_back(nc);
    }
  }
};
int main() {
  scanf("%d%d%d", &n, &m, &h);
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
  }
  for (int i = 0; i < m; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    --x;
    --y;
    if ((a[x] + 1) % h == a[y]) edge[x].push_back(y);
    if ((a[y] + 1) % h == a[x]) edge[y].push_back(x);
  }
  SCC scc(n, edge);
  for (int i = 0; i < scc.comp.size(); i++) {
    for (int j = 0; j < scc.comp[i].size(); j++) {
      int v = scc.comp[i][j];
      for (int k = 0; k < edge[v].size(); k++) {
        int u = edge[v][k];
        if (i != scc.cid[u]) nope[i] = true;
      }
    }
  }
  int best = -1;
  for (int i = 0; i < scc.comp.size(); i++) {
    if (nope[i]) continue;
    if (best == -1 || scc.comp[i].size() < scc.comp[best].size()) best = i;
  }
  printf("%d\n", scc.comp[best].size());
  vector<int> ans_v;
  for (int i = 0; i < n; i++) {
    if (scc.cid[i] == best) {
      ans_v.push_back(i + 1);
    }
  }
  for (int i = 0; i < ans_v.size(); i++) {
    if (i) printf(" ");
    printf("%d", ans_v[i]);
  }
  puts("");
  return 0;
}
