using System; using System.Collections.Generic; using System.Collections; using System.Collections.Specialized; using System.Linq; using System.Text; using System.IO; using System.Reflection; using static System.Math; using System.Numerics; using System.Threading; using System.Runtime.CompilerServices; using System.Diagnostics; //using nint=System.Int32; static class Program{ const int mod=(int)1e9+7; static List[] li; static bool[] b; static int[] h,ans; static int k; static void Main(){ Sc sc=new Sc(); var n=sc.I; var lir=new List<(char,int,int)>(); var lib=new List<(char,int,int)>(); var f=new (char,char,int)[n+1]; for(int i = 0;ib.Item2){return 1;} else if(a.Item2b.Item2){return 1;} else if(a.Item2[n+1]; b=new bool[n+1]; h=new int[n+1]; for(int i=1;i<=n;i++){li[i]=new List();} var g=new int[1000]; for(int i = 0,j=0;i0;i--) {if(!b[i]){Tp(i);}} g=new int[1000]; for(int i = 0;i(int n,Func f){var a=new T[n];for(int i=0;i(int n,Func f){var a=new T[n];for(int i=0;i(int n,Func f){var a=new T[n];for(int i=0;i(int n,Func f){var a=new T[n];for(int i=0;i(){var s=Console.ReadLine().Split();return (Ct(s[0]),Ct(s[1]));} public (T,T,T) Tp3(){var s=Console.ReadLine().Split();return (Ct(s[0]),Ct(s[1]),Ct(s[2]));} private T Ct(string s){return (T)Convert.ChangeType(s,typeof(T));} }