human
BigData Inc. is a corporation that has n data centers indexed from 1 to n that are located all over the world. These data centers provide storage for client data (you can figure out that client data is really big!).

Main feature of services offered by BigData Inc. is the access availability guarantee even under the circumstances of any data center having an outage. Such a guarantee is ensured by using the two-way replication. Two-way replication is such an approach for data storage that any piece of data is represented by two identical copies that are stored in two different data centers.

For each of m company clients, let us denote indices of two different data centers storing this client data as ci, 1 and ci, 2.

In order to keep data centers operational and safe, the software running on data center computers is being updated regularly. Release cycle of BigData Inc. is one day meaning that the new version of software is being deployed to the data center computers each day.

Data center software update is a non-trivial long process, that is why there is a special hour-long time frame that is dedicated for data center maintenance. During the maintenance period, data center computers are installing software updates, and thus they may be unavailable. Consider the day to be exactly h hours long. For each data center there is an integer uj (0 ≤ uj ≤ h - 1) defining the index of an hour of day, such that during this hour data center j is unavailable due to maintenance.

Summing up everything above, the condition uci, 1 ≠ uci, 2 should hold for each client, or otherwise his data may be unaccessible while data centers that store it are under maintenance.

Due to occasional timezone change in different cities all over the world, the maintenance time in some of the data centers may change by one hour sometimes. Company should be prepared for such situation, that is why they decided to conduct an experiment, choosing some non-empty subset of data centers, and shifting the maintenance time for them by an hour later...
Solve the task in PYTHON3.

=====
Give me a the Python program you requested?
assistant
#Here is the Python program you requested.

from collections import deque
import sys
input = sys.stdin.readline

n, m, MOD = map(int, input().split())
u = list(map(int, input().split()))
info = [list(map(int, input().split())) for i in range(m)]

graph = [[] for i in range(n)]
rev_graph = [[] for i in range(n)]
set_ = set()
INF = 10 ** 9
for a, b in info:
    a -= 1
    b -= 1
    if (u[a] + 1) % MOD == u[b]:
        if a * INF + b not in set_:
            graph[a].append(b)
            rev_graph[b].append(a)
            set_.add(a * INF + b)
    if (u[b] + 1) % MOD == u[a]:
        if b * INF + a not in set_:
            graph[b].append(a)
            rev_graph[a].append(b)
            set_.add(b * INF + a)

def scc(N, G, RG):
    order = []
    used = [0]*N
    group = [None]*N
    def dfs(s):
        used[s] = 1
        q = deque([s])
        tmp = deque([s])
        while q:
            s = q.pop()
            for t in G[s]:
                if not used[t]:
                    used[t] = 1
                    q.append(t)
                    tmp.append(t)
        while tmp:
            order.append(tmp.pop())
    def rdfs(s, col):
        group[s] = col
        used[s] = 1
        q = deque([s])
        while q:
            s = q.pop()
            for t in RG[s]:
                if not used[t]:
                    q.append(t)
                    used[t] = 1
                    group[t] = col
    for i in range(N):
        if not used[i]:
            dfs(i)
    used = [0]*N
    label = 0
    for s in reversed(order):
        if not used[s]:
            rdfs(s, label)
            label += 1
    return label, group

def construct(N, G, label, group):
    G0 = [set() for i in range(label)]
    GP = [[] for i in range(label)]
    for v in range(N):
        lbs = group[v]
        for w in G[v]:
            lbt = group[w]
            if lbs == lbt:
                continue
            G0[lbs].add(lbt)
        GP[lbs].append(v + 1)
    return G0, GP

min_ans = 10 ** 9
ind_ans = -1
label, group = scc(n, graph, rev_graph)
new_graph, element = construct(n,...