2003' ACM/ICPCѵϰ 5

F: Gridland