A group of $n$ women and $m$ men have gotten themselves stuck on a desert island. Or, they're the last people left alive after the apocalypse. Whichever scenario you prefer. If they start reproducing, and assuming these people are all completely unrelated, how long will their colony last for if they want to avoid any and all incest, no matter how far removed?

More precisely, the rules are:

1. A person's generation is the maximum of their parents', plus one. The initial population all have generation zero.
2. You can reproduce with (and only with) anyone of the opposite gender with whom you share no common ancestor in the initial population (and a person is considered to be their own ancestor).
3. Ignore the fact that people have a finite lifespan and that pregnancy takes nine months. You can have as many children as you want.
4. You're trying to find the theoretical highest possible number of generations, so it's fine if your strategy requires that the kids come out with specific genders.

Try the case with, say, 1 man and 2 women (or vice versa) to whet your appetite, but the point of the puzzle is to work out the general case. Remember that you don't just need some upper bound, you need a tight upper bound - so you'll probably want to show an explicit strategy attaining that bound, along with a proof that that's the best you can do.

I have already solved this, so I can guarantee there is an elegant solution.