Aamir transfers apples from one larger box to smaller boxes. When the larger box is emptied, apples fill 3 smaller boxes and still 6 apples remained outside. If the number of apples in each smaller box is q, what was the number of apples in the larger box?