Is the graph acyclic? A Directed Acyclic Graph (DAG) is a type of graph that has no cycles in it. In other words, if there is a link from node A to node B, there exists no path from B to A (via any nodes).

Challenge

Determine whether the directed graph given as input is acyclic.

Input

A list of lists of integers representing the links between nodes, where a node is identified by its index in the list.

Output

Standard I/O for decision problems; generally a truthy value for acyclic graphs, and a falsy one for cyclic graphs. Additionally, your program may halt/not halt to indicate truthy and falsy, if you wish.

Test Cases

[[1, 2], [3, 4], [5], [], [6], [6], []]


Represents the following graph (where all edges are directed downwards):

        0
      /   \
     1     2
    / \   /
   3  4  5
      | /
      6


This example is acyclic, so the result should be truthy.



[[1, 3], [2], [0], [1]]


Represents the following graph:

 -----&lt;-----&lt;----
/                \
0 --&gt; 3 --&gt; 1 --&gt; 2
 \----&gt;----/


This example is cyclic, so the result should be falsey. (Sorry for my terrible drawing; if this is unclear let me know.)

Constraints


No input will ever be invalid; i.e. no node will link to a node that does not exist
Self loops must be handled ([[0]] is a cyclic graph)


This is code-golf, so the fewest bytes in each language wins.
Mathematica, 80 44 40 30 22 bytes

#//.x_:&gt;#[[Union@@x]]&amp;


Uses 1-based indexing for input. Returns an empty list iff the graph is acyclic.

Example:

In[1]:= #//.x_:&gt;#[[Union@@x]]&amp;[{{2,3},{4,5},{6},{},{7},{7},{}}]

Out[1]= {}

In[2]:= #//.x_:&gt;#[[Union@@x]]&amp;[{{2,4},{3},{1},{2}}]

Out[2]= {{2, 4}, {3}, {1}, {2}}

In[3]:= #//.x_:&gt;#[[Union@@x]]&amp;[{{1}}]

Out[3]= {{1}}