Price of one blue pen = Rs.15
Price of one red pen = Rs.20
In shop A:
Let the number of blue and red pens sold are Ab and Ar respectively. Then,
Then, Ab + Ar = 32...(i)
And 15Ab + 20Ar = 580
3Ab + 4Ar = 116..(ii)
From (ii)  -  3(i), we get
4Ar  -  3Ar = 116  -  3 * 32
Ar = 20
Ab = 32  -  20 = 12
So, selling price of blue pens = 12 * 15 = Rs.180
And selling price of red pens = 20 * 20 = Rs.400
In shop C:
Let the number of blue and red pens sold are Ab and Ar respectively. Then,
Then, Ab + Ar = 20...(iii)
And 15Ab + 20Ar = 370
3Ab + 4Ar = 74..(iv)
From (iv)  -  3(iii), we get
4Ar  -  3Ar = 74  -  3 * 20
Ar = 14
Ab = 20  -  14 = 6
So, selling price of blue pens = 6 * 15 = Rs.90
And selling price of red pens = 14 * 20 = Rs.280
In tabular form:
| Shop | Number of pens | Selling price of (in rupees) | 
| Total | Blue | Red | Total pens | Blue pens | Red pens | 
| A | 32 | 12 | 20 | 580 | 180 | 400 | 
| B |  |  |  |  |  |  | 
| C | 20 | 6 | 14 | 370 | 90 | 280 | 
| D | 28 |  |  |  |  |  | 
| E |  |  |  | 310 |  |  | 
Let the number of blue pens sold by shop D and E are 2x and x respectively.
Let the number of red pens sold by shop D = number of red pens sold by shop E = y
Then, 28 = 2x + y => y = 28  -  2x
And selling price received by shop E = 15 * x + 20 * y = 310
3x + 4y = 62
Now, 3x + 4 * (28  -  2x) = 62
3x + 112  -  8x = 62
5x = 50
x = 10
Then, number of red pens sold from shop D = 28  -  2x = 28  -  2 * 10 = 8