#include <bits/stdc++.h>
using namespace std;
const int maxn = int(1e5) + 100;
struct LINK {
  int id, next;
};
int n, m, now, ti;
int sum, hr;
int u[maxn], c[maxn][2];
int h[maxn];
int dfn[maxn], low[maxn];
LINK t[maxn * 2];
int color[maxn];
int size[maxn];
vector<int> stk;
vector<int> group[maxn];
void read() {
  scanf("%d%d%d", &n, &m, &hr);
  for (int i = 1; i <= n; ++i) scanf("%d", &u[i]);
  for (int i = 1; i <= m; ++i) scanf("%d%d", &c[i][0], &c[i][1]);
}
void join(int u, int v) {
  t[now].id = v;
  t[now].next = h[u];
  h[u] = now++;
}
void build() {
  for (int i = 1; i <= n; ++i) h[i] = -1;
  for (int i = 1; i <= m; ++i) {
    if ((u[c[i][0]] + 1) % hr == u[c[i][1]]) join(c[i][0], c[i][1]);
    if ((u[c[i][1]] + 1) % hr == u[c[i][0]]) join(c[i][1], c[i][0]);
  }
}
void tarjan(int cur) {
  dfn[cur] = low[cur] = ++ti;
  stk.push_back(cur);
  for (int i = h[cur]; i > -1; i = t[i].next) {
    if (dfn[t[i].id] == 0) {
      tarjan(t[i].id);
      low[cur] = min(low[cur], low[t[i].id]);
    } else
      low[cur] = min(low[cur], dfn[t[i].id]);
  }
  if (dfn[cur] == low[cur]) {
    ++sum;
    while (stk.back() != cur) {
      group[sum].push_back(stk.back());
      color[stk.back()] = sum;
      dfn[stk.back()] = n + 1;
      stk.pop_back();
    }
    group[sum].push_back(stk.back());
    color[stk.back()] = sum;
    dfn[stk.back()] = n + 1;
    stk.pop_back();
  }
}
bool check(int nid) {
  for (int i : group[nid])
    for (int j = h[i]; j > -1; j = t[j].next)
      if (color[t[j].id] != nid) return false;
  return true;
}
void solve() {
  for (int i = 1; i <= n; ++i)
    if (dfn[i] == 0) tarjan(i);
  int ans = n + 1;
  int idx = 0;
  for (int i = 1; i <= sum; ++i) {
    if (!check(i)) continue;
    if (ans > group[i].size()) {
      ans = group[i].size();
      idx = i;
    }
  }
  printf("%d\n", ans);
  for (int i : group[idx]) printf("%d ", i);
}
int main() {
  read();
  build();
  solve();
  return 0;
}
