Infection

시간 제한1초메모리 제한1024 MB

요약
시간 순서대로 주어진 접촉 목록에서 직원 k가 감염되었다는 조건 아래 각 직원의 감염 확률을 구한다.
난이도

어려움10점 중 8점

유형
확률, 동적 계획법, 비트 연산
정답자
아직 제출이 없습니다

문제

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. In this regard, the management of the organization wants to establish which employees can still be infected, but the symptoms of the disease have not yet shown themselves.

There are nn employees in the organization, who can be numbered with integers from 11 to nn. From the recordings of CCTV cameras, the organization's management established when which employees contacted each other. In addition, management took into account the following assumptions:

  • At the beginning of the working day, exactly one of the employees was infected, and each of the initial states could happen with a probability of 1/n1/n.
  • If two employees come into contact with each other, and one of them is infected and the other is not, then a healthy employee becomes infected with a probability of 1/21/2. If both employees are healthy, or both are infected, nothing happens.
  • If an employee is infected, he cannot suddenly recover, that is, he remains infected until the end.
  • It is known that the employee numbered kk was eventually infected.

A chronological list of employees' contacts is given. Determine for each employee the probability of being infected according to the assumptions described above.

입력

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, respectively (2≤n≤152 \le n \le 15, 1≤k≤n1 \le k \le n, 1≤m≤501 \le m \le 50).

The ii-th of the following mm lines contains two integers x_ix\_i and y_iy\_i --- indexes of employees who participated in the ii-th contact (1≤x_i,y_i≤n1 \le x\_i, y\_i \le n, x_i≠y_ix\_i \ne y\_i).

All contacts in the list are given in chronological order

출력

Print nn lines. On the ii-th line print the probability of infection of the ii-th employee as an irreducible fraction a/ba/b. See the example for a more precise understanding.

예제3

  1. 예제 1

    입력
    3 2 1
    1 2
    
    예상 출력
    2/3
    1/1
    0/1
    
  2. 예제 2

    입력
    3 2 2
    1 2
    2 3
    
    예상 출력
    1/2
    1/1
    5/8
    
  3. 예제 3

    입력
    4 1 4
    1 2
    2 3
    3 4
    4 1
    
    예상 출력
    1/1
    19/37
    17/37
    27/37