In the beginning,
Kai, Joe, and Alice have 30 marbles each.
After Kai rolls 5,
he receives 5 marbles from Joe and Alice according to the rule. So after kai's roll, Kai has 40 marbles, Joe and Alice have 25 marbles each.
After Joe rolls 2,
he gives 2 marbles to Kai and Alice according to the rule. So after Joe's roll, Kai has 42 (40+2), Alice has 27 (25 + 2) and Joe has 21 (25-4) marbles.
Now, we know that the friends end up with 41, 20, and 29 marbles respectively. So, that means Alice has rolled 1. And as a result, Kai and Joe have to give one marble each to Alice.
At the end, Kai would have 41, Joe would have 20 and Alice will have 29 marbles