For some positive integer $n$, a coin will be ﬂipped $n$ times to obtain a sequence of $n$ heads and tails. For each ﬂip of the coin, there is probability $p$ of obtaining a head and probability $1-p$ of obtaining a tail, where $0<p<1$ is a rational number.
Kim writes all $2^n$ possible sequences of $n$ heads and tails in two columns, with some sequences in the left column and the remaining sequences in the right column. Kim would like the sequence produced by the coin ﬂips to appear in the left column with probability $1/2$.
Determine all pairs $(n,p)$ for which this is possible.