Full Search

Black Square

Inspired by Kazimir Malevich's masterpiece "Black Square", Peter Palevich is planning to create his own version. He prepared a rectangular grid containing m × n white cells arranged in m rows of n cells each.

Peter painted some of the cells black, so that the black cells formed a square of size s × s cells. But later that day Peter became disappointed with his painting and destroyed it, cutting it to horizontal stripes of size 1 × n and burning them in the fireplace.

Next morning Peter changed his mind and decided to restore his painting. He tried to find its remains in the fireplace, and fortunately one of the stripes, namely the k-th from the top, survived the fire.

Now Peter wonders whether it is possible to restore the painting based on this stripe. Help him to do it.


The first line contains four integer numbers: m, n, s and k (1m, n5000, 1smin(m, n), 1km).

The second line contains n characters and describes the k-th line of the painting, '.' stands for a white cell, '*' stands for a black cell.


If the initial painting can be uniquely restored, output "Unique". If there are several paintings that could have been painted by Peter, output "Ambiguous". If there are no possible paintings, output "Impossible".

Time limit 1 second
Memory limit 128 MiB
Input example #1
4 4 1 2
Output example #1
Input example #2
4 4 2 2
Output example #2
Input example #3
4 4 3 2
Output example #3
Source 2011 ACM NEERC, Northern Subregional Contest, St Petersburg, October 29, Problem B