#include <bits/stdc++.h>   using namespace std;   bool debug = 0;   int n, m, k;   int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0};   string direc =  RDLU ;   long long ln, lk, lm;   void etp(bool f = 0) {     puts(f ?  YES  :  NO );     exit(0);   }   void addmod(int &x, int y, int mod = 1000000007) {     assert(y >= 0);     x += y;     if (x >= mod) x -= mod;     assert(x >= 0 && x < mod);   }   void et() {     puts( -1 );     exit(0);   }   long long fastPow(long long x, long long y, int mod = 1000000007) {     long long ans = 1;     while (y > 0) {       if (y & 1) ans = (x * ans) % mod;       x = x * x % mod;       y >>= 1;     }     return ans;   }   long long gcd1(long long x, long long y) {     long long z = y;     while (x % y != 0) {       z = x % y;       x = y;       y = z;     }     return z;   }   int h, u[100005], dp[100005];   vector<int> mp[100005];   set<pair<int, int> > cs;   void add(int x, int y) {     if (cs.count({x, y})) return;     cs.insert({x, y});     mp[x].push_back(y);   }   int dfn[100005], sta[100005], low[100005], color, ii, cnt, belong[100005];   bool ins[100005];   int sz[100005];   void tarjan(int x) {     dfn[x] = low[x] = ++ii;     sta[++cnt] = x;     ins[x] = 1;     for (auto child : mp[x]) {       if (!dfn[child]) {         tarjan(child);         low[x] = min(low[x], low[child]);       } else if (ins[child]) {         low[x] = min(low[x], dfn[child]);       }     }     if (dfn[x] == low[x]) {       ++color;       int t;       do {         t = sta[cnt];         cnt--;         ins[t] = 0;         belong[t] = color;         sz[color]++;       } while (dfn[t] != low[t]);     }   }   bool del[100005];   void fmain(int ID) {     scanf( %d%d%d , &n, &m, &h);     for (int(i) = 1; (i) <= (int)(n); (i)++) {       scanf( %d , u + i);     }     for (int(i) = 1; (i) <= (int)(m); (i)++) {       int x, y;       scanf( %d%d , &x, &y);       if ((u[x] + 1) % h == u[y]) add(x, y);       if ((u[y] + 1) % h == u[x]) add(y, x);     }     for (int(i) = 1; (i) <= (int)(n); (i)++)       if (belong[i] == 0) tarjan(i);     for (auto p : cs) {       int x = belong[p.first], y = belong[p.second];       if (x == y) continue;       del[x] = 1;     }     int ans = -1;     for (int(i) = 1; (i) <= (int)(color); (i)++)       if (!del[i]) {         if (ans == -1 || sz[ans] > sz[i]) ans = i;       }     printf( %d n , sz[ans]);     for (int(i) = 1; (i) <= (int)(n); (i)++)       if (belong[i] == ans) printf( %d  , i);   }   int main() {     int t = 1;     for (int(i) = 1; (i) <= (int)(t); (i)++) {       fmain(i);     }     return 0;   }   