using System; using System.Collections; using System.Collections.Generic; class TEST{ static void Main(){ Sol mySol =new Sol(); mySol.Solve(); } } class Sol{ public void Solve(){ int Inf=(int)(1e9); bool[,] canGo=new bool[N,N]; int[][] WF=new int[N][]; for(int i=0;i L=new List(); int now=S; while(now!=G){ L.Add(now); for(int i=0;iint.Parse(e));} static long[] rla(){return Array.ConvertAll(Console.ReadLine().Split(' '),e=>long.Parse(e));} static double[] rda(){return Array.ConvertAll(Console.ReadLine().Split(' '),e=>double.Parse(e));} } class Pair : IComparable { public int Pos; public int Cost; public Pair(int p, int c) { Pos = p; Cost = c; } public int CompareTo(Pair t) { //return this.Cost > t.Cost ? -1 : this.Cost < t.Cost ? 1 : 0; return this.Cost > t.Cost ? 1 : this.Cost < t.Cost ? -1 : 0; } } class SkewHeap where T:IComparable{ public int Count{ get{return cnt;} private set{cnt=value;} } public SkewHeap(){ root=null; this.Count=0; } public void Push(T v){ NodeSH p=new NodeSH(v); root=NodeSH.Meld(root,p); this.Count++; } public void Pop(){ if(root==null)return; root=NodeSH.Meld(root.L,root.R); this.Count--; } public T Top{ get{return root.Val;} } int cnt; NodeSH root; class NodeSH where S : IComparable { public NodeSH L, R; public S Val; public NodeSH(S v){ Val = v; L = null; R = null; } public static NodeSH Meld(NodeSH a, NodeSH b){ if(a == null)return b; if (b == null) return a; if (a.Val.CompareTo(b.Val) > 0) swap(ref a, ref b); a.R = Meld(a.R, b); swap(ref a.L, ref a.R); return a; } static void swap(ref U x, ref U y) { U t = x; x = y; y = t; } } }