Under construction

Still being built. Things may change

XOR Hashing

Interview

Time limit1sMemory limit1024 MB

Summary
Each hash value 0 to 2^N-1 is equally likely for a random point, and the task asks for the chance that M random picks contain two with the same value, modulo 10^9+7.
Level

Medium4 of 10

Topics
Probability, Math, Combinatorics
Solved
No attempts yet

Problem

Every point on a plane whose xx and yy coordinates are integers with 0≤x,y<2N0 \leq x, y < 2^N is assigned the value x⊕yx \oplus y, the XOR of its two coordinates. Mapping data to other data this way is called hashing, and the mapped value is called the hash value.

A point with an assigned value is chosen MM times. Each choice is made with equal probability, and the same point may be chosen more than once. Find the probability that two of the chosen points have the same hash value.

Input

The first line contains integers NN and MM separated by a space. (1≤N≤20;(1 \leq N \leq 20; 1≤M≤109)1 \leq M \leq 10^9)

Output

Let the probability that two chosen points share a hash value be pq\frac{p}{q}, where pp and qq are coprime non-negative integers and q≢0(mod109+7)q\not\equiv 0 \pmod{10^9+7}. Print p×q−1 mod (109+7)p\times q^{-1}\bmod (10^9+7). q−1q^{-1} is the modular multiplicative inverse of qq.

You can prove that the probability is always a rational number.

Examples1

  1. Example 1

    Input
    2 3
    
    Expected output
    625000005