The following table represents all possible paths of dichotomous events at 5 time moments. At each time moment either 1 or -1 event occurs with probabilities $p$ and $q$. Time stops when one observes 3 of either 1 or -1 events. So time can stop after 3, 4 or 5 moments. I am interested in a probability distribution of the number of time moments - $N$.
T1 T2 T3 T4 T5
1: -1 -1 1 1 1
2: -1 1 -1 1 1
3: 1 -1 -1 1 1
4: -1 1 1 -1 1
5: 1 -1 1 -1 1
6: 1 1 -1 -1 1
7: -1 1 1 1
8: 1 -1 1 1
9: 1 1 -1 1
10: 1 1 1
11: 1 1 -1 -1 -1
12: 1 -1 1 -1 -1
13: -1 1 1 -1 -1
14: 1 -1 -1 1 -1
15: -1 1 -1 1 -1
16: -1 -1 1 1 -1
17: 1 -1 -1 -1
18: -1 1 -1 -1
19: -1 -1 1 -1
20: -1 -1 -1
For example, before time starts, the probability of $N = 3$ is $p^3+q^3$ and $P(N=4)=3p^3q+3q^3p$.
I struggle with conditional probabilities at different time moments. For example, what is $P(N=4|T_3,C)$ - probability after time moment 3 with condition that the sum of three events is say -1. Or $P(N=5|T_2,C)$ - probability after time moment 2 with condition that the sum of two events is 0.
I am interested in a formula for $P(N=k|T_j,C_j)$ where $C_j$ is the sum of event outcomes up to time moment $j$. And would also like to see a walk-through example.
What is exact framework or formula for computing such probabilities and what are the answers for these examples?