using System; using System.Linq; using System.Text; using System.Collections.Generic; public class Hello{ private static int distination; private static int[] answer; private static Town[] towns; private static Road[] roads; private static int pleyNum; public static void Main(){ var line = System.Console.ReadLine().Split(' '); int N = int.Parse(line[0]); int M = int.Parse(line[1]); int Q = int.Parse(line[2]); towns = new Town[N]; for(int i=0;i(),-1,-1); if(answer[1]>=0){ towns[answer[1]].pley.Remove(answer[0]); pleyNum--; } System.Console.WriteLine(answer[0]); answer = new int[2]{-2,-2}; } } } private static void GoHome(int now, List usedRoad, int max, int maxTown){ //現在地の獲物を捕らえる if(towns[now].pley.Count>0){ int tmp = towns[now].pley.Max(); if(max0){ //移動可能な街へ移動する foreach(int road in canMove){ var newUsed = new List(usedRoad); newUsed.Add(road); int next = (roads[road].A==now ? roads[road].B : roads[road].A); GoHome(next,newUsed,max,maxTown); } } return; } } public class Road{ public int A; public int B; } public class Town{ public List pley = new List(); public List neighborhood = new List(); }