Comments

I'm confused about the time complexity. It seems that it's $$$O(N^3)$$$?

I use a wrong algorithm to solve E and got accepted, but got TLE on some simple datas :(

3 3 0
1 2 1
2 2 1
1 3 1