Dilemmas in cooperation areone of the major concerns in game theory. In a publicgoods game, each individual cooperates by paying a cost or defectingwithout paying it, and receives a reward from the group out of the collected cost. Thus, defectingis beneficial for each individual, while cooperation is beneficial for the group. Now, groups (say, countries) consisting of individuals also play games. To study such a multi-level game, we introduce a hierarchical game in which multiple groups compete for limited resources by utilizing the collected cost in each group,where the power to appropriate resources increases with the population of the group. Analyzing this hierarchical game, we found a hierarchical prisoner's dilemma, in which groups choose the defecting policy (say, armament) as a Nash strategy to optimize each group's benefit, while cooperation optimizes the total benefit. On the other hand, for each individual, refusing to pay the cost (say, tax) is a Nash strategy, which turns out to be a cooperation policy for the group, thus leading to a hierarchical dilemma. Here the group reward increases with the group size. However,we find that there exists an optimal group size that maximizes the individual payoff. Furthermore, when the population asymmetry between two groups is large, the smaller group will choose a cooperation policy (say, disarmament) to avoid excessive response from the larger group, and the prisoner's dilemma between the groups is resolved. Accordingly, the relevance of this hierarchical game onpolicy selection in society and the optimal size of human or animal groups arediscussed.