257. Debt

time limit per test: 0.25 sec.
memory limit per test: 65536 KB
input: standard
output: standard



Professor Dr. Murzov decided to leave Burland. But before he leaves, he should return all his debts. Professor owes priest Popov P burcrystals, barber Parkin O burcrystals, student Studnev S burcrystals. Making payments using crystals is very simple - one small crystal equals to one burcrystal, one big crystal equals to two burcrystals.
The only problem is that there is no exact criteria to determine whether the crystal big or small. Because of this, Murzov asked all his creditors to estimate all his crystals and to say about each crystal is it big or small. Now professor has a big problem to solve - how to distribute his crystals to repay all his debts. Possibly somebody will get more then he owed, but it does not matter for professor, because he is not going to return to Burland, and crystals have no value in any other place.

Input
The first line contains integer numbers P, O and S (1 <= P,O,S <= 10^5).
The second line contains integer number N - the amount of crystals professor has (1 <= N <= 10^5).
Each of the following N lines contains three letters without spaces. First letter means the estimate of this crystal by Popov, second - by Parkin, third - by Studnev.
Letter 'B' means that the crystal is estimated as big, 'S' means that the crystal estimated as small.

Output
You should output the distribution of crystals - N letters without any delimiters.
Letter 'P' means that the crystal goes to Popov, 'O' - to Parkin, 'S' - to Studnev. If there is no such distributions of crystals that the debt is repaid, output only phrase 'no solution'.

Sample test(s)

Input
3 2 4
6
BBS
SSB
BBB
BBS
SSS
BBS

Output
OSPPSS

Note
Popov will get 4 burcrystals, Parkin - 2, Studnev - 4.
[submit]
[forum]

Author:Andrew V. Lazarev
Resource:Saratov SU Contest: Golden Fall 2004
Date:October 2, 2004











Server time: 2017-09-25 22:43:09Online Contester Team © 2002 - 2016. All rights reserved.