output_description: Print 1+K lines, where K is the number of strongly connected components. Print
  K on the first line. Print the information of each strongly connected
  component in next K lines in the following format, where l is the number of
  vertices in the strongly connected component and v_i is the index of the
  vertex in it.
  
      
      
      l v_0 v_1 ... v_{l-1}
      
  
  Here, for each edge (a_i, b_i), b_i should not appear in **earlier** line than
  a_i.
  
  If there are multiple correct output, print any of them.
  
  * * *
input_description: Input is given from Standard Input in the following format:
  
      
      
      N M
      a_0 b_0
      a_1 b_1
      :
      a_{M - 1} b_{M - 1}
attempt: def scc(N, G, RG):
      order = []
      used = [0] * N
      group = [None] * N
  
      def dfs(s):
          used[s] = 1
          for t in G[s]:
              if not used[t]:
                  dfs(t)
          order.append(s)
  
      def rdfs(s, col):
          group[s] = col
          used[s] = 1
          for t in RG[s]:
              if not used[t]:
                  rdfs(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)
      return G0, GP
  
  
  N, M = list(map(int, input().split()))
  G = [[] for i in range(N)]
  RG = [[] for i in range(N)]
  
  for i in range(M):
      A, B = list(map(int, input().split()))
      G[A].append(B)
      RG[B].append(A)
  
  label, group = scc(N, G, RG)
  G0, GP = construct(N, G, label, group)
  print(label)
  for G in GP:
      print(len(G), *G)
  
problem_description: Statement
  
  You are given a directed graph with N vertices and M edges, not necessarily
  simple. The i-th edge is oriented from the vertex a_i to the vertex b_i.
  Divide this graph into strongly connected components and print them in their
  topological order.
samples: [{"input": "6 7\n    1 4\n    5 2\n    3 0\n    5 5\n    4 1\n    0 3\n    4 2", "output": "4\n    1 5\n    2 4 1\n    1 2\n    2 3 0"}]