an electrical grid Berland palace consist 2 grid main reserve Wires palace expensive material sell good ideaeach grid main reserve head node number 1 every node get electricity head node each node reach head node unique path also grid exactly n node spread electricity furtherIn word grid root direct tree n leave root node number 1 each tree independent enumeration node grid connect node gridAlso palace n electrical device each device connect node main grid node reserve grid Devices connect node electricity spread node tree leave each grid leaf connect exactly device in example main grid contain 6 node tree reserve grid contain 4 node low tree there 3 device number color blue it guarantee grid grid n device show way like picture main grid tree wire direct reserve grid low tree wire direct device horizontal row grid number 1 n leave right wire node intersect Formally tree exist depthfirst search node number 1 visit leave order connection device 1 2 dot n firstly node connected device 1 node connect device 2 etcbusinessman want sell remove maximal wire device power grid main reserve in word device exist path head node main grid reserve grid contain node grid