Let the original price X paid be P.
When X sold to Y at 18% profit:
X's selling price =P+0.18P
=1.18P
This is Y's cost price.
When Y sold back to X at 40% profit:
Y's selling price =1.18P+0.40(1.18P)
=1.18P×1.40
=1.652P
Y's profit = Y's selling price − Y's cost price
=1.652P−1.18P
=0.472P
Y's profit is given as ₹118:
0.472P=118
P=0.472118
P=250
Therefore, X originally paid ₹250 for the article.