RA-ONE had kidnapped a lady and kept it in his castle . G-ONE got to know about this and he went there to save her. He found that in order to save her he needed to cross the bridge. The bridge was very high above the ground level and had had some planks missing. The length of the bridge was L metres. The bridge had some planks missing and were represented by . while planks on the bridge were represented by $.

The problem was that G-ONE could jump only those number of planks which he had practiced for otherwise he need to go and practice 1 day to perfect that steps of jump .

Find how many days it will take G-ONE to cross the bridge. In the input, the Bridge is described as a string **P** of '$'s and '.'s. A '$' represents a plank, while a '.' represents the absence of a plank. The string, when read from left to right, describes the bridge to RA-ONE hideout.

If the days exceed 7 print "cannot save" else print "saved" along with the number of days in which the lady will be saved.

**Input:**

The first line consists of a single integer **T**, the number of testcases.

Each of the next **T** lines consist of the string **P** for that case.

**Output:**

For each case, output whether lady can be saved or not. If yes, then also print the number of days.

**Constraints:**

1 ≤ T ≤ 100

1 ≤ |P| ≤ 1,000,0 (10^{4})

**P** will consist of only the characters $ and .

The first and the last characters of **P** will be $

**Example:
Input:**

4

$$$$.$

$$..$$...$.$

$$$$$$

$$.$..$...$

saved 1

saved 2

saved 0

saved 3

For 2nd test case 1 day is required to practice for 2 dots. Then next time 3 dots are encountered so 1 more day to practice. Then since 1 dot is there one can easily do that because G-ONE has mastered for 3 dots.

If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.

GustavoMéndez | 191 |

VivSisMMM | 182 |

d_Coder00 | 177 |

ajayjadhav35 | 161 |

Astikeysingh | 154 |

Pulkit__Sharma__ | 694 |

Anirban166 | 652 |

abducodes | 562 |

Found_me | 542 |

Sathvik Avasarala | 514 |

blackshadows | 5331 |

Ibrahim Nash | 5219 |

akhayrutdinov | 5111 |

mb1973 | 4929 |

Quandray | 4559 |

Login to report an issue on this page.