In order to help (confuse) anyone that is trying to find the rule for assigning the numbers in two groups, I will give the numbers in the groups for n=4 and n=5. So here they go:
The groups are respectively:
For n=4 A (0,3,5,6,9,10,12,15) and B(1,2,4,7,8,11,13,14). The sums of the first, second and third powers of both groups are equal...
For n=5 A (0,3,5,6,9,10,12,15,17,18,20,23,24,27,29,30) and B(1,2,4,7,8,11,13,14,16,19,21,22,25,26,28,31). The sums are equal for all powers <= 4.
One may easily see that all the numbers that were in the A and B groups for n=n1<n2 are again in the A and B groups for n=n2. However, the method by which the numbers are divided in these two groups is not that obvious, though it is quite simple in nature.