#include <bits/stdc++.h>
using namespace std;
const int maxN = 200005;
const int mod = (int)1e9 + 7;
const int inf = (int)1e9;
const int N = 200005;
vector<int> adj[N];
int t[N], mini[N], counter, id[N], scc;
vector<int> s;
vector<int> sol[maxN];
bool valid[maxN];
void dfs(int u) {
  t[u] = mini[u] = ++counter;
  s.push_back(u);
  for (int j = 0; j < adj[u].size(); ++j) {
    int where = adj[u][j];
    if (t[where] == 0) dfs(where);
    if (t[where] != -1) mini[u] = min(mini[u], mini[where]);
  }
  if (mini[u] == t[u]) {
    int v;
    do {
      v = s.back();
      t[v] = -1;
      s.pop_back();
      id[v] = scc;
      sol[scc].push_back(v);
    } while (v != u);
    scc++;
  }
}
vector<int> G[maxN];
set<int> datas[maxN];
int out[maxN];
bool used[maxN];
int main() {
  int n, m, h;
  scanf("%d %d %d", &n, &m, &h);
  for (int i = 0; i < n; ++i) {
    int x;
    scanf("%d", &x);
    datas[x].insert(i);
  }
  while (m--) {
    int x, y;
    scanf("%d %d", &x, &y);
    x--;
    y--;
    G[x].push_back(y);
    G[y].push_back(x);
  }
  memset(valid, true, sizeof valid);
  for (int i = 0; i < h; ++i) {
    if (datas[i].size() == 0) {
      valid[i] = false;
      continue;
    }
    int to = (i + 1) % h;
    for (auto elem : datas[i]) {
      for (int nei : G[elem]) {
        if (datas[to].find(nei) != datas[to].end()) {
          adj[elem].push_back(nei);
        }
      }
    }
  }
  for (int i = 0; i < n; ++i) {
    if (t[i] == 0) {
      dfs(i);
    }
  }
  int who = -1;
  for (int i = 0; i < n; ++i) {
    if (used[id[i]]) {
      continue;
    }
    used[id[i]] = true;
    bool ok = true;
    for (int vertex : sol[id[i]]) {
      for (int nei : adj[vertex]) {
        if (id[nei] != id[i]) {
          ok = false;
        }
      }
    }
    if (ok && (who == -1 || sol[id[i]].size() < sol[who].size())) {
      who = id[i];
    }
  }
  cout << sol[who].size() << endl;
  for (int e : sol[who]) {
    printf("%d ", e + 1);
  }
  return 0;
}
