Was practicing DP, had a question on the complexity if question was modified a bit

https://www.codechef.com/problems/COUPON
was the problem i was trying.

this problem considers that alice buys item 1 and only then buys item 2 and so on. my question is, what will be the time complexity if she can buy item 2 first and then item 1.

eg input:
1
3 2
2 2
4 4
7 7
1 1
2 2
5 5

present question would give an answer of 10. but my question would give an answer of 7.