Sayadpur City

Bob wants to visit a new country called sayadpur. There are N cities(1, 2, 3….., N) in sayadpur, and they are connected by n-1 undirected roads. You can go from one city to any other city using these roads. Each city except city 1 is directly connected with at most two cities. Bob wants to start his journey from a city and then move to any adjacent city. In his journey, he does not want to visit a city twice. For visiting a city he has to pay a cost. Suppose he visits total “k” cities and the cost of those cities are $a_1,a_2,…. a_k$ . The overall cost will be the bitwise “or” of those costs ($a_1 | a_2 |a_3 |…. | a_k$). You have to find the maximum overall cost.

This is a companion discussion topic for the original entry at