How to convert the probability P/Q to P⋅Q−1 where Q is co-prime with mod I was dealing with probability in programming but i was stuck on the final answer part.
Below is statement in which format i have to give the answer
Can you find the probabilities It can be proved that for each of these values, the probability can be expressed as a fraction PQ, where P and Q are integers (P≥0, Q>0) and Q is co-prime with 998,244,353. You should compute P⋅Q−1 modulo 998,244,353 for each of these values. 
Below is probability that can be calculated on paper and 2nd line is for what i have to print can any1 explain how should calculate P.Q-1.
For 1st Input
Calculated Probability = 1/4 
Answer : 748683265
For 2nd Input
Calculated Probability was = 1/16 , 3/16 , 3/16 , 9/16
Answer that was given = 436731905 935854081 811073537 811073537

If anything is unclear then pls comment as iam new to community I am not very good at asking questions.
Thank you for your reply in advance. 

This can be solved using Extended Euclidean Algorithm. You can visit the following link for further info and code solutions:
https://www.geeksforgeeks.org/multiplicative-inverse-under-modulo-m/
Also there is a same question on overflow for this.
