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; static class Program{ const int mod=(int)1e9+7; static List[] li; static List<(int,int)>[] lih; static bool[] b; static int[] h,d,oa; static void Main(){ Sc sc=new Sc(); var s=sc.Ia; int n=s[0],m=n-1; if(n==1){ Console.WriteLine("-1 -1"); return; } li=new List[n+1]; lih=new List<(int,int)>[n+1]; b=new bool[n+1]; h=new int[n+1]; d=new int[n+1]; oa=new int[n+1]; var a=sc.Ia; for(int i=1;i<=n;i++){ li[i]=new List(); lih[i]=new List<(int,int)>(); } for(int i=0;iu.Item1-v.Item1); lih[a].Add((mod,0)); d[a]=p; int z=p==0?1:0; for(int i = 0;iz){ break; } } h[a]=z; 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