Let the cost of onions, wheat, and rice per kg be Rs x, Rs y,and Rs z respectively. Then, the given situation can be represented by a system of equations as:

This system of equations can be written in the form of AX = B, where


Hence, the cost of onions is Rs 5 per kg, the cost of wheat is Rs 8 per kg, and the cost of rice is Rs 8 per kg.