You are given a positive integer p. Consider an array nums (1-indexed) that consists of the integers in the inclusive range [1, 2p - 1] in their binary representations. You are allowed to do the following operation any number of times:


	Choose two elements x and y from nums.
	Choose a bit in x and swap it with its corresponding bit in y. Corresponding bit refers to the bit that is in the same position in the other integer.


For example, if x = 1101 and y = 0011, after swapping the 2nd bit from the right, we have x = 1111 and y = 0001.

Find the minimum non-zero product of nums after performing the above operation any number of times. Return this product modulo 109 + 7.

Note: The answer should be the minimum product before the modulo operation is done.

&nbsp;
Example 1:

Input: p = 1
Output: 1
Explanation: nums = [1].
There is only one element, so the product equals that element.


Example 2:

Input: p = 2
Output: 6
Explanation: nums = [01, 10, 11].
Any swap would either make the product 0 or stay the same.
Thus, the array product of 1 * 2 * 3 = 6 is already minimized.


Example 3:

Input: p = 3
Output: 1512
Explanation: nums = [001, 010, 011, 100, 101, 110, 111]
- In the first operation we can swap the leftmost bit of the second and fifth elements.
    - The resulting array is [001, 110, 011, 100, 001, 110, 111].
- In the second operation we can swap the middle bit of the third and fourth elements.
    - The resulting array is [001, 110, 001, 110, 001, 110, 111].
The array product is 1 * 6 * 1 * 6 * 1 * 6 * 7 = 1512, which is the minimum possible product.


&nbsp;
Constraints:


	1 &lt;= p &lt;= 60


class Solution:
    def minNonZeroProduct(self, p: int) -> int:
        mod = 10**9+7
        return (pow(2**p-2,2**(p-1)-1,mod)*(2**p-1))%mod
class Solution {
    public int mod = 1_000_000_007;
    public int minNonZeroProduct(int p) {
        if (p == 1) return 1;
        
        long mx = (long)(Math.pow(2, p)) - 1;
        long sm = mx - 1;
        long n = sm/2;
        long sum = rec(sm, n);
        
        return (int)(sum * (mx % mod) % mod); 
    }
    
    public long rec(long val, long n) {
        if (n == 0) return 1;
        if (n == 1) return (val % mod);
        
        long newVal = ((val % mod) * (val % mod)) % mod;
        
        if (n % 2 != 0) {
            return ((rec(newVal, n/2) % mod) * (val % mod)) % mod;
        }
        
        return rec(newVal, n/2) % mod;
    }
}
class Solution {
public:
    long long myPow(long long base, long long exponent, long long mod) {
        if (exponent == 0) return 1;
        if (exponent == 1) return base % mod;
        
        long long tmp = myPow(base, exponent/2, mod);
        
        if (exponent % 2 == 0) { // (base ^ exponent/2) * (base ^ exponent/2)
            return (tmp * tmp) % mod;
        }
        else { // (base ^ exponent/2) * (base ^ exponent/2) * base
            tmp = tmp * tmp % mod;
            base %= mod;
            return (tmp * base) % mod;
        }
    }
    
    int minNonZeroProduct(int p) {
        long long range = pow(2, p);
        range--;
        long long mod = pow(10, 9) + 7;
        long long tmp = myPow(range-1, range/2, mod);
        return (tmp * (range%mod)) % mod;
    }
};
var minNonZeroProduct = function(p) {
    p = BigInt(p);
    
    const MOD = BigInt(1e9 + 7);
    const first = ((1n << p) - 1n);
    
   const half = first / 2n;
    
    const second = powMOD(first - 1n, half); 
    
    return (first * second) % MOD;
    
    function powMOD(num, exp) {
        if (exp === 0n) return 1n; 
        
        const tmp = powMOD(num, exp >> 1n);
        
        let res = (tmp * tmp) % MOD;
        
        if (exp % 2n) res = (res * num) % MOD;
        
        return res;
    }
};  
Minimum Non-Zero Product of the Array Elements