Infection
시간 제한1초메모리 제한1024 MB
시간 순서대로 주어진 접촉 목록에서 직원 k가 감염되었다는 조건 아래 각 직원의 감염 확률을 구한다.
문제
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 employees in the organization, who can be numbered with integers from to . 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 .
- 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 . 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 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 , and --- the number of employees, the number of the infected employee and the number of contacts, respectively (, , ).
The -th of the following lines contains two integers and --- indexes of employees who participated in the -th contact (, ).
All contacts in the list are given in chronological order
출력
Print lines. On the -th line print the probability of infection of the -th employee as an irreducible fraction . See the example for a more precise understanding.