import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStream; import java.util.ArrayDeque; import java.util.Arrays; import java.util.NoSuchElementException; import java.util.Scanner; public class Main { public static void main(String[] args) throws FileNotFoundException { long t = System.currentTimeMillis(); new Main().run(); System.err.println(System.currentTimeMillis() - t); } final long MOD=998244353; void run() { Scanner sc = new Scanner(System.in); int n=sc.nextInt(); int[][] v=new int[n+1][3]; for(int i=0;i