 # Boolean Program

Q2> Given a boolean expression with following symbols.
Symbols
‘T’ —> true
‘F’ —> false
And following operators filled between symbols
Operators
& —> boolean AND
| —> boolean OR
^ —> boolean XOR
Count the number of ways we can parenthesize the expression so that the value of expression evaluates to true.

For Example:
The expression is “T | T & F ^ T”, it evaluates true
in 4 ways ((T|T)&(F^T)), (T|(T&(F^T))), (((T|T)&F)^T)
and (T|((T&F)^T)).
Return No_of_ways Mod 1003.
Input:
First line contains the test cases T. 1<=T<=500
Each test case have two lines
First is length of string N. 1<=N<=100
Second line is string S (boolean expression).
Output:
No of ways Mod 1003.

Example:
Input:
2
7
T|T&F^T
5
T^F|F
Output:
4
2

I don’t think that order of operation will matter. so basically we have to just calculate number of ways we can put (n/2)*2 brackets in expression. Which I think can be done using dp… working on it…

BTW… from where you are just copy pasting these problems?? Last question that you asked was marked as Q1 and this is Q2. Are you asking us to solve some kind of paper or something… Can you provide some link of this problem before anyone else put more effort in it??