You are given a directed graph of N nodes. Initially there are M directed edges which are given as input (these are unique and self edges are allowed). You can add a new edge (c, a) if the edges (a,b) and (b,c) exist in the graph. Find the total no of edges in the final graph (when you cannot add any more edges)
NOTE: (a,b) & (b,c) => (c,a) and NOT (a,c)
Constraint: N = 100,000, M = 100,000, TimeLimit = 2s