According to the editorial for this problem, the given graph in for this problem is a Directed Acyclic Graph (DAG). If it is a directed acyclic graph, then the answer will always be 1 because we can use the topological ordering. There is no rule which states that A_i < B_i and that means that the graph may have cycles.

Link to problem: here

I wrote this question in the comments of the problem but no one replied so I am asking here.

Could someone please advise me why the given graph is a DAG?