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==== header ====
#include <bits/stdc++.h>

#define SZ(x) (int((x).size()))
#define ALL(x) begin(x), end(x)
#define REP(i, n) for (int i = 0; i < int(n); i++)
#define MP make_pair
#define EB emplace_back
#define PB push_back

using namespace std;

using LL = int64_t;
using PII = pair<int, int>;
using VI = vector<int>;

namespace { namespace aimi {

template<class T> void _R(T &x) { cin >> x; }
void _R(int &x) { scanf("%d", &x); }
void _R(int64_t &x) { scanf("%" SCNd64, &x); }
void _R(double &x) { scanf("%lf", &x); }
void _R(char &x) { scanf(" %c", &x); }
void _R(char *x) { scanf("%s", x); }
void R() {}
template<class T, class... U> void R(T &head, U &... tail) { _R(head); R(tail...); }

template<class T> void _W(const T &x) { cout << x; }
void _W(const int &x) { printf("%d", x); }
void _W(const int64_t &x) { printf("%" PRId64, x); }
void _W(const double &x) { printf("%.16f", x); }
void _W(const char &x) { putchar(x); }
void _W(const char *x) { printf("%s", x); }
template<class T> void _W(const vector<T> &x) { for (auto i = begin(x); i != end(x); _W(*i++)) if (i != cbegin(x)) putchar(' '); }
void W() {}
template<class T, class... U> void W(const T &head, const U &... tail) { _W(head); putchar(sizeof...(tail) ? ' ' : '\n'); W(tail...); }

#ifdef LOCAL_TEST
#include "lib/local_test.hpp"
#else
#define dump(...)
#define FILEIO(...)
#endif

template<class T, class F = less<T>> void sort_uniq(vector<T> &v, F f = F()) { sort(begin(v), end(v), f); v.resize(unique(begin(v), end(v)) - begin(v)); }
template<class T> inline T get_bit(T x, int i) { return (x >> i) & 1; }
template<class T> inline bool chkmax(T &a, const T &b) { return b > a ? a = b, true : false; }
template<class T> inline bool chkmin(T &a, const T &b) { return b < a ? a = b, true : false; }
template<class T> using MaxHeap = priority_queue<T>;
template<class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;

// }}}

// {{{ SCC
struct SCC {
    int n;
    vector<vector<int>> e1, e2, scc;
    vector<int> grp, ord;
    void init(int _n) {
        n = _n;
        e1.clear();
        e1.resize(n);
        e2.clear();
        e2.resize(n);
    }
    void add(int a, int b) {
        e1[a].push_back(b);
        e2[b].push_back(a);
    }
    void dfs1(int u) {
        grp[u] = -1;
        for (int v : e1[u]) if (grp[v] == 0) dfs1(v);
        ord.push_back(u);
    }
    void dfs2(int u) {
        grp[u] = scc.size() - 1;
        scc.back().push_back(u);
        for (int v : e2[u]) if (grp[v] == -1) dfs2(v);
    }
    void solve() {
        grp.clear();
        grp.resize(n);
        ord.clear();
        ord.reserve(n);
        for (int i = 0; i < n; i++) if (grp[i] == 0) dfs1(i);
        reverse(ord.begin(), ord.end());
        scc.clear();
        grp.resize(n);
        for (int i : ord) if (grp[i] == -1) {
            scc.emplace_back();
            dfs2(i);
        }
    }
};
// }}}

const int N_MAX = 200005;

int n, m, h;
int s[N_MAX];
int t[N_MAX][2];

SCC scc;
set<int> conn[N_MAX];
int val[N_MAX] = {};
int dp[N_MAX];

int go(int x) {
    if (dp[x] != -1) return dp[x];
    int total = val[x];
    if (total < 0) W(x, val[x]);
    for (int u : conn[x]) {
        //dump(u);
        total += go(u);
    }
    return dp[x] = total;
}

bool vis[N_MAX];
VI sol;

void print(int x) {
    if (x % 2 == 1) sol.PB((x >> 1) + 1);
    for (int u : scc.e1[x]) {
        if (!vis[u >> 1]) {
            vis[u >> 1] = true;
            print(u);
        }
    }
}

void main() {
    R(n, m, h);
    REP(i, n) {
        R(s[i]);
    }
    REP(i, m) {
        R(t[i][0], t[i][1]);
        --t[i][0];
        --t[i][1];
    }
    scc.init(n * 2);
    REP(i, m) {
        int a = t[i][0];
        int b = t[i][1];
        if ((s[a] + 1) % h == s[b]) {
            scc.add(a * 2 + 1, b * 2 + 1);
            scc.add(b * 2, a * 2);
        }
        if (s[a] == (s[b] + 1) % h) {
            scc.add(b * 2 + 1, a * 2 + 1);
            scc.add(a * 2, b * 2);
        }
    }
    scc.solve();
    REP(i, scc.n) {
        for (int j : scc.e1[i]) {
            if (scc.grp[i] != scc.grp[j]) {
                conn[scc.grp[i]].insert(scc.grp[j]);
            }
        }
    }
    REP(i, scc.n) {
        if (i % 2 == 1) ++val[scc.grp[i]];
    }
    memset(dp, -1, sizeof(dp));
    int best = INT_MAX;
    int pos = -1;
    REP(i, n) {
        int cost = go(scc.grp[i * 2 + 1]);
        if (cost < 0) {
            W("-1", i, scc.grp[i * 2 + 1], scc.n);
            return;
        }
        //cerr << i << ": " << cost << endl;
        if (cost < best) {
            best = cost;
            pos = i;
        }
    }
    W(best);
    vis[pos] = true;
    print(pos * 2 + 1);
    W(sol);
}

// {{{ ==== execution ====
}}

int main() { aimi::main(); return 0; }
// }}}
