MDOLLS - Nested Dolls spoj , how to solve ?

I can’t understand what question wants to say.
help me to understand this problem.

You have to output as minimum number of separate nested dolls as possible like In first test case
20 30 40 50 30 40
You see all the dolls can be fit in one doll that is {20,30} doll in {30,40} in {40,50}. so ans is 1 doll. Similarly in second test case
20 30 10 10 30 20 40 50
{10,10} in {20,30} and{30,20} in {40,50} (or the {20,30} doll can be fitted in {40,50} and {30,20} separate)
so there need to be 2 different nested dolls. so ans is 2
In third test case no dolls can be fitted inside. So ans is 3
In fourth test case {10,10} in {20,30} in {40,50} and {39,51} is separate. so ans is 2.

how LIS will solve this problem ? I can’t figure out/

Sort by height and keep extracting lis until you have no element left the number of times you extract is the ans I think as you would want to put as many dolls as possible in each nested doll