WEBISL  Web islands
For a given set of web pages, we want to find largest subsets such that from every page in a subset you can follow links to any other page in the same subset.
Input
On the first line, there are two numbers, number of the pages N, and total number of links M. Pages are numbered from 0 up to N1. On lines 2 up to M+1, there are two numbers per line. The first is the source page and the second is the target page of a link.
Output
On N lines there is a component ID for every single page. The componet ID is the smallest page index on the component.
Example
Input: 3 3
0 1
1 0
1 2
Output: 0
0
2
hide comments
mrigank9:
20170502 20:28:44
good question for scc beginners 

deerishi:
20160623 05:20:56
AC ONE GO! Cool application of Strongly connected components. 

kejriwal:
20151222 21:15:54
AC one go.. also 100th :D 

visionvrp:
20150926 04:42:06
AC in one go... hurrray.. :)


ankitrohilla:
20150920 14:50:02
getting WA, someone give tough test case 

Jordan:
20150712 17:37:16
Using STL gave TLE, even with fast input... 

Dipti Singhal:
20150530 09:57:28
need more test cases. getting WA 

ashish jaiswal:
20150321 23:46:33
plz explain with other test case..not able to understand. 

Deepak:
20150301 16:19:42
Got AC with N = 100005 

sanchay:
20150207 00:17:25
Got A.C assuming N < 10^7. 
Added by:  dRak 
Date:  20130304 
Time limit:  1s5s 
Source limit:  50000B 
Memory limit:  1536MB 
Cluster:  Cube (Intel G860) 
Languages:  All except: ASM64 