#icpc2013autumna. [icpc2013autumn_a]Broken Audio Signal

[icpc2013autumn_a]Broken Audio Signal

MathJax.Hub.Config({ tex2jax: { inlineMath: [["","",""], ["\\(","\\)"]], processEscapes: true }}); blockquote { font-family: Menlo, Monaco, "Courier New", monospace; color: #333333; display: block; padding: 8.5px; margin: 0 0 9px; font-size: 12px; line-height: 18px; background-color: #f5f5f5; border: 1px solid #ccc; border: 1px solid rgba(0, 0, 0, 0.15); -webkit-border-radius: 4px; -moz-border-radius: 4px; border-radius: 4px; white-space: pre; white-space: pre-wrap; word-break: break-all; word-wrap: break-word; }

Problem Statement

Nathan O. Davis is a student at the department of integrated systems.

Today's agenda in the class is audio signal processing. Nathan was given a lot of homework out. One of the homework was to write a program to process an audio signal. He copied the given audio signal to his USB memory and brought it back to his home.

When he started his homework, he unfortunately dropped the USB memory to the floor. He checked the contents of the USB memory and found that the audio signal data got broken.

There are several characteristics in the audio signal that he copied.

  • The audio signal is a sequence of NN samples.

  • Each sample in the audio signal is numbered from 11 to NN and represented as an integer value.

  • Each value of the odd-numbered sample(s) is strictly smaller than the value(s) of its neighboring sample(s).

  • Each value of the even-numbered sample(s) is strictly larger than the value(s) of its neighboring sample(s).

He got into a panic and asked you for a help. You tried to recover the audio signal from his USB memory but some samples of the audio signal are broken and could not be recovered. Fortunately, you found from the metadata that all the broken samples have the same integer value.

Your task is to write a program, which takes the broken audio signal extracted from his USB memory as its input, to detect whether the audio signal can be recovered uniquely.


Input

The input consists of multiple datasets. The form of each dataset is described below.

NN
a_1a\_{1} a_2a\_{2} ... a_Na\_{N}

The first line of each dataset consists of an integer, N(2leNle1,000)N (2 \\le N \\le 1{,}000). NN denotes the number of samples in the given audio signal. The second line of each dataset consists of NN values separated by spaces. The ii-th value, a_ia\_{i}, is either a character x or an integer between 109-10^9 and 10910^9, inclusive. It represents the ii-th sample of the broken audio signal. If a_ia\_{i} is a character x , it denotes that ii-th sample in the audio signal is broken. Otherwise it denotes the value of the ii-th sample.

The end of input is indicated by a single 00. This is not included in the datasets.

You may assume that the number of the datasets does not exceed 100100.

Output

For each dataset, output the value of the broken samples in one line if the original audio signal can be recovered uniquely. If there are multiple possible values, output ambiguous. If there are no possible values, output none.


Sample Input

5
1 x 2 4 x
2
x x
2
1 2
2
2 1
2
1000000000 x
4
x 2 1 x
0```

### Output for the Sample Input

```plain
3
none
ambiguous
none
ambiguous
none```

* * *

### Source Name

[JAG Practice Contest for ACM-ICPC Asia Regional 2013](http://acm-icpc.aitea.net/index.php?2013%2FPractice%2F%CC%CF%B5%BC%C3%CF%B6%E8%CD%BD%C1%AA)

* * *