22. The Unfortunate Grocer. A grocer, the owner of a small shop, decided to set aside a small amount of money - all in dollar bills and coins of fifty cents and twenty-five cents. He distributed the entire amount into 8 bags, so that in each bag there was the same number of dollar bills and coins of each denomination. One evening, the grocer decided to redistribute all this money into 7 bags so that the number of dollar bills and coins of each denomination remained equal in all bags. The next evening, he similarly redistributed all the money into 6 bags.

Then the unfortunate madman tried to redistribute everything into 5 bags, but after hours of hard work, he died in complete exhaustion, bitterly mourned by his neighbors. What is the smallest amount of money that the grocer could have set aside for a rainy day?
22. The grocer set aside 168 paper dollars, 168 half-dollar coins, and 168 quarter-dollar coins for a rainy day, totaling 294 dollars. In each of the six bags, there should be 28 monetary units of each type; in each of the seven bags, 24; and in each of the eight bags, 21 monetary units of each type.