Bytes

Time limit: 3s Memory limit: 256MB Input: Output:

Seeking treasures of immense value to add to his almighty random knapsack, Prosto is travelling around the world. During one of his journeys he found a room filled with chests, each being locked. On every chest there is a boolean formula engraved on it.

The boolean formulas are XOR\text{XOR} sums of multiple clauses, where a clause is the AND\text{AND} sum of some literals, which can be negated.

Alongside the formula on the chest, there is engraved a number kk, which represents the number of distinct literals which can appear in the given formula. The ii-th literal is represented as the ii-th lowercase letter of the english alphabet e.g. the first literal is 'a', the second literal is 'b' and so on.

In order to unlock a chest you need to find the number of ways to assign each literal 00 or 11 such that the given formula evaluates to 11.

Let's say we have a chest with k=3k=3 variables and the following formula: (a AND b) XOR (b AND c) XOR (a AND c)\text{(a AND b) XOR (b AND c) XOR (a AND c)}. If the tuple of literals (a,b,c)(a,b,c) is equal to one of the following tuples: (1,1,0)(1,1,0), (1,0,1)(1,0,1), (0,1,1)(0,1,1), (1,1,1)(1,1,1) then the given expression is 11, so the answer is 44.

Our protagonist promises you glory and 100100 points if you can help him find the keys to some of his chests.

Input

The first line of the input contains TT, the number of chests.

For each chest you are given a number kk representing the number of literals, and a string ss which represents the formula written on the chest.

Output

The output will contain on TT lines the keys of the chests in the order they appear in the input.

Constraints

  • 1T151 \leq T \leq 15
  • 1k141 \leq k \leq 14
  • 1s1051 \leq |s| \leq 10^5
  • For tests worth 2020 points, 1k101 \leq k \leq 10
  • For tests worth 3030 more points, there aren't any negated literals
  • For tests worth another 2020 points, 1k121 \leq k \leq 12
  • The scores from the contest might be different than the scores you get here

Example

stdin

3
4
(c&d)^(!a&b&!c)^(b)
4
(!c)
4
(!c&!d)^(!a&c&!d)^(a&!b&c)

stdout

6
8
8

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