Under construction

Still being built. Things may change

Infection

Time limit1sMemory limit1024 MB

Summary
Given timed contacts that spread infection with probability 1/2, find each employee's infection probability, given that employee k ends up infected.
Level

Medium5 of 10

Topics
Dynamic programming, Bit manipulation, Probability
Solved
No attempts yet

Problem

An emergency happened in one secret organization. In the middle of the working day, one of the employees was hospitalized with symptoms of an extremely dangerous colonavirus infection. Management now wants to know which employees can still be infected, even though their symptoms have not yet appeared.

The organization has nn employees, numbered with integers from 1 to nn. From CCTV recordings, management established when each pair of employees contacted each other. Management also made the following assumptions.

  • At the beginning of the working day, exactly one employee was infected, and each initial state has probability 1/n1/n.
  • If two employees come into contact, and one is infected and the other is not, the healthy employee becomes infected with probability 1/21/2. If both are healthy, or both are infected, nothing happens.
  • An infected employee cannot recover. He remains infected until the end.
  • It is known that employee kk was eventually infected.

The contacts are given in chronological order. Determine the probability that each employee is infected under the assumptions above.

Input

The first line contains three integers nn, kk and mm, the number of employees, the number of the infected employee, and the number of contacts (2≤n≤152 \le n \le 15, 1≤k≤n1 \le k \le n, 1≤m≤501 \le m \le 50).

Each of the following mm lines contains two integers xix_i and yiy_i, the indexes of the employees who took part in the ii-th contact (1≤xi,yi≤n1 \le x_i, y_i \le n, xi≠yix_i \ne y_i).

All contacts are given in chronological order.

Output

Print nn lines. On the ii-th line, print the probability that employee ii is infected as an irreducible fraction a/ba/b.

Examples3

  1. Example 1

    Input
    3 2 1
    1 2
    
    Expected output
    2/3
    1/1
    0/1
    
  2. Example 2

    Input
    3 2 2
    1 2
    2 3
    
    Expected output
    1/2
    1/1
    5/8
    
  3. Example 3

    Input
    4 1 4
    1 2
    2 3
    3 4
    4 1
    
    Expected output
    1/1
    19/37
    17/37
    27/37