Sharing Past Exam Notes
Time limit8sMemory limit1024 MB
Find the expected number of subjects student 1 holds after K random edge-sharing events on a friendship graph, modulo 998244353.
- Level
Medium6 of 10
- Topics
- Dynamic programming, Probability, Bit manipulation
- Solved
- No attempts yet
Problem
At the JAG University ICPC department, there are students, numbered from 1 to . There are friendships among them. The -th friendship means that students and are friends and can contact each other.
The department's final exams will cover subjects. Initially, student has the past exam papers for subject . You are student 1. You want to know how many subjects' past exam information you end up with after friends repeatedly share past exams. So you want the expected value after sharing events between friends.
Consider the following event, which happens times in order, independently.
- One of the friendships is chosen at random, and the two students in it contact each other. They then share all the past exam information they have.
- In other words, if the set of subjects one student has is and the other's is , then after the event both students have the set .
After the events, find the expected number of subjects whose past exam papers you (student 1) have, modulo 998244353.
The expected value is always a rational number. It can be proven that under the constraints of this problem, when written as an irreducible fraction , . Therefore, there is a unique integer satisfying and . This is the expected value modulo 998244353. Here, is prime.
Input
The input consists of multiple datasets. The number of datasets is at most 50. Each dataset is given in the following format.
The first line gives , , and . is the number of students, an integer from to . is the number of friendships, an integer from to . is the number of events, an integer from to .
The next lines give the friendships. The -th line gives and , each an integer from to . No friendship connects a student to themselves, so for all . No friendship is given more than once, so for , .
The input ends with a line containing three zeros.
Output
For each dataset, print the answer on one line.