Problem #331
Colourful Wand
The sorcerer is crafting a wand for himself that contains 101 pearls in a specific sequence. Each pearl is magically generated and can be either red or blue in color, with an equal probability for each. The power of the wand is the maximum number of consecutive pearls of the same colour. The expected power of the wand is x.
x can be represented as \frac{p}{q} such that \text{gcd}(p,q) = 1. Find (p \cdot q^{-1})\:mod\:1234567891.