#include <bits/stdc++.h>
using namespace std;
const int MOD = 1000000007;
const int INF = 0x3f3f3f3f;
const long long LL_INF = 0x3f3f3f3f3f3f3f3f;
const double PI = acos(-1);
const double EPS = 1e-10;
const int N = 100010;
int n, m, h;
vector<int> adjList[2][N];
int color[N];
int low[N], num[N];
stack<int> dfsStack;
vector<vector<int>> comps;
int compIndex[N];
set<int> adjComp[N];
void dfs(int u) {
  static int dfsCounter = 0;
  low[u] = num[u] = ++dfsCounter;
  dfsStack.push(u);
  for (int v : adjList[1][u]) {
    if (num[v]) {
      low[u] = min(low[u], num[v]);
    } else {
      dfs(v);
      low[u] = min(low[u], low[v]);
    }
  }
  if (low[u] >= num[u]) {
    vector<int> newComp;
    int v;
    do {
      v = dfsStack.top();
      dfsStack.pop();
      newComp.push_back(v);
      compIndex[v] = (int)comps.size();
      low[v] = num[v] = INF;
    } while (v != u);
    comps.push_back(newComp);
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cin >> n >> m >> h;
  for (int i = 0; i < n; ++i) {
    cin >> color[i];
  }
  while (m--) {
    int u, v;
    cin >> u >> v;
    adjList[0][u - 1].push_back(v - 1);
    adjList[0][v - 1].push_back(u - 1);
  }
  for (int i = 0; i < n; ++i) {
    for (int j : adjList[0][i]) {
      if ((color[i] + 1) % h == color[j]) {
        adjList[1][i].push_back(j);
      }
    }
  }
  for (int i = 0; i < n; ++i) {
    if (!num[i]) {
      dfs(i);
    }
  }
  for (int i = 0; i < n; ++i) {
    for (int j : adjList[1][i]) {
      if (compIndex[i] != compIndex[j]) {
        adjComp[compIndex[i]].insert(compIndex[j]);
      }
    }
  }
  int res = INF;
  for (int i = 0; i < (int)comps.size(); ++i) {
    if (adjComp[i].empty()) {
      res = min(res, (int)comps[i].size());
    }
  }
  cout << res << '\n';
  for (auto comp : comps) {
    if ((int)comp.size() == res) {
      for (int v : comp) {
        cout << v + 1 << ' ';
      }
      return 0;
    }
  }
}
