Company: Intuit_11_feb
Difficulty: medium
Prime Allocation Problem Description Hackerland is a country consisting of n cities, structured as a tree graph. Each city is uniquely numbered from 1 to n , and the country is connected by n-1 roads, such that the graph is fully connected and acyclic. The i th road directly connects two cities: edge_from[i] and edge_to[i] . The mathematicians of Hackerland want to assign a unique prime number as an index to each city. The assignment must satisfy the following conditions: Each city must be assigned a unique prime number between 2 and 100 (inclusive). For any two cities directly connected by a road, the sum of their assigned indices must not be a prime number. Your task is to determine the total number of valid ways to allocate indices to all cities such that the above conditions are met. Since the number of valid allocations may be very large, return the result modulo (10 9 + 7). Example 1 Input: n = 2 edge_from = [1] edge_to = [2] Output: 609 Explanation: The graph is a simple edge be