Santa Claus has come with a bag full of presents this year. A group of N kids stand in line, anxious to get their gifts. Santa Claus takes a present from his bag and gives it to the kid who is currently first in line. That kid then goes to the end of the line, unless he already has 4 gifts, in which case, he goes home. This process continues as long as there are presents in the bag and kids in the line.
You are given a String gifts containing the presents in Santa's bag, in the order they are given away. Return a String containing exactly N elements, where the k-th element is a single space separated list of presents received by the k-th kid, in the order he received them. Kid 0 is the first kid in the initial lineup, kid 1 is the second kid, etc.