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. 

p=998244353;
int power(int x, int y, int p) 
{ 
    int res = 1;      // Initialize result 
x = x % p;  // Update x if it is more than or 
            // equal to p 

while (y > 0) 
{ 
    // If y is odd, multiply x with result 
    if (y & 1) 
        res = (res*x) % p; 

    // y must be even now 
    y = y>>1; // y = y/2 
    x = (x*x) % p; 
} 
return res; 

} 
// Returns n^(-1) mod p 
int modInverse(int n, int p) 
{ 
    return power(n, p-2, p); 
} 
