A Math Problem
Time limit1sMemory limit256 MB
Count the fan-to-team assignments for n fans and m teams where the fan sets are closed under pairwise intersection and union, modulo 10^9+7.
- Level
Hard8 of 10
- Topics
- Math, Combinatorics
- Solved
- No attempts yet
Statement
There are fans () and teams ().
(i) Each fan is a fan of at least one team but not a fan of all teams.
(ii) For any two teams (), there is exactly one team () whose set of fans is exactly the set of fans shared by and . , , and may be equal.
(iii) For any two teams (), there is exactly one team () whose set of fans is exactly the set of fans of or . , , and may be equal.
Count the number of ways to assign fans to teams (the correspondences between fans and teams) that satisfy these conditions.
Input
The first line contains an integer (), the number of test cases.
Each test case is a single line with two integers and (, ).
Output
For each test case, print the answer modulo on its own line.