This puzzle is based on a post on math.se.
Assume I have m black shirts and n white shirts. Both shirts have a non-zero durability.
Every day, I pick out a shirt to wear. Once I run out of either color of shirt, I wash all my dirty shirts of both colors and start over. Clean shirts do not get washed. Whenever a shirt gets washed, its durability goes down by one. Immediately after washing, if the durability of a shirt reaches 0, it must be thrown out.
Your task: take in a sequence of two characters of arbitrary length (eg. b b b w b w w b...) representing choices of shirt to wear on that day. Continue execution until either the last black shirt or the last white shirt is thrown out. Once this occurs, stop consuming input and halt execution immediately.
Inputs: number of black shirts, number of white shirts, durability of black shirts, durability of white shirts, arbitrary number of two single characters, your choice (eg. b and w)
Output: the character representing which shirt ran out first. If both shirts run out on the same day, output either both characters, or a third character representing neither of the shirt colors.
This is code golf, so the answer with the fewest bytes wins.