#include <bits/stdc++.h>
using namespace std;
int low[100010], depth[100010], timer, cyc, mp[100010];
vector<int> a[100010], scc[100010];
stack<int> stck;
bool vis[100010], sccs[100010], in[100010];
void dfs(int x) {
  low[x] = depth[x] = timer++;
  stck.push(x);
  vis[x] = 1;
  in[x] = 1;
  int nxt;
  for (int i = 0; i < a[x].size(); ++i) {
    nxt = a[x][i];
    if (!vis[nxt]) {
      dfs(nxt);
      low[x] = min(low[x], low[nxt]);
    } else {
      if (in[nxt]) {
        low[x] = min(low[x], depth[nxt]);
      }
    }
  }
  if (low[x] >= depth[x]) {
    while (1) {
      nxt = stck.top();
      scc[cyc].push_back(nxt);
      mp[nxt] = cyc;
      stck.pop();
      in[nxt] = 0;
      if (nxt == x) break;
    }
    ++cyc;
  }
}
int hh[100010];
int main() {
  int n, m, x, y, nxt, ans, h;
  while (cin >> n >> m >> h) {
    for (int i = 1; i <= n; ++i) {
      a[i].clear();
      scc[i - 1].clear();
    }
    for (int i = 1; i <= n; ++i) {
      scanf("%d", hh + i);
    }
    for (int i = 0; i < m; ++i) {
      scanf("%d %d", &x, &y);
      if ((hh[y] + 1) % h == hh[x]) {
        a[y].push_back(x);
      }
      if ((hh[x] + 1) % h == hh[y]) {
        a[x].push_back(y);
      }
    }
    memset(vis, 0, sizeof vis);
    memset(sccs, 0, sizeof sccs);
    timer = 0;
    cyc = 0;
    for (int i = 1; i <= n; ++i) {
      if (!vis[i]) dfs(i);
    }
    int mn = n, ans = 0;
    for (int i = 0; i < cyc; ++i) {
      bool l = 1;
      for (int j = 0; j < scc[i].size(); ++j) {
        for (int k = 0; k < a[scc[i][j]].size(); ++k) {
          if (mp[a[scc[i][j]][k]] != i) {
            l = 0;
          }
        }
      }
      if (l) {
        if (scc[i].size() < mn) {
          mn = scc[i].size();
          ans = i;
        }
      }
    }
    cout << mn << endl;
    for (int i = 0; i < scc[ans].size(); ++i) {
      cout << scc[ans][i] << " ";
    }
    cout << endl;
  }
  return 0;
}
