CF960F Pathwalks

Description

You are given a directed graph with $ n $ nodes and $ m $ edges, with all edges having a certain weight. There might be multiple edges and self loops, and the graph can also be disconnected. You need to choose a path (possibly passing through same vertices multiple times) in the graph such that the weights of the edges are in strictly increasing order, and these edges come in the order of input. Among all such paths, you need to find the the path that has the maximum possible number of edges, and report this value. Please note that the edges picked don't have to be consecutive in the input.

Input Format

N/A

Output Format

N/A

Explanation/Hint

The answer for the first sample input is $ 2 $ : ![](https://cdn.luogu.com.cn/upload/vjudge_pic/CF960F/64f1808592d29bd3c0ddf93b30b30da2e43f461a.png). Note that you cannot traverse ![](https://cdn.luogu.com.cn/upload/vjudge_pic/CF960F/701350564a202a853dc0a2e9276e318c9ca164a2.png) because edge ![](https://cdn.luogu.com.cn/upload/vjudge_pic/CF960F/b59064b21bfeab8af7de18849682bc80881d0361.png) appears earlier in the input than the other two edges and hence cannot be picked/traversed after either of the other two edges. In the second sample, it's optimal to pick $ 1 $ -st, $ 3 $ -rd and $ 5 $ -th edges to get the optimal answer: ![](https://cdn.luogu.com.cn/upload/vjudge_pic/CF960F/da8446025ba10d3435163cc331ea49b0612f49e8.png).