<PREV Problem:
NEXT>
Solved by 17 users: old1, Rizvanov, tourist, WsemirZ, dan, Chmeli_BSU, zloy_mipt, JohnJones_001, mazahaka, defrager, Jacob, ilyakor, topspin, UdH-WiNGeR, EAA2008, Dest, fetetriste.
 < 
 < 
 < 
 < 
 < 
 < 
 < 
 < 
 < 
 < 

The Landing

Time limit = 2 second(s)

There was a string of simbols "." and "-", but some symbols was missed and changed to "0" symbol. You know resulting string and lenghts of all substrings consisting of symbols "-" given in order from left to right For string "-.---...--" length list will be (1, 3, 2). Your task is to restore maximum amount of missed symbols.

Input

First line contains string from symbols ".", "-", "0", string lenght does not exceed 10000. The second line contains length list.

Output String with maximum symboles restored or word "BEAVERROR" if information is contradictory.

Input#1
.-0.-
2 1

Output#1
.--.-

Input#2
000 
2

Output#2
0-0

Input#3
..
1 
Output#3
BEAVERROR

Author:
First Moscow Individual Programming Championship, 17 October 2004, MIPT

<PREV | Problem set | Search related messages | NEXT>


© acm.mipt DevGroup
The page was generated in 190ms

SW soft NIX
ID = 54.161.108.158