RoAlgo Contest #8 | Beculețe de brad

This was the problem page during the contest. Access the current page here.
Time limit: 0.7s Memory limit: 128MB Input: Output:

Task

Alice Elice thought about giving Bob Glob some Christmas gifts. A gift is a string of Christmas tree lights colored red (R\color{#FF3131}{\text{R}}) or blue (A\color{cyan}{\text{A}}) of length NN. A good gift satisfies MM conditions of the type (i,j)(i, j) which means that bulb ii has a different color than bulb jj.

Unfortunately, Alice Elice is out shopping and doesn't have time to calculate how many different good gifts she can buy for Bob Glob.

Input data

The first line contains TT, representing the number of scenarios. The structure of a scenario is as follows: the first line contains NN and MM, followed by the next MM lines containing two numbers ii and jj.

Output data

For each scenario, output the number requested by Alice on a separate line, modulo 109+710^9 + 7. If there are no such gifts, print the message Doar carbuni.

Constraints and clarifications

  • 1T1021 \leq T \leq 10^2
  • 1N1051 \leq N \leq 10^5
  • 0M1050 \leq M \leq 10^5
  • The sum of the values of NN over all TT scenarios is at most 51065 \cdot 10^6.
  • The sum of the values of MM over all TT scenarios is at most 10610^6.
# Score Constraints
1 25 N,M20N, M \leq 20
2 45 N,M104N, M \leq 10^4
3 30 No additional constraints

Example 1

stdin

1
5 3
1 2
2 3
4 5

stdout

4

Explanation

The 44 good gifts are:
RARRA\color{#FF3131}{\text{R}} \color{cyan}{\text{A}} \color{#FF3131}{\text{R}} \color{#FF3131}{\text{R}} \color{cyan}{\text{A}}
RARAR\color{#FF3131}{\text{R}} \color{cyan}{\text{A}} \color{#FF3131}{\text{R}} \color{cyan}{\text{A}} \color{#FF3131}{\text{R}}
ARARA\color{cyan}{\text{A}} \color{#FF3131}{\text{R}} \color{cyan}{\text{A}} \color{#FF3131}{\text{R}} \color{cyan}{\text{A}}
ARAAR\color{cyan}{\text{A}} \color{#FF3131}{\text{R}} \color{cyan}{\text{A}} \color{cyan}{\text{A}} \color{#FF3131}{\text{R}}

Example 2

stdin

2
5 2
1 2
1 3
3 3
1 2
2 3
3 1

stdout

8
Doar carbuni

Explanation

  • In the first example, the 88 good gifts are:
    RAARA\color{#FF3131}{\text{R}} \color{cyan}{\text{A}} \color{cyan}{\text{A}} \color{#FF3131}{\text{R}} \color{cyan}{\text{A}}
    RAAAR\color{#FF3131}{\text{R}} \color{cyan}{\text{A}} \color{cyan}{\text{A}} \color{cyan}{\text{A}} \color{#FF3131}{\text{R}}
    ARRRA\color{cyan}{\text{A}} \color{#FF3131}{\text{R}} \color{#FF3131}{\text{R}} \color{#FF3131}{\text{R}} \color{cyan}{\text{A}}
    ARRAR\color{cyan}{\text{A}} \color{#FF3131}{\text{R}} \color{#FF3131}{\text{R}} \color{cyan}{\text{A}} \color{#FF3131}{\text{R}}
    RAARR\color{#FF3131}{\text{R}} \color{cyan}{\text{A}} \color{cyan}{\text{A}} \color{#FF3131}{\text{R}} \color{#FF3131}{\text{R}}
    RAAAA\color{#FF3131}{\text{R}} \color{cyan}{\text{A}} \color{cyan}{\text{A}} \color{cyan}{\text{A}} \color{cyan}{\text{A}}
    ARRRR\color{cyan}{\text{A}} \color{#FF3131}{\text{R}} \color{#FF3131}{\text{R}} \color{#FF3131}{\text{R}} \color{#FF3131}{\text{R}}
    ARRAA\color{cyan}{\text{A}} \color{#FF3131}{\text{R}} \color{#FF3131}{\text{R}} \color{cyan}{\text{A}} \color{cyan}{\text{A}}
  • In the second example, it can be demonstrated that there is no solution.

Log in or sign up to be able to send submissions!