提示: 欢迎访问OurACM平台。
Problem 1661 Correct it

Accept: 117    Submit: 191
Time Limit: 1000 mSec    Memory Limit : 32768 KB

Problem Description

Before every Fuzhou University Monthly Contest. Oaiei will prepare some problems. Before the contest, he should check them and make sure that these problems are correct.
However, there are always some mistakes that he can not find.
Every problem has two states: “A” and “W”, indicating the problem is correct or incorrect respectively.
He has two operations.
  • ”Y”:he corrects a “W” problem that means he changes the state of a problem from “W” to “A”
  • ”N”:he mistakes a “A” problem that means he changes the state of a problem from “A” to “W”
Initially, every problem is in the state of “W”, and after some operations, oaiei wants to know the probability of some problem which is correct.

Input

There are multiple test cases. For each case, the first line are two integers N (1<= N <= 16) and Q(0<=Q<=100), indicating there are N problems and oaiei has Q operations. The problem are numbered from 1 to N. Followed by Q lines, for each line there is a character “Y” or “N”. In the last line, there is an integer P(1<=P<=N) indicating oaiei wants to know the probability of problem P which is correct. We should note that oaiei will choose a problem from these problems in equal probability, and Q operations are given reasonably.

Output

For each test, output the simplest fraction, indicating the probability of problem P which is correct.

Sample Input

5 1 Y 1 5 2 Y Y 1 5 0 1 2 2 Y Y 1

Sample Output

1/5 2/5 0 1

Source

FOJ月赛-2008年10月

Submit  Back  Status  Discuss