Vera adores poems. All the poems Vera knows are divided into quatrains (groups of four lines) and in each quatrain some lines contain rhymes.Let's consider that all lines in the poems consist of lowercase Latin letters (without spaces). Letters "a", "e", "i", "o", "u" are considered vowels.Two lines rhyme if their suffixes that start from the k-th vowels (counting from the end) match. If a line has less than k vowels, then such line can't rhyme with any other line. For example, if k=1, lines commit and hermit rhyme (the corresponding suffixes equal it), and if k=2, they do not rhyme (ommit≠ermit).Today on a literature lesson Vera learned that quatrains can contain four different schemes of rhymes, namely the following ones (the same letters stand for rhyming lines):   Clerihew (aabb);  Alternating (abab);  Enclosed (abba). If all lines of a quatrain pairwise rhyme, then the quatrain can belong to any rhyme scheme (this situation is represented by aaaa).If all quatrains of a poem belong to the same rhyme scheme, then we can assume that the whole poem belongs to this rhyme scheme. If in each quatrain all lines pairwise rhyme, then the rhyme scheme of the poem is aaaa. Let us note that it doesn't matter whether lines from different quatrains rhyme with each other or not. In other words, it is possible that different quatrains aren't connected by a rhyme.Vera got a long poem as a home task. The girl has to analyse it and find the poem rhyme scheme. Help Vera cope with the task.

The first line contains two integers n and k (1≤n≤2500, 1≤k≤5) — the number of quatrains in the poem and the vowel's number, correspondingly. Next 4n lines contain the poem. Each line is not empty and only consists of small Latin letters. The total length of the lines does not exceed 10^4.
If we assume that the lines are numbered starting from 1, then the first quatrain contains lines number 1, 2, 3, 4; the second one contains lines number 5, 6, 7, 8; and so on.

Print the rhyme scheme of the poem as "aabb", "abab", "abba", "aaaa"; or "NO" if the poem does not belong to any of the above mentioned schemes.

In the last sample both quatrains have rhymes but finding the common scheme is impossible, so the answer is "NO".

2 1
day
may
sun
fun
test
hill
fest
thrill

[{'input': ['1 1\r\nday\r\nmay\r\nsun\r\nfun\r\n'], 'output': ['aabb\r\n']}, {'input': ['1 1\r\nday\r\nmay\r\ngray\r\nway\r\n'], 'output': ['aaaa\r\n']}, {'input': ['2 1\r\na\r\na\r\na\r\na\r\na\r\na\r\ne\r\ne\r\n'], 'output': ['aabb\r\n']}, {'input': ['2 1\r\nday\r\nmay\r\nsun\r\nfun\r\ntest\r\nhill\r\nfest\r\nthrill\r\n'], 'output': ['NO\r\n']}, {'input': ['2 5\r\na\r\na\r\na\r\na\r\na\r\na\r\ne\r\ne\r\n'], 'output': ['NO\r\n']}, {'input': ['1 1\r\nrezwbgy\r\nxakgmv\r\njogezwbgy\r\napezwbgy\r\n'], 'output': ['NO\r\n']}, {'input': ['2 1\r\nnuqfxwrb\r\napqfkw\r\nuqfxwrb\r\nnhcuqfxwrb\r\nogkznwncmt\r\nevf\r\nogkznwncmt\r\nogkznwncmt\r\n'], 'output': ['NO\r\n']}, {'input': ['1 1\r\naawjvkxx\r\nawjvkxx\r\nxawjvkxx\r\nawjvkxx\r\n'], 'output': ['aaaa\r\n']}, {'input': ['2 2\r\nrhcujgxabk\r\nnjgdqpurul\r\nueoedt\r\ncpcfhbyvo\r\nzmfwnieog\r\npkpylassbf\r\nhrfeod\r\ncdwuil\r\n'], 'output': ['NO\r\n']}, {'input': ['2 1\r\nol\r\nol\r\nol\r\nzol\r\nek\r\nek\r\nek\r\nqek\r\n'], 'output': ['aaaa\r\n']}, {'input': ['3 2\r\nexdaoao\r\nrdwunurp\r\ndunurp\r\ntyqzuxao\r\ndupocgsps\r\nzsiravcm\r\nnqiravcm\r\nlnupocgsps\r\niwashk\r\neepkqcykbv\r\nyviwashk\r\neepkqcykbv\r\n'], 'output': ['NO\r\n']}, {'input': ['2 1\r\ndaihacbnhgfts\r\nsqihpntjvczkw\r\nmihpntjvczkw\r\nvyacbnhgfts\r\ntsvovdpqajmgvcj\r\ncexqkwrvctomb\r\njxbomb\r\ngnpajmgvcj\r\n'], 'output': ['abba\r\n']}, {'input': ['3 2\r\netba\r\ntfecetba\r\nzkitbgcuuy\r\nuuy\r\nbuxeoi\r\nmekxoi\r\nblviwoehy\r\niwoehy\r\njyfpaqntiz\r\nqvaqntiz\r\nhciak\r\niak\r\n'], 'output': ['aabb\r\n']}, {'input': ['4 3\r\niixxiojrrdytjcbkvymw\r\nbjqixxiojrrdytjcbkvymw\r\nogjixxiojrrdytjcbkvymw\r\nevixxpfxpgicpg\r\njkotitixiughfhphliuurx\r\ngyubkqtonejprfjzvqxbdpn\r\ndpudxfoqnhekjytbwiuurx\r\noubkqtonejprfjzvqxbdpn\r\npgzaendrxjhsfzjmijv\r\npomuaendrxjhsfzjmijv\r\nafyuyxueaendrxjhsfzjmijv\r\naendrxjhsfzjmijv\r\nyubweicj\r\ntbnsuxqigmxdfnmbipubweicj\r\nfuftydlmoo\r\nmdkuftydlmoo\r\n'], 'output': ['NO\r\n']}, {'input': ['5 2\r\nqurcmcbxyoddgyyccsmb\r\nlsdzsqoa\r\neurcmcbxyoddgyyccsmb\r\noa\r\nutyxmdhcvaclynmstwsx\r\nmkyycelbmkmdrilmbvr\r\nutyxmdhcvaclynmstwsx\r\nrduyelbmkmdrilmbvr\r\nhmguhvqswwciowwgu\r\nnoe\r\nzmyncuwrowwgu\r\nqrhymghavvbmigzsjoe\r\nbvofhknbzusykztlxwms\r\nbpbfmvjaimkdeddy\r\neofhknbzusykztlxwms\r\nmhivpkxkpazimkdeddy\r\negvywnhmfngllaknmn\r\nmblkvhenlggoftwjgk\r\nzegvywnhmfngllaknmn\r\ngrdenlggoftwjgk\r\n'], 'output': ['abab\r\n']}, {'input': ['7 3\r\nferwljzwakxedlgwl\r\noerwljzwakxedlgwl\r\nhyqombizhuhxedprb\r\netptjrizhuhxedprb\r\nurtuckar\r\ndkartmwramklcmi\r\nrurtuckar\r\nnurartmwramklcmi\r\niraziomsv\r\nsaziomsv\r\nbprapiqpayzurgij\r\nusyemayzurgij\r\nztstmeecvmkvuu\r\nquexlecvmkvuu\r\nrlhwecvmkvuu\r\nzecvmkvuu\r\niikymgbncljtub\r\nqiikymgbncljtub\r\nbcavhexqamyszgfya\r\nojexqamyszgfya\r\nieyxqinjinjv\r\nxtiudieyxqinjinjv\r\nthtceyxqinjinjv\r\nmuneyxqinjinjv\r\nwreae\r\nqylcjhjzfhteae\r\nozcjthgyuchqo\r\nfcjozcjthgyuchqo\r\n'], 'output': ['NO\r\n']}, {'input': ['16 1\r\ni\r\ni\r\ni\r\ni\r\ni\r\nu\r\ni\r\ni\r\no\r\na\r\na\r\no\r\na\r\ni\r\na\r\na\r\ni\r\ni\r\no\r\no\r\ni\r\ni\r\ni\r\ni\r\nu\r\nu\r\nu\r\nu\r\no\r\ne\r\ne\r\ne\r\no\r\ni\r\no\r\ni\r\na\r\na\r\na\r\na\r\nu\r\no\r\no\r\nu\r\ni\r\no\r\no\r\ni\r\na\r\na\r\ne\r\ne\r\na\r\na\r\na\r\na\r\na\r\no\r\na\r\na\r\nu\r\na\r\nu\r\nu\r\n'], 'output': ['NO\r\n']}, {'input': ['16 1\r\neb\r\neb\r\nfe\r\nce\r\ner\r\ner\r\new\r\new\r\nu\r\ncu\r\nu\r\nu\r\nud\r\nik\r\nud\r\nik\r\nve\r\niw\r\niw\r\nne\r\nel\r\nob\r\nel\r\nob\r\no\r\neo\r\no\r\nyo\r\nav\r\nav\r\nei\r\nmi\r\nu\r\noh\r\noh\r\nzu\r\niw\r\niw\r\na\r\nma\r\ni\r\nu\r\nku\r\ngi\r\nac\r\no\r\no\r\nac\r\ni\r\ner\r\nai\r\ner\r\nyu\r\nuf\r\nuf\r\nhu\r\nef\r\nef\r\nef\r\nef\r\nmu\r\nu\r\nqe\r\nie\r\n'], 'output': ['NO\r\n']}, {'input': ['25 1\r\nw\r\ni\r\nv\r\nx\r\nh\r\ns\r\nz\r\ny\r\no\r\nn\r\nh\r\ni\r\nf\r\nf\r\ny\r\nr\r\nb\r\nu\r\no\r\np\r\nz\r\nh\r\nt\r\no\r\nw\r\nx\r\nh\r\no\r\nj\r\ny\r\nw\r\nj\r\ny\r\nh\r\nh\r\nr\r\ns\r\nb\r\ny\r\nr\r\nw\r\no\r\nl\r\nl\r\nh\r\nh\r\nw\r\nu\r\na\r\nv\r\no\r\nx\r\nd\r\nw\r\nc\r\nf\r\ni\r\ne\r\nj\r\nq\r\nk\r\na\r\ne\r\nl\r\nw\r\nm\r\nf\r\na\r\nc\r\na\r\nb\r\nf\r\nj\r\nb\r\nx\r\ni\r\nx\r\ne\r\nu\r\nh\r\nm\r\no\r\ni\r\nq\r\nm\r\nk\r\nn\r\nd\r\nl\r\np\r\nc\r\nw\r\nu\r\nz\r\nc\r\nk\r\ng\r\ny\r\nj\r\ny\r\n'], 'output': ['NO\r\n']}, {'input': ['1 1\r\ne\r\ne\r\ne\r\ne\r\n'], 'output': ['aaaa\r\n']}, {'input': ['1 1\r\na\r\ne\r\ne\r\ne\r\n'], 'output': ['NO\r\n']}, {'input': ['1 1\r\ne\r\na\r\ne\r\ne\r\n'], 'output': ['NO\r\n']}, {'input': ['1 1\r\na\r\na\r\ne\r\ne\r\n'], 'output': ['aabb\r\n']}, {'input': ['1 1\r\ne\r\ne\r\na\r\ne\r\n'], 'output': ['NO\r\n']}, {'input': ['1 1\r\na\r\ne\r\na\r\ne\r\n'], 'output': ['abab\r\n']}, {'input': ['1 1\r\ne\r\na\r\na\r\ne\r\n'], 'output': ['abba\r\n']}, {'input': ['1 1\r\na\r\na\r\na\r\ne\r\n'], 'output': ['NO\r\n']}, {'input': ['1 1\r\ne\r\ne\r\ne\r\na\r\n'], 'output': ['NO\r\n']}, {'input': ['1 1\r\na\r\ne\r\ne\r\na\r\n'], 'output': ['abba\r\n']}, {'input': ['1 1\r\ne\r\na\r\ne\r\na\r\n'], 'output': ['abab\r\n']}, {'input': ['1 1\r\na\r\na\r\ne\r\na\r\n'], 'output': ['NO\r\n']}, {'input': ['1 1\r\ne\r\ne\r\na\r\na\r\n'], 'output': ['aabb\r\n']}, {'input': ['1 1\r\na\r\ne\r\na\r\na\r\n'], 'output': ['NO\r\n']}, {'input': ['1 1\r\ne\r\na\r\na\r\na\r\n'], 'output': ['NO\r\n']}, {'input': ['1 1\r\na\r\na\r\na\r\na\r\n'], 'output': ['aaaa\r\n']}, {'input': ['1 2\r\neraub\r\nbee\r\naab\r\nttbee\r\n'], 'output': ['NO\r\n']}, {'input': ['10 1\r\na\r\na\r\na\r\na\r\na\r\na\r\na\r\na\r\na\r\na\r\na\r\na\r\na\r\na\r\na\r\na\r\na\r\na\r\na\r\na\r\na\r\na\r\na\r\na\r\na\r\na\r\na\r\na\r\na\r\na\r\na\r\na\r\na\r\na\r\na\r\na\r\na\r\na\r\na\r\ny\r\n'], 'output': ['NO\r\n']}, {'input': ['1 2\r\neeereaatktb\r\nbee\r\niaattb\r\nottbee\r\n'], 'output': ['NO\r\n']}, {'input': ['1 1\r\nab\r\nac\r\nad\r\naf\r\n'], 'output': ['NO\r\n']}, {'input': ['1 1\r\nar\r\nat\r\nay\r\naw\r\n'], 'output': ['NO\r\n']}, {'input': ['2 1\r\na\r\ne\r\na\r\ne\r\na\r\na\r\na\r\na\r\n'], 'output': ['abab\r\n']}, {'input': ['1 1\r\na\r\ne\r\na\r\ni\r\n'], 'output': ['NO\r\n']}, {'input': ['1 1\r\na\r\ne\r\na\r\ne\r\n'], 'output': ['abab\r\n']}, {'input': ['1 1\r\nabbbbbbbbbbbbbbbbcbbbbbbbbbbbbbbbb\r\nabbbbbbbbbbbbbbbbfbbbbbbbbbbbbbbbb\r\nabbbbbbbbbbbbbbbbxbbbbbbbbbbbbbbbb\r\nabbbbbbbbbbbbbbbbdbbbbbbbbbbbbbbbb\r\n'], 'output': ['NO\r\n']}, {'input': ['2 1\r\na\r\ne\r\ne\r\na\r\na\r\na\r\na\r\na\r\n'], 'output': ['abba\r\n']}, {'input': ['1 1\r\nbug\r\nsuy\r\nluh\r\ngut\r\n'], 'output': ['NO\r\n']}, {'input': ['1 1\r\nam\r\nat\r\nan\r\nag\r\n'], 'output': ['NO\r\n']}, {'input': ['2 1\r\na\r\na\r\ne\r\ne\r\na\r\na\r\na\r\na\r\n'], 'output': ['aabb\r\n']}, {'input': ['1 4\r\naieoabcd\r\naeioabcd\r\naoeiabcd\r\naoieabcd\r\n'], 'output': ['NO\r\n']}, {'input': ['1 2\r\naec\r\naed\r\naek\r\naem\r\n'], 'output': ['NO\r\n']}, {'input': ['1 1\r\nar\r\nab\r\nak\r\naz\r\n'], 'output': ['NO\r\n']}, {'input': ['2 1\r\na\r\na\r\na\r\na\r\na\r\nb\r\nb\r\nb\r\n'], 'output': ['NO\r\n']}]


Little Petya likes to draw. He drew N red and M blue points on the plane in such a way that no three points lie on the same line. Now he wonders what is the number of distinct triangles with vertices in red points which do not contain any blue point inside.

The first line contains two non-negative integer numbers N and M (0≤N≤500, 0≤M≤500) — the number of red and blue points respectively. The following N lines contain two integer numbers each — coordinates of red points. The following M lines contain two integer numbers each — coordinates of blue points. All coordinates do not exceed 10^9 by absolute value.

Output one integer — the number of distinct triangles with vertices in red points which do not contain any blue point inside.

# Read input
my $input = <STDIN>;
chomp $input;
my ($N, $M) = split ' ', $input;

# Read red points
my @red_points;
for (1..$N) {
    my $point = <STDIN>;
    chomp $point;
    my ($x, $y) = split ' ', $point;
    push @red_points, [$x, $y];
}

# Read blue points
my @blue_points;
for (1..$M) {
    my $point = <STDIN>;
    chomp $point;
    my ($x, $y) = split ' ', $point;
    push @blue_points, [$x, $y];
}

# Function to check if a point is inside a triangle
sub is_inside_triangle {
    my ($p, $p1, $p2, $p3) = @_;
    my $d1 = ($p1->[0] - $p->[0]) * ($p2->[1] - $p1->[1]) - ($p2->[0] - $p1->[0]) * ($p1->[1] - $p->[1]);
    my $d2 = ($p2->[0] - $p->[0]) * ($p3->[1] - $p2->[1]) - ($p3->[0] - $p2->[0]) * ($p2->[1] - $p->[1]);
    my $d3 = ($p3->[0] - $p->[0]) * ($p1->[1] - $p3->[1]) - ($p1->[0] - $p3->[0]) * ($p3->[1] - $p->[1]);
    return ($d1 >= 0 && $d2 >= 0 && $d3 >= 0) || ($d1 <= 0 && $d2 <= 0 && $d3 <= 0);
}

# Count the number of distinct triangles
my $count = 0;
for my $i (0..$N-1) {
    for my $j ($i+1..$N-1) {
        for my $k ($j+1..$N-1) {
            my $triangle = [$red_points[$i], $red_points[$j], $red_points[$k]];
            my $is_valid = 1;
            for my $blue_point (@blue_points) {
                if (is_inside_triangle($blue_point, @$triangle)) {
                    $is_valid = 0;
                    last;
                }
            }
            $count++ if $is_valid;
        }
    }
}

# Print the result
print $count;


Gerald is setting the New Year table. The table has the form of a circle; its radius equals R. Gerald invited many guests and is concerned whether the table has enough space for plates for all those guests. Consider all plates to be round and have the same radii that equal r. Each plate must be completely inside the table and must touch the edge of the table. Of course, the plates must not intersect, but they can touch each other. Help Gerald determine whether the table is large enough for n plates.

The first line contains three integers n, R and r (1≤n≤100, 1≤r,R≤1000) — the number of plates, the radius of the table and the plates' radius.

Print "YES" (without the quotes) if it is possible to place n plates on the table by the rules given above. If it is impossible, print "NO".
Remember, that each plate must touch the edge of the table.

The possible arrangement of the plates for the first sample is:

#!/usr/bin/perl

$PI=3.14159265358979323846;
$MOD=1000000007;

while (<>=~/ (\d+) /){

#    <>=~/ /;
#    <>=~/ (\d+) /;
#    <>=~/ (\d+) (\d+) /;

$`-1 or (print ($'>$1?"NO":"YES"));
$`-1 or last;
print (($'+$'/sin($PI/$`)>$1)?"NO":"YES")

}

#***********SUBS************

sub num {$a <=> $b}
sub num_rev {$b <=> $a}
sub rev {$b cmp $a}

sub p{print}
sub n{print "\n"}
sub pn{p,n}
sub pn_mas {pn for @_}

sub fact{
	my $i= shift;   my $j= 1;
	$j*=$i-- while $i;
	return $j
}

# Transpose "charbox"
sub trans{
	my @t=(); my $i=0;
	$i=0, s/./$t[$i++].=$&/eg for @_;
	return @t
}

sub rotL{
	my @t=(); my $i=0; my $j;
	for (@_){
		$i=0, $j=length; $t[$i++].=chop while $j--
	}
	return @t
}

sub rotR{
    my @m=@_;  chomp @m;   my @t=();
	my $i= length $m[0];
	while ($i--){
		$t[$i]=~s/^/chop/e for @m
	}
return @t
}

sub revlines{
	$_=reverse $_ for @_;
	return @_
}

# Transpose "value sets" ## slow?
sub trans_s{
	my @t=(); my $j;
	$j=0, s/\S+/($t[$j++].="$& ")?$&:$&/eg for @_;
	chop @t;
return @t
}

# rotL_s
# rotR_s

# slow?
sub revlines_s{
	$_=join" ", reverse split/\s+/ 	for @_;
	return @_
}

sub div{
    my ($n, $k)=@_;
return ($n - $n % $k) / $k
}

sub uniq{
	my @m=sort @_; my @u;
	push @u, my $i=shift @m;
	$i eq $_ or push @u, $i=$_ for @m;
return @u
}

sub max{
    my $max=shift;
    $max<$_ and $max=$_ for @_;
return $max
}

sub min{
    my $min=shift;
    $min>$_ and $min=$_ for @_;
return $min
}

# count (kas_ieskoma, masyvas)
sub count{
    my $i=0;
    $_ eq $_[0] and $i++ for @_;
return --$i
}


Sherlock Holmes found a mysterious correspondence of two VIPs and made up his mind to read it. But there is a problem! The correspondence turned out to be encrypted. The detective tried really hard to decipher the correspondence, but he couldn't understand anything. At last, after some thought, he thought of something. Let's say there is a word s, consisting of |s| lowercase Latin letters. Then for one operation you can choose a certain position p (1≤p<|s|) and perform one of the following actions:   either replace letter sp with the one that alphabetically follows it and replace letter sp+1 with the one that alphabetically precedes it;  or replace letter sp with the one that alphabetically precedes it and replace letter sp+1 with the one that alphabetically follows it. Let us note that letter "z" doesn't have a defined following letter and letter "a" doesn't have a defined preceding letter. That's why the corresponding changes are not acceptable. If the operation requires performing at least one unacceptable change, then such operation cannot be performed.Two words coincide in their meaning iff one of them can be transformed into the other one as a result of zero or more operations.Sherlock Holmes needs to learn to quickly determine the following for each word: how many words can exist that coincide in their meaning with the given word, but differs from the given word in at least one character? Count this number for him modulo 1000000007 (10^9+7).

The input data contains several tests. The first line contains the only integer t (1≤t≤10^4) — the number of tests.
Next t lines contain the words, one per line. Each word consists of lowercase Latin letters and has length from 1 to 100, inclusive. Lengths of words can differ.

For each word you should print the number of different other words that coincide with it in their meaning — not from the words listed in the input data, but from all possible words. As the sought number can be very large, print its value modulo 1000000007 (10^9+7).

Some explanations about the operation:
  Note that for each letter, we can clearly define the letter that follows it. Letter "b" alphabetically follows letter "a", letter "c" follows letter "b", ..., "z" follows letter "y".  Preceding letters are defined in the similar manner: letter "y" precedes letter "z", ..., "a" precedes letter "b".  Note that the operation never changes a word's length. In the first sample you can obtain the only other word "ba". In the second sample you cannot obtain any other word, so the correct answer is 0.
Consider the third sample. One operation can transform word "klmbfxzb" into word "klmcexzb": we should choose p=4, and replace the fourth letter with the following one ("b" → "c"), and the fifth one — with the preceding one ("f" → "e"). Also, we can obtain many other words from this one. An operation can transform word "ya" only into one other word "xb".
Word "ya" coincides in its meaning with words "xb", "wc", "vd", ..., "ay" (overall there are 24 other words). The word "klmbfxzb has many more variants — there are 3320092814 other words that coincide with in the meaning. So the answer for the first word equals 24 and for the second one equals 320092793 — the number 3320092814 modulo 10^9+7

use strict;
use warnings;

my $MOD = 1000000007;

sub count_coinciding_words {
    my ($word) = @_;
    my $length = length($word);
    my $count = 0;

    # Calculate the number of words that coincide with the given word
    # by considering each possible position for the operation
    for (my $p = 0; $p < $length - 1; $p++) {
        my $letter_p = substr($word, $p, 1);
        my $letter_p_next = substr($word, $p + 1, 1);

        # Calculate the number of words that can be formed by replacing
        # letter p with the letter that follows it and letter p+1 with the
        # letter that precedes it
        my $count_follows = ord('z') - ord($letter_p) + ord($letter_p_next) - ord('a') + 1;

        # Calculate the number of words that can be formed by replacing
        # letter p with the letter that precedes it and letter p+1 with the
        # letter that follows it
        my $count_precedes = ord($letter_p) - ord('a') + ord('z') - ord($letter_p_next) + 1;

        # Add the counts modulo $MOD
        $count = ($count + $count_follows + $count_precedes) % $MOD;
    }

    return $count;
}

# Read the number of tests
my $t = <STDIN>;
chomp($t);

# Process each test case
for (my $i = 0; $i < $t; $i++) {
    # Read the word
    my $word = <STDIN>;
    chomp($word);

    # Calculate the number of coinciding words
    my $coinciding_words = count_coinciding_words($word);

    # Print the result modulo $MOD
    print($coinciding_words % $MOD . "\n");
}


In some country live wizards. They love to ride trolleybuses.A city in this country has a trolleybus depot with n trolleybuses. Every day the trolleybuses leave the depot, one by one and go to the final station. The final station is at a distance of d meters from the depot. We know for the i-th trolleybus that it leaves at the moment of time ti seconds, can go at a speed of no greater than vi meters per second, and accelerate with an acceleration no greater than a meters per second squared. A trolleybus can decelerate as quickly as you want (magic!). It can change its acceleration as fast as you want, as well. Note that the maximum acceleration is the same for all trolleys.Despite the magic the trolleys are still powered by an electric circuit and cannot overtake each other (the wires are to blame, of course). If a trolleybus catches up with another one, they go together one right after the other until they arrive at the final station. Also, the drivers are driving so as to arrive at the final station as quickly as possible.You, as head of the trolleybuses' fans' club, are to determine for each trolley the minimum time by which it can reach the final station. At the time of arrival at the destination station the trolleybus does not necessarily have zero speed. When a trolley is leaving the depot, its speed is considered equal to zero. From the point of view of physics, the trolleybuses can be considered as material points, and also we should ignore the impact on the speed of a trolley bus by everything, except for the acceleration and deceleration provided by the engine.

The first input line contains three space-separated integers n, a, d (1≤n≤10^5, 1≤a,d≤10^6) — the number of trolleybuses, their maximum acceleration and the distance from the depot to the final station, correspondingly.
Next n lines contain pairs of integers ti vi (0≤t1<t2...<tn-1<tn≤10^6, 1≤vi≤10^6) — the time when the i-th trolleybus leaves the depot and its maximum speed, correspondingly. The numbers in the lines are separated by spaces.

For each trolleybus print a single line the time it arrives to the final station. Print the times for the trolleybuses in the order in which the trolleybuses are given in the input. The answer will be accepted if the absolute or relative error doesn't exceed 10^-4.

In the first sample the second trolleybus will catch up with the first one, that will happen at distance 510.5 meters from the depot. The trolleybuses will go the remaining 9489.5 meters together at speed 10 meters per second. As a result, both trolleybuses will arrive to the final station by the moment of time 1000.5 seconds. The third trolleybus will not catch up with them. It will arrive to the final station by the moment of time 11000.05 seconds.

#!/usr/bin/perl

use strict;
use warnings;
use List::Util qw[max];

sub trolley_time {
    my ($n, $a, $d, @trolley_info) = @_;
    my @arrival_times;
    my $prev_time = 0;
    for my $i (0 .. $n-1) {
        my ($t, $v) = @{$trolley_info[$i]};
        my $time_to_reach_v = $v / $a;
        my $dist_to_reach_v = 0.5 * $a * $time_to_reach_v**2;
        my $total_time;
        if ($dist_to_reach_v <= $d) {
            my $remaining_dist = $d - $dist_to_reach_v;
            my $remaining_time = $remaining_dist / $v;
            $total_time = $t + $time_to_reach_v + $remaining_time;
        } else {
            $total_time = $t + sqrt(2*$d/$a);
        }
        $prev_time = max($prev_time, $total_time);
        push @arrival_times, $prev_time;
    }
    return @arrival_times;
}

my $input_line = <STDIN>;
chomp $input_line;
my ($n, $a, $d) = split ' ', $input_line;
my @trolley_info;
for my $i (0 .. $n-1) {
    my $trolley_line = <STDIN>;
    chomp $trolley_line;
    push @trolley_info, [split ' ', $trolley_line];
}
my @arrival_times = trolley_time($n, $a, $d, @trolley_info);
for my $time (@arrival_times) {
    printf("%.10f\n", $time);
}


How to make a cake you'll never eat.Ingredients.   2 carrots  0 calories  100 g chocolate spread  1 pack of flour  1 egg Method.   Put calories into the mixing bowl.  Take carrots from refrigerator.  Chop carrots.  Take chocolate spread from refrigerator.  Put chocolate spread into the mixing bowl.  Combine pack of flour into the mixing bowl.  Fold chocolate spread into the mixing bowl.  Add chocolate spread into the mixing bowl.  Put pack of flour into the mixing bowl.  Add egg into the mixing bowl.  Fold pack of flour into the mixing bowl.  Chop carrots until choped.  Pour contents of the mixing bowl into the baking dish. Serves 1.

The only line of input contains a sequence of integers a0,a1,... (1≤a0≤100, 0≤ai≤1000 for i≥1).


Fibonacci strings are defined as follows:   f1 = «a»  f2 = «b»  fn = fn-1 fn-2, n>2 Thus, the first five Fibonacci strings are: "a", "b", "ba", "bab", "babba".You are given a Fibonacci string and m strings si. For each string si, find the number of times it occurs in the given Fibonacci string as a substring.

The first line contains two space-separated integers k and m — the number of a Fibonacci string and the number of queries, correspondingly.
Next m lines contain strings si that correspond to the queries. It is guaranteed that strings si aren't empty and consist only of characters "a" and "b".
The input limitations for getting 30 points are:
  1≤k≤3000  1≤m≤3000  The total length of strings si doesn't exceed 3000  The input limitations for getting 100 points are:
  1≤k≤10^18  1≤m≤10^4  The total length of strings si doesn't exceed 10^5  Please do not use the %lld specifier to read or write 64-bit integers in С++. It is preferred to use cin, cout streams or the %I64d specifier.

For each string si print the number of times it occurs in the given Fibonacci string as a substring. Since the numbers can be large enough, print them modulo 1000000007 (10^9+7). Print the answers for the strings in the order in which they are given in the input.

use strict;
use warnings;

sub fibonacci_strings {
    my ($k, $m, @queries) = @_;
    my @fibonacci = ('a', 'b');

    for (my $i = 2; $i < $k; $i++) {
        $fibonacci[$i] = $fibonacci[$i-1] . $fibonacci[$i-2];
    }

    my @results;
    foreach my $query (@queries) {
        my $count = 0;
        my $pos = 0;
        while (($pos = index($fibonacci[$k-1], $query, $pos)) != -1) {
            $count++;
            $pos++;
        }
        push @results, $count;
    }

    return @results;
}

# Read input
my $input = <STDIN>;
chomp $input;
my ($k, $m) = split ' ', $input;
my @queries;
for (my $i = 0; $i < $m; $i++) {
    my $query = <STDIN>;
    chomp $query;
    push @queries, $query;
}

# Call the function and print the results
my @output = fibonacci_strings($k, $m, @queries);
foreach my $result (@output) {
    print "$result\n";
}


Vasya is developing his own programming language VPL (Vasya Programming Language). Right now he is busy making the system of exceptions. He thinks that the system of exceptions must function like that.The exceptions are processed by try-catch-blocks. There are two operators that work with the blocks: The try operator. It opens a new try-catch-block.  The catch(<exception_type>, <message>) operator. It closes the try-catch-block that was started last and haven't yet been closed. This block can be activated only via exception of type <exception_type>. When we activate this block, the screen displays the <message>. If at the given moment there is no open try-catch-block, then we can't use the catch operator.The exceptions can occur in the program in only one case: when we use the throw operator. The throw(<exception_type>) operator creates the exception of the given type.Let's suggest that as a result of using some throw operator the program created an exception of type a. In this case a try-catch-block is activated, such that this block's try operator was described in the program earlier than the used throw operator. Also, this block's catch operator was given an exception type a as a parameter and this block's catch operator is described later that the used throw operator. If there are several such try-catch-blocks, then the system activates the block whose catch operator occurs earlier than others. If no try-catch-block was activated, then the screen displays message "Unhandled Exception".To test the system, Vasya wrote a program that contains only try, catch and throw operators, one line contains no more than one operator, the whole program contains exactly one throw operator.Your task is: given a program in VPL, determine, what message will be displayed on the screen.

The first line contains a single integer: n (1≤n≤10^5) the number of lines in the program. Next n lines contain the program in language VPL. Each line contains no more than one operator. It means that input file can contain empty lines and lines, consisting only of spaces.
The program contains only operators try, catch and throw. It is guaranteed that the program is correct. It means that each started try-catch-block was closed, the catch operators aren't used unless there is an open try-catch-block. The program has exactly one throw operator. The program may have spaces at the beginning of a line, at the end of a line, before and after a bracket, a comma or a quote mark.
The exception type is a nonempty string, that consists only of upper and lower case english letters. The length of the string does not exceed 20 symbols. Message is a nonempty string, that consists only of upper and lower case english letters, digits and spaces. Message is surrounded with quote marks. Quote marks shouldn't be printed. The length of the string does not exceed 20 symbols.
Length of any line in the input file does not exceed 50 symbols.

Print the message the screen will show after the given program is executed.

In the first sample there are 2 try-catch-blocks such that try operator is described earlier than throw operator and catch operator is described later than throw operator: try-catch(BE,"BE in line 3") and try-catch(AE,"AE somewhere"). Exception type is AE, so the second block will be activated, because operator catch(AE,"AE somewhere") has exception type AE as parameter and operator catch(BE,"BE in line 3") has exception type BE.
In the second sample there are 2 try-catch-blocks such that try operator is described earlier than throw operator and catch operator is described later than throw operator: try-catch(AE,"AE in line 3") and try-catch(AE,"AE somewhere"). Exception type is AE, so both blocks can be activated, but only the first one will be activated, because operator catch(AE,"AE in line 3") is described earlier than catch(AE,"AE somewhere")
In the third sample there is no blocks that can be activated by an exception of type CE.

8
try
    try
        throw ( AE )
    catch ( BE, "BE in line 3")

    try
    catch(AE, "AE in line 5")
catch(AE,"AE somewhere")

8
try
    try
        throw ( AE )
    catch ( AE, "AE in line 3")

    try
    catch(BE, "BE in line 5")
catch(AE,"AE somewhere")

8
try
    try
        throw ( CE )
    catch ( BE, "BE in line 3")

    try
    catch(AE, "AE in line 5")
catch(AE,"AE somewhere")

AE somewhere
AE in line 3
Unhandled Exception

#!/usr/bin/perl

use 5.006;
use strict;
use warnings;

sub getMessage {
    my $t = shift;
    my $s = $t;
    $s =~ s/^[\w (,]+\"//g;
    $s =~ s/\"[\w) ]+$//g;
    $s =~ s/^[\s]+//g;
    $s =~ s/[\s]+$//g;
    return $s;
}

sub getException {
    my $t = shift;
    my $s = $t;
    $s =~ s/^[\w ]+\(//g;
    $s =~ s/,[\w )\"]+$//g;
    $s =~ s/^[\s]+//g;
    $s =~ s/[\s]+$//g;
    return $s;
}

sub startsWith {
    my $t = shift;
    my $tok = shift;
    my $s = $t;
    $s =~ s/^[\s]+//g;
    return 1 if ($s =~ /^$tok/);
    return 0;
}

sub getThrowExc {
    my $t = shift;
    my $s = $t;
    $s =~ s/^[\w ]+\(//g;
    $s =~ s/[)]//g;
    $s =~ s/^[\s]+//g;
    $s =~ s/[\s]+$//g;
    return $s;
}

sub blank {
    my $t = shift;
    my $s = $t;
    $s =~ s/[\s]+//g;
    return length($s) == 0;
}

my $n = <>;
my $line;
my $level = 0;
my $throwLevel = -1;
my $left = 0;
my $haveAnswer = 0;
my $exc;
while ($line = <>) {
    next if (blank($line));
    if ($throwLevel == -1) {
        if (startsWith($line, "try")) {
            $level++;
            next;
        }
        if (startsWith($line, "catch")) {
            $level--;
            next;
        }
        $exc = getThrowExc($line);
        $throwLevel = $level;
    } else {
        if (startsWith($line, "try")) {
            $left++;
            next;
        }
        my $e = getException($line);
        if ($left == 0 && $exc eq $e) {
            $haveAnswer = 1;
            print getMessage($line);
            last;
        }
        if ($left > 0) {
            $left--;
        }

    }
}

if ($haveAnswer != 1) {
    print "Unhandled Exception";
}

[{'input': ['8\r\ntry\r\n    try\r\n        throw ( AE ) \r\n    catch ( BE, "BE in line 3")\r\n\r\n    try\r\n    catch(AE, "AE in line 5") \r\ncatch(AE,"AE somewhere")\r\n'], 'output': ['AE somewhere\r\n']}, {'input': ['8\r\ntry\r\n    try\r\n        throw ( AE ) \r\n    catch ( AE, "AE in line 3")\r\n\r\n    try\r\n    catch(BE, "BE in line 5") \r\ncatch(AE,"AE somewhere")\r\n'], 'output': ['AE in line 3\r\n']}, {'input': ['8\r\ntry\r\n    try\r\n        throw ( CE ) \r\n    catch ( BE, "BE in line 3")\r\n\r\n    try\r\n    catch(AE, "AE in line 5") \r\ncatch(AE,"AE somewhere")\r\n'], 'output': ['Unhandled Exception\r\n']}, {'input': ['3\r\ntry\r\nthrow(A)\r\ncatch(A, "A cought")\r\n'], 'output': ['A cought\r\n']}, {'input': ['5\r\n try  \r\n try \r\n  catch ( gnAEZNTt,  "i5 tAC8ktUdeX")  \r\n  throw(   gnAEZNTt    ) \r\ncatch  ( gnAEZNTt, "g1cN" )  \r\n'], 'output': ['g1cN\r\n']}, {'input': ['5\r\n try    \r\n catch(UqWpIpGKiMqFnKox ,  "bp9h8dfeNLhk9Wea"  ) \r\nthrow   (   uaBRmgAAQyWTCzaaQMlZ ) \r\n    try    \r\ncatch(  UqWpIpGKiMqFnKox,"0OvVhsVWzDyqwo"  )\r\n'], 'output': ['Unhandled Exception\r\n']}, {'input': ['5\r\n    throw  (    ouB    )    \r\n  try   \r\ncatch(ouB, "bTJZV" )\r\n try    \r\ncatch(  ouB , "DUniE dDhpiN")  \r\n'], 'output': ['Unhandled Exception\r\n']}, {'input': ['5\r\ntry    \r\n throw(    egdCZzrKRLBcqDl   )\r\n catch (  egdCZzrKRLBcqDl  ,"o" )\r\n    try    \r\n  catch (egdCZzrKRLBcqDl  , "oM62EJIirV D0"  ) \r\n'], 'output': ['o\r\n']}, {'input': ['10\r\n  \r\n\r\n \r\n\r\nthrow (ProgramException)\r\n \r\n  \r\n\r\n\r\n \r\n'], 'output': ['Unhandled Exception\r\n']}, {'input': ['21\r\n  try  \r\n  try  \r\n  try  \r\n  try  \r\n  try  \r\n  try  \r\n  try  \r\n  try  \r\n  try  \r\n  try  \r\n  throw(  qtSMze)   \r\ncatch(LY,"x3 j")\r\ncatch(hgSAFgbMGx,"moByu")\r\ncatch(LmydVQgv,"hbZl")\r\ncatch(oK,"B6OZx qy")\r\ncatch(rrtnRQB,"7VFkQMv")\r\ncatch(CASqQXaz,"d9oci1Kx")\r\ncatch(CTCzsdD,"u")\r\ncatch(xqqMxbEs,"Mdu")\r\ncatch(sOWgTPbRp,"fVH6")\r\ncatch(qtSMze,"ZRnNzz")\r\n'], 'output': ['ZRnNzz\r\n']}, {'input': ['3\r\ntry\r\nthrow ( X )\r\ncatch ( X, "try again")\r\n'], 'output': ['try again\r\n']}, {'input': ['3\r\ntry\r\nthrow ( try )\r\ncatch ( try, "try again")\r\n'], 'output': ['try again\r\n']}, {'input': ['3\r\ntry\r\nthrow(tryC)\r\ncatch(tryC, "bad boy")\r\n'], 'output': ['bad boy\r\n']}, {'input': ['7\r\ntry\r\ncatch(A,"try A")\r\ntry\r\n throw(A)\r\ncatch(A,"try B")\r\ntry\r\ncatch(A,"try C")\r\n'], 'output': ['try B\r\n']}, {'input': ['3\r\ntry\r\n throw(try)\r\ncatch(try,"haha")\r\n'], 'output': ['haha\r\n']}, {'input': ['3\r\ntry\r\n throw(try)\r\ncatch(try,"asd")\r\n'], 'output': ['asd\r\n']}, {'input': ['11\r\ntry\r\n  try\r\n  catch (B, "b")\r\n  \r\n  try\r\n    throw ( U )\r\n  catch (U, "try")\r\n  \r\n  try\r\n  catch (C, "c")\r\ncatch (A, "a")\r\n'], 'output': ['try\r\n']}]


As Valeric and Valerko were watching one of the last Euro Championship games in a sports bar, they broke a mug. Of course, the guys paid for it but the barman said that he will let them watch football in his bar only if they help his son complete a programming task. The task goes like that.Let's consider a set of functions of the following form:  Let's define a sum of n functions y1(x),...,yn(x) of the given type as function s(x)=y1(x)+...+yn(x) for any x. It's easy to show that in this case the graph s(x) is a polyline. You are given n functions of the given type, your task is to find the number of angles that do not equal 180 degrees, in the graph s(x), that is the sum of the given functions.Valeric and Valerko really want to watch the next Euro Championship game, so they asked you to help them.

The first line contains integer n (1≤n≤10^5) — the number of functions. Each of the following n lines contains two space-separated integer numbers ki,bi (-10^9≤ki,bi≤10^9) that determine the i-th function.

Print a single number — the number of angles that do not equal 180 degrees in the graph of the polyline that equals the sum of the given functions.

#!/usr/bin/perl

use 5.006;
use strict;
use warnings;

my %hash;

sub gcd {
  my $a = abs (shift);
  my $b = abs (shift);
  while ($b > 0) {
    $b ^= $a ^= $b ^= $a %= $b;
  }
  return $a;
}

my $n = <>;
for(1..$n) {
  my $line = <>;
  my @arr = split(/ /, $line);
  my $k = $arr[0];
  my $b = $arr[1];
  next if (0 == $k);
  my $g = gcd($k, $b);
  $k /= $g;
  $b /= $g;
  if ($k < 0) {
    $k = -$k;
    $b = -$b;
  }
  $hash{($k, $b)} = 1;
}
print "".keys( %hash )."\n";


You've got a rectangular table with length a and width b and the infinite number of plates of radius r. Two players play the following game: they take turns to put the plates on the table so that the plates don't lie on each other (but they can touch each other), and so that any point on any plate is located within the table's border. During the game one cannot move the plates that already lie on the table. The player who cannot make another move loses. Determine which player wins, the one who moves first or the one who moves second, provided that both players play optimally well.

A single line contains three space-separated integers a, b, r (1≤a,b,r≤100) — the table sides and the plates' radius, correspondingly.

If wins the player who moves first, print "First" (without the quotes). Otherwise print "Second" (without the quotes).

In the first sample the table has place for only one plate. The first player puts a plate on the table, the second player can't do that and loses.

In the second sample the table is so small that it doesn't have enough place even for one plate. So the first player loses without making a single move.

$xx = <STDIN> ; @xx = split(" ",$xx) ;
if ($xx[0] < $xx[2] * 2 or $xx[1] < $xx[2] * 2) { print "Second"; }
else { print "First"; }


Consider some square matrix A with side n consisting of zeros and ones. There are n rows numbered from 1 to n from top to bottom and n columns numbered from 1 to n from left to right in this matrix. We'll denote the element of the matrix which is located at the intersection of the i-row and the j-th column as Ai,j.Let's call matrix A clear if no two cells containing ones have a common side.Let's call matrix A symmetrical if it matches the matrices formed from it by a horizontal and/or a vertical reflection. Formally, for each pair (i,j) (1≤i,j≤n) both of the following conditions must be met: Ai,j=An-i+1,j and Ai,j=Ai,n-j+1.Let's define the sharpness of matrix A as the number of ones in it.Given integer x, your task is to find the smallest positive integer n such that there exists a clear symmetrical matrix A with side n and sharpness x.

The only line contains a single integer x (1≤x≤100) — the required sharpness of the matrix.

Print a single number — the sought value of n.

The figure below shows the matrices that correspond to the samples:


The new operating system BerOS has a nice feature. It is possible to use any number of characters '/' as a delimiter in path instead of one traditional '/'. For example, strings //usr///local//nginx/sbin// and /usr/local/nginx///sbin are equivalent. The character '/' (or some sequence of such characters) at the end of the path is required only in case of the path to the root directory, which can be represented as single character '/'.A path called normalized if it contains the smallest possible number of characters '/'.Your task is to transform a given path to the normalized form.

The first line of the input contains only lowercase Latin letters and character '/' — the path to some directory. All paths start with at least one character '/'. The length of the given line is no more than 100 characters, it is not empty.

chomp($line = <>);
$line =~ s/\/+/\//g;
$line =~ s/\/+$//g if (length $line) > 1;
print "$line\n";

[{'input': ['//usr///local//nginx/sbin\r\n'], 'output': ['/usr/local/nginx/sbin\r\n']}, {'input': ['////a//b/////g\r\n'], 'output': ['/a/b/g\r\n']}, {'input': ['/a/b/c\r\n'], 'output': ['/a/b/c\r\n']}, {'input': ['/\r\n'], 'output': ['/\r\n']}, {'input': ['////\r\n'], 'output': ['/\r\n']}, {'input': ['/a//aa/a//\r\n'], 'output': ['/a/aa/a\r\n']}, {'input': ['/aa//b/aa\r\n'], 'output': ['/aa/b/aa\r\n']}, {'input': ['////////////////////////////////////////////////////////////////////////////////////////////////////\r\n'], 'output': ['/\r\n']}, {'input': ['/opt///pokerband///srvb/opt///pokerband///srvb////pokerband///srvb/\r\n'], 'output': ['/opt/pokerband/srvb/opt/pokerband/srvb/pokerband/srvb\r\n']}, {'input': ['/root/pokerband/trunk/server/game/code/src/main/java/com/uosipa/pokerband/gameserver/game/\r\n'], 'output': ['/root/pokerband/trunk/server/game/code/src/main/java/com/uosipa/pokerband/gameserver/game\r\n']}, {'input': ['/root//pokerband/trunk/server/game/code/src///main/java/com/uosipa/pokerband//gameserver/game//\r\n'], 'output': ['/root/pokerband/trunk/server/game/code/src/main/java/com/uosipa/pokerband/gameserver/game\r\n']}, {'input': ['/root//pokerband/trunk/server/game/code/src///main/java/com/uosipa/pokerband//gameserver/game//test/\r\n'], 'output': ['/root/pokerband/trunk/server/game/code/src/main/java/com/uosipa/pokerband/gameserver/game/test\r\n']}, {'input': ['/root//pokerband/trunk/server/game/code/src///main/java/com/uosipa/pokerband//gameserver/game//testt\r\n'], 'output': ['/root/pokerband/trunk/server/game/code/src/main/java/com/uosipa/pokerband/gameserver/game/testt\r\n']}, {'input': ['///a//a////a/a//a//a//a/////\r\n'], 'output': ['/a/a/a/a/a/a/a\r\n']}, {'input': ['/zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\r\n'], 'output': ['/zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\r\n']}, {'input': ['/zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz/\r\n'], 'output': ['/zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\r\n']}, {'input': ['/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a\r\n'], 'output': ['/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a\r\n']}, {'input': ['///////////////////////////////////////////////////////////////////////////////////////////////////z\r\n'], 'output': ['/z\r\n']}, {'input': ['/z//////////////////////////////////////////////////////////////////////////////////////////////////\r\n'], 'output': ['/z\r\n']}]


Jabber ID on the national Berland service «Babber» has a form <username>@<hostname>[/resource], where   <username> — is a sequence of Latin letters (lowercase or uppercase), digits or underscores characters «_», the length of <username> is between 1 and 16, inclusive.  <hostname> — is a sequence of word separated by periods (characters «.»), where each word should contain only characters allowed for <username>, the length of each word is between 1 and 16, inclusive. The length of <hostname> is between 1 and 32, inclusive.  <resource> — is a sequence of Latin letters (lowercase or uppercase), digits or underscores characters «_», the length of <resource> is between 1 and 16, inclusive. The content of square brackets is optional — it can be present or can be absent.There are the samples of correct Jabber IDs: [email protected], [email protected]/contest.Your task is to write program which checks if given string is a correct Jabber ID.

The input contains of a single line. The line has the length between 1 and 100 characters, inclusive. Each characters has ASCII-code between 33 and 127, inclusive.

[{'input': ['mike@codeforces.com\r\n'], 'output': ['YES\r\n']}, {'input': ['john.smith@codeforces.ru/contest.icpc/12\r\n'], 'output': ['NO\r\n']}, {'input': ['test@test.ri/abacaba\r\n'], 'output': ['YES\r\n']}, {'input': ['@ops\r\n'], 'output': ['NO\r\n']}, {'input': ['this-is-the-test\r\n'], 'output': ['NO\r\n']}, {'input': ['mike@codeforces.commike@codeforces.com\r\n'], 'output': ['NO\r\n']}, {'input': ['oooop/oooop\r\n'], 'output': ['NO\r\n']}, {'input': ['w@S8/XU.5._R7fHq.@../e.WP!54Ey1L\x7f.9jv\r\n'], 'output': ['NO\r\n']}, {'input': ['lNC9D1L5U@.L!_!CcAOEEx.0z.aiW/S430sbQT\r\n'], 'output': ['NO\r\n']}, {'input': ['@/YTd.K1@lD\r\n'], 'output': ['NO\r\n']}, {'input': ['Fyi!d1l@.OesGopTnRn.81xdSb8q\x7f./MzuI\r\n'], 'output': ['NO\r\n']}, {'input': ['_TlPy65\x7fw/@.Vl@.8k\r\n'], 'output': ['NO\r\n']}, {'input': ['xpS@._s8.e0l\x7fJci/.LdiT\r\n'], 'output': ['NO\r\n']}, {'input': ['lGwo\x7f8.D2@.3\r\n'], 'output': ['NO\r\n']}, {'input': ['Ccz9T5rKZQuEerGo@6l.\r\n'], 'output': ['NO\r\n']}, {'input': ['Y@5nh@8.9P.Bx5AaY.1g.Tc_MK7.g_..0.\r\n'], 'output': ['NO\r\n']}, {'input': ['Q2/6y!SP9s\x7fG@7zIGr.Du_nR8.\r\n'], 'output': ['NO\r\n']}, {'input': ['eWfLL@gW!BEJUxF\x7fh@dghf.d4.FiYp/2.Pr7a/5O6zXdAkikjCEDrb\r\n'], 'output': ['NO\r\n']}, {'input': ['8oI/\x7fa@Q\r\n'], 'output': ['NO\r\n']}, {'input': ['J@Y9Gz550l@\x7fPqVZdQ!u\r\n'], 'output': ['NO\r\n']}, {'input': ['VTE6aTTta@DHe4xeG@6.c2R.J.O7sndWEEW.9j@.l..3Bs\r\n'], 'output': ['NO\r\n']}, {'input': ['aeo2XkK@UX.nQJN!Tg..wGN5YOi68U.oP2Yl3/\r\n'], 'output': ['NO\r\n']}, {'input': ['m13zREg8LbPr@T2.Z9@g.9u.v.A..XNH/1/tloIceXydZf3\r\n'], 'output': ['NO\r\n']}, {'input': ['4@@..f3ZT./oUGZ@\r\n'], 'output': ['NO\r\n']}, {'input': ['G.rVAxwDx@a.PVSe!KtpX4tzs/0yQGzZCPJPJoda\r\n'], 'output': ['NO\r\n']}, {'input': ['SV9T5RR425Sl0b@kzj.XT.PFWc..ho/VE7gjf\r\n'], 'output': ['NO\r\n']}, {'input': ['bgko@1../xwSj_\x7fJ\r\n'], 'output': ['NO\r\n']}, {'input': ['n5ymLC.bE@ukio.im2../.\r\n'], 'output': ['NO\r\n']}, {'input': ['zr.KB_6ZMSwI2GA5@R/4iP1ZKHpszW!YN/\r\n'], 'output': ['NO\r\n']}, {'input': ['@alK@pR\r\n'], 'output': ['NO\r\n']}, {'input': ['al_Y2I4IKp@A_N.\x7fruCw0VL/hRzJtx.S7sp/r!c.n9ffh\r\n'], 'output': ['NO\r\n']}, {'input': ['C1rE26_rTAVzLm@6@X5OGX.ibJ9./kkBEVlcU\r\n'], 'output': ['NO\r\n']}, {'input': ['feGSXP@eyUfr\x7f8.x4Re.JL.6B.r/fX_\r\n'], 'output': ['NO\r\n']}, {'input': ['Ht15T@50eo.E@.\r\n'], 'output': ['NO\r\n']}, {'input': ['k9MITs_Ar.JL2RRs4@VRq.wCuJ.6..amF.fE4.5I.6fJ7gz7\r\n'], 'output': ['NO\r\n']}, {'input': ['Mi\x7fWPE8@fc./IViqq4T4PSUuMdhH\r\n'], 'output': ['NO\r\n']}, {'input': ['pxSCmv!NbMvz2@pTQ.t!.Ntz/QEh_sl\r\n'], 'output': ['NO\r\n']}, {'input': ['s@mH@RO\x7f_/iWD\r\n'], 'output': ['NO\r\n']}, {'input': ['UP51i49wX@pvx@2LWm8w/G4M3J./9L6Szy\r\n'], 'output': ['NO\r\n']}, {'input': ['xC_5Vx8NgF..\x7fln@X1.drRTX..1vx.Xb3of@/PQYPeq@_y8!h_iF\r\n'], 'output': ['NO\r\n']}, {'input': ['qG3@LKp\r\n'], 'output': ['YES\r\n']}, {'input': ['flTq1knyb@2!Mtfss\r\n'], 'output': ['NO\r\n']}, {'input': ['/pqi7WXQPJFM4q1@hxUyUy\x7f/_pWo0n\r\n'], 'output': ['NO\r\n']}, {'input': ['zXme@.Dq.TWBs.fB.M\r\n'], 'output': ['NO\r\n']}, {'input': ['o3EaAnc3K6@h\r\n'], 'output': ['YES\r\n']}, {'input': ['G/AZdVMTzRLV4Ucm@eQ!..pq!..tRTi5.Ejkqa/HGpFYk\r\n'], 'output': ['NO\r\n']}, {'input': ['.c_V@L.1v!AFAEk7glM\x7fq.ag8Sy8@0.Qm/OLKoJpZlac\r\n'], 'output': ['NO\r\n']}, {'input': ['WKxNIM79u\x7f@I.RM\r\n'], 'output': ['NO\r\n']}, {'input': ['POTjlYcxAZsbyZPDh@sPm.z6aVaO.H1wEUhD9YvROQFUk/M_jTHS_6!\r\n'], 'output': ['NO\r\n']}, {'input': ['pbRIiuA@KZ2hVed2fMikA.@ebd.tE2Y\r\n'], 'output': ['NO\r\n']}, {'input': ['OlS_OwxYhH@im.0A7o/juNlxB\r\n'], 'output': ['YES\r\n']}, {'input': ['xkjHHDRBEFwgNP@G9TGStEs2Lu.BJge3EBXw3c9EfE\r\n'], 'output': ['YES\r\n']}, {'input': ['bK@8X7tQO.pXBHJpDewD\r\n'], 'output': ['YES\r\n']}, {'input': ['kKUXy6@0WefbXz39ywP.Q3r7uF\r\n'], 'output': ['YES\r\n']}, {'input': ['SllbRLdZ6@.T.E3x.BE2nIv.5db_.38./zgVGNjpldr\r\n'], 'output': ['NO\r\n']}, {'input': ['4lBJkY8c097oa@ZYmVbtiyyYN.gbj\r\n'], 'output': ['YES\r\n']}, {'input': ['F@JX4.SI1/0EY3XmYatfY\r\n'], 'output': ['YES\r\n']}, {'input': ['oLo01@B77Pu.9R.vtAZG0.HQSunv0J.\r\n'], 'output': ['NO\r\n']}, {'input': ['xLEctap0T@22U9W_fA/7iQeJGFu1lSgMZ\r\n'], 'output': ['YES\r\n']}, {'input': ['WYh@yUWfOQiF.gOK9k8aEa\r\n'], 'output': ['YES\r\n']}, {'input': ['BPxNVANhtEh@Oh_go.\r\n'], 'output': ['NO\r\n']}, {'input': ['mGIY@cHRNC8GlJ/2pcl3LYxpi3PaKGs\r\n'], 'output': ['YES\r\n']}, {'input': ['x6yfn7BGwqWd@.N/UXC\r\n'], 'output': ['NO\r\n']}, {'input': ['cUIr@cP.eGQC2xJXvI1X7\r\n'], 'output': ['YES\r\n']}, {'input': ['MLZ6e1vgZ4hOI@ktWk.Ro.o6C4/i8cnKHT\r\n'], 'output': ['YES\r\n']}, {'input': ['XCJIa@jFaP.Eu28YaoT9Z.Epk.Z/4TBzLWf724zE1r\r\n'], 'output': ['YES\r\n']}, {'input': ['Cz1U1xjg6iW0U@.97HoVA.YG.Qd.eI.DCXxtibi6HG.GV/0sN\r\n'], 'output': ['NO\r\n']}, {'input': ['nrKbWV@P0irxQoRxDsNvG/69WxCwCsfB\r\n'], 'output': ['YES\r\n']}, {'input': ['yI1nRv3FbuhgaI@.Y9vKe.8oc.BLi.6JfYT/tT5d36\r\n'], 'output': ['NO\r\n']}, {'input': ['IGsma3L6YTJRrXS@1g.yR3mC.c.xoCns7Wo1.9C.Oe.5ebkR/_97Ltj3\r\n'], 'output': ['YES\r\n']}, {'input': ['Uu538LDu9Bye@Gu0W0P5a.b9zA9nSaNhzB_TQ2.z/qfi5CZrH\r\n'], 'output': ['YES\r\n']}, {'input': ['bdHl525me@XzR_iO23v.YFXbnHUybbgw.i/WVEhm\r\n'], 'output': ['YES\r\n']}, {'input': ['NQsZ0K@eE8VMB.w2nYtKImB.4nUF\r\n'], 'output': ['YES\r\n']}, {'input': ['186@E.MmBaKLj.WYpt4wPZkzv93\r\n'], 'output': ['YES\r\n']}, {'input': ['hmhYxkGtWYRJFtBU@Drg3L7WKujE.lU61Ljqxv./FJ4X\r\n'], 'output': ['NO\r\n']}, {'input': ['t1RIUz9l3FA15@tOL9.rv.NjhouD.\r\n'], 'output': ['NO\r\n']}, {'input': ['_I4ytjyccT@q.WIc.Cqn\r\n'], 'output': ['YES\r\n']}, {'input': ['LwHHRYq@whOoq.e9b6i0xnoWBl7z.SGJiJe/iUij1x7\r\n'], 'output': ['YES\r\n']}, {'input': ['Yesx@9_KiJq2cBI6.\r\n'], 'output': ['NO\r\n']}, {'input': ['Zu5VFUtSbIw@ner5e\r\n'], 'output': ['YES\r\n']}, {'input': ['test@test.\r\n'], 'output': ['NO\r\n']}, {'input': ['test@.test\r\n'], 'output': ['NO\r\n']}, {'input': ['est.@test\r\n'], 'output': ['NO\r\n']}, {'input': ['test@test.ru/\r\n'], 'output': ['NO\r\n']}, {'input': ['asd@asd@\r\n'], 'output': ['NO\r\n']}, {'input': ['@\r\n'], 'output': ['NO\r\n']}, {'input': ['/\r\n'], 'output': ['NO\r\n']}, {'input': ['.\r\n'], 'output': ['NO\r\n']}, {'input': ['mike@\r\n'], 'output': ['NO\r\n']}, {'input': ['@mike\r\n'], 'output': ['NO\r\n']}, {'input': ['@mail.ru\r\n'], 'output': ['NO\r\n']}, {'input': ['test.me\r\n'], 'output': ['NO\r\n']}, {'input': ['$@ru\r\n'], 'output': ['NO\r\n']}, {'input': ['testme@o.o.o.o.o/ooooo\r\n'], 'output': ['YES\r\n']}, {'input': ['oooop/oooop\r\n'], 'output': ['NO\r\n']}, {'input': ['mail.ru/a\r\n'], 'output': ['NO\r\n']}, {'input': ['mike@mail.ru/aaa\r\n'], 'output': ['YES\r\n']}, {'input': ['mike@mike.mike\r\n'], 'output': ['YES\r\n']}]


One day Vasya was going home when he saw a box lying on the road. The box can be represented as a rectangular parallelepiped. Vasya needed no time to realize that the box is special, as all its edges are parallel to the coordinate axes, one of its vertices is at point (0,0,0), and the opposite one is at point (x1,y1,z1). The six faces of the box contain some numbers a1,a2,...,a6, exactly one number right in the center of each face. The numbers are located on the box like that:   number a1 is written on the face that lies on the ZOX plane;  a2 is written on the face, parallel to the plane from the previous point;  a3 is written on the face that lies on the XOY plane;  a4 is written on the face, parallel to the plane from the previous point;  a5 is written on the face that lies on the YOZ plane;  a6 is written on the face, parallel to the plane from the previous point. At the moment Vasya is looking at the box from point (x,y,z). Find the sum of numbers that Vasya sees. Note that all faces of the box are not transparent and Vasya can't see the numbers through the box. The picture contains transparent faces just to make it easier to perceive. You can consider that if Vasya is looking from point, lying on the plane of some face, than he can not see the number that is written on this face. It is enough to see the center of a face to see the corresponding number for Vasya. Also note that Vasya always reads correctly the ai numbers that he sees, independently of their rotation, angle and other factors (that is, for example, if Vasya sees some ai=6, then he can't mistake this number for 9 and so on).

The fist input line contains three space-separated integers x, y and z (|x|,|y|,|z|≤10^6) — the coordinates of Vasya's position in space. The second line contains three space-separated integers x1, y1, z1 (1≤x1,y1,z1≤10^6) — the coordinates of the box's vertex that is opposite to the vertex at point (0,0,0). The third line contains six space-separated integers a1,a2,...,a6 (1≤ai≤10^6) — the numbers that are written on the box faces.
It is guaranteed that point (x,y,z) is located strictly outside the box.

Print a single integer — the sum of all numbers on the box faces that Vasya sees.

The first sample corresponds to perspective, depicted on the picture. Vasya sees numbers a2 (on the top face that is the darkest), a6 (on the right face that is the lightest) and a4 (on the left visible face).
In the second sample Vasya can only see number a4.


Bike loves looking for the second maximum element in the sequence. The second maximum element in the sequence of distinct numbers x1,x2,...,xk (k>1) is such maximum element xj, that the following inequality holds: .The lucky number of the sequence of distinct positive integers x1,x2,...,xk (k>1) is the number that is equal to the bitwise excluding OR of the maximum element of the sequence and the second maximum element of the sequence.You've got a sequence of distinct positive integers s1,s2,...,sn (n>1). Let's denote sequence sl,sl+1,...,sr as s[l..r] (1≤l<r≤n). Your task is to find the maximum number among all lucky numbers of sequences s[l..r].Note that as all numbers in sequence s are distinct, all the given definitions make sence.

The first line contains integer n (1<n≤10^5). The second line contains n distinct integers s1,s2,...,sn (1≤si≤10^9).

Print a single integer — the maximum lucky number among all lucky numbers of sequences s[l..r].

For the first sample you can choose s[4..5]={4,3} and its lucky number is (4 xor 3)=7. You can also choose s[1..2].
For the second sample you must choose s[2..5]={8,3,5,7}.


Petya is preparing for IQ test and he has noticed that there many problems like: you are given a sequence, find the next number. Now Petya can solve only problems with arithmetic or geometric progressions.Arithmetic progression is a sequence a1, a1+d, a1+2d, ..., a1+(n-1)d, where a1 and d are any numbers.Geometric progression is a sequence b1, b2=b1q, ..., bn=bn-1q, where b1≠0, q≠0, q≠1. Help Petya and write a program to determine if the given sequence is arithmetic or geometric. Also it should found the next number. If the sequence is neither arithmetic nor geometric, print 42 (he thinks it is impossible to find better answer). You should also print 42 if the next element of progression is not integer. So answer is always integer.

The first line contains exactly four integer numbers between 1 and 1000, inclusively.

Print the required number. If the given sequence is arithmetic progression, print the next progression element. Similarly, if the given sequence is geometric progression, print the next progression element.
Print 42 if the given sequence is not an arithmetic or geometric progression.

This problem contains very weak pretests!

#!/usr/bin/perl

use strict;
use warnings;

my @input = split ' ', <>;
my $gap;

my ($i, $j);
for ($i = 0, $j = 1; $j <= $#input; $i++, $j++) {
    if (not defined($gap)) {
        $gap = $input[$j] - $input[$i];
    } else {
        last unless ($input[$j] - $input[$i] == $gap)
    }
}

if ($j > $#input) {
    print $input[$i] + $gap;
    exit 0;
}

my $mul;
for ($i = 0, $j = 1; $j <= $#input; $i++, $j++) {
    if (not defined($mul)) {
        $mul = $input[$j]/$input[$i];
    } else {
        last unless ($input[$j]/$input[$i] == $mul)
    }
}

if ($j > $#input and int($input[$i]*$mul) == $input[$i]*$mul) {
    print $input[$i]*$mul;
    exit 0;
}

print 42;


Dima and Inna are doing so great! At the moment, Inna is sitting on the magic lawn playing with a pink pony. Dima wanted to play too. He brought an n×m chessboard, a very tasty candy and two numbers a and b.Dima put the chessboard in front of Inna and placed the candy in position (i,j) on the board. The boy said he would give the candy if it reaches one of the corner cells of the board. He's got one more condition. There can only be actions of the following types:  move the candy from position (x,y) on the board to position (x-a,y-b);  move the candy from position (x,y) on the board to position (x+a,y-b);  move the candy from position (x,y) on the board to position (x-a,y+b);  move the candy from position (x,y) on the board to position (x+a,y+b). Naturally, Dima doesn't allow to move the candy beyond the chessboard borders.Inna and the pony started shifting the candy around the board. They wonder what is the minimum number of allowed actions that they need to perform to move the candy from the initial position (i,j) to one of the chessboard corners. Help them cope with the task!

The first line of the input contains six integers n,m,i,j,a,b (1≤n,m≤10^6; 1≤i≤n; 1≤j≤m; 1≤a,b≤10^6).
You can assume that the chessboard rows are numbered from 1 to n from top to bottom and the columns are numbered from 1 to m from left to right. Position (i,j) in the statement is a chessboard cell on the intersection of the i-th row and the j-th column. You can consider that the corners are: (1,m), (n,1), (n,m), (1,1).

In a single line print a single integer — the minimum number of moves needed to get the candy.
If Inna and the pony cannot get the candy playing by Dima's rules, print on a single line "Poor Inna and pony!" without the quotes.

Note to sample 1:
Inna and the pony can move the candy to position (1+2,3+2)=(3,5), from there they can move it to positions (3-2,5+2)=(1,7) and (3+2,5+2)=(5,7). These positions correspond to the corner squares of the chess board. Thus, the answer to the test sample equals two.


On a history lesson the teacher asked Vasya to name the dates when n famous events took place. He doesn't remembers the exact dates but he remembers a segment of days [li,ri] (inclusive) on which the event could have taken place. However Vasya also remembers that there was at most one event in one day. Help him choose such n dates of famous events that will fulfill both conditions. It is guaranteed that it is possible.

The first line contains one integer n (1≤n≤100) — the number of known events. Then follow n lines containing two integers li and ri each (1≤li≤ri≤10^7) — the earliest acceptable date and the latest acceptable date of the i-th event.

Print n numbers — the dates on which the events took place. If there are several solutions, print any of them. It is guaranteed that a solution exists.

sub max { my ($a, $b) = @_; $a > $b? $a: $b }
sub priority { max($a->{start}, $current) <=> max($b->{start}, $current) || $a->{end} <=> $b->{end} }

(undef, @input) = <STDIN>;
for (@input) {
	@val = split;
	push @p, {start => $val[0], end => $val[1], index => $i++ }
}

while (@p) {
	($p, @p) = sort priority @p;
	$current = max $p->{start}, $current;
	$r[ $p->{index} ] = $current++;
}

print "@r";


Do you like summer? Residents of Berland do. They especially love eating ice cream in the hot summer. So this summer day a large queue of n Berland residents lined up in front of the ice cream stall. We know that each of them has a certain amount of berland dollars with them. The residents of Berland are nice people, so each person agrees to swap places with the person right behind him for just 1 dollar. More formally, if person a stands just behind person b, then person a can pay person b 1 dollar, then a and b get swapped. Of course, if person a has zero dollars, he can not swap places with person b.Residents of Berland are strange people. In particular, they get upset when there is someone with a strictly smaller sum of money in the line in front of them.Can you help the residents of Berland form such order in the line so that they were all happy? A happy resident is the one who stands first in the line or the one in front of who another resident stands with not less number of dollars. Note that the people of Berland are people of honor and they agree to swap places only in the manner described above.

The first line contains integer n (1≤n≤200000) — the number of residents who stand in the line.
The second line contains n space-separated integers ai (0≤ai≤10^9), where ai is the number of Berland dollars of a man standing on the i-th position in the line. The positions are numbered starting from the end of the line.

If it is impossible to make all the residents happy, print ":(" without the quotes. Otherwise, print in the single line n space-separated integers, the i-th of them must be equal to the number of money of the person on position i in the new line. If there are multiple answers, print any of them.

In the first sample two residents should swap places, after that the first resident has 10 dollars and he is at the head of the line and the second resident will have 9 coins and he will be at the end of the line.
In the second sample it is impossible to achieve the desired result.
In the third sample the first person can swap with the second one, then they will have the following numbers of dollars: 4 11 3, then the second person (in the new line) swaps with the third one, and the resulting numbers of dollars will equal to: 4 4 10. In this line everybody will be happy.

#!/usr/bin/perl
use warnings;
use strict;

<>;
my @array = split(' ', <>);
my $inc;

for my $el(@array){
	$el += $inc ++;
}

@array = sort {$a <=> $b} @array;

$inc = -1;
for my $el(@array){
	if($el == $inc){
		print ":(";
		exit;
	}
	$inc = $el;
}

$inc = 0;
for my $el(@array){
	$el -= $inc ++;
}
print "@array";


It's now 260 AD. Shapur, being extremely smart, became the King of Persia. He is now called Shapur, His majesty King of kings of Iran and Aniran.Recently the Romans declared war on Persia. They dreamed to occupy Armenia. In the recent war, the Romans were badly defeated. Now their senior army general, Philip is captured by Shapur and Shapur is now going to capture Valerian, the Roman emperor.Being defeated, the cowardly Valerian hid in a room at the top of one of his castles. To capture him, Shapur has to open many doors. Fortunately Valerian was too scared to make impenetrable locks for the doors.Each door has 4 parts. The first part is an integer number a. The second part is either an integer number b or some really odd sign which looks like R. The third one is an integer c and the fourth part is empty! As if it was laid for writing something. Being extremely gifted, after opening the first few doors, Shapur found out the secret behind the locks.c is an integer written in base a, to open the door we should write it in base b. The only bad news is that this R is some sort of special numbering system that is used only in Roman empire, so opening the doors is not just a piece of cake!Here's an explanation of this really weird number system that even doesn't have zero:Roman numerals are based on seven symbols: a stroke (identified with the letter I) for a unit, a chevron (identified with the letter V) for a five, a cross-stroke (identified with the letter X) for a ten, a C (identified as an abbreviation of Centum) for a hundred, etc.: I=1 V=5 X=10 L=50 C=100 D=500 M=1000Symbols are iterated to produce multiples of the decimal (1, 10, 100, 1,000) values, with V, L, D substituted for a multiple of five, and the iteration continuing: I 1, II 2, III 3, V 5, VI 6, VII 7, etc., and the same for other bases: X 10, XX 20, XXX 30, L 50, LXXX 80; CC 200, DCC 700, etc. At the fourth and ninth iteration, a subtractive principle must be employed, with the base placed before the higher base: IV 4, IX 9, XL 40, XC 90, CD 400, CM 900.Also in bases greater than 10 we use A for 10, B for 11, etc.Help Shapur capture Valerian and bring peace back to Persia, especially Armenia.

The first line contains two integers a and b (2≤a,b≤25). Only b may be replaced by an R which indicates Roman numbering system.
The next line contains a single non-negative integer c in base a which may contain leading zeros but its length doesn't exceed 10^3.
It is guaranteed that if we have Roman numerals included the number would be less than or equal to 300010 and it won't be 0. In any other case the number won't be greater than 10^1510.

Write a single line that contains integer c in base b. You must omit leading zeros.

You can find more information about roman numerals here: http://en.wikipedia.org/wiki/Roman_numerals

use strict;

our @rule = qw(1 11 111 12 2 21 211 2111 13);
our @char = qw(IVX XLC CDM M);

sub convert_R {
	my $s = shift;
	my $r;
	my $p = length $s;
	if ($p) {
		my ($d, $d2) = split //, $s, 2;
		if ($d) {
	        	$r = $rule[$d - 1];
	        	my @c = split //, $char[$p - 1];
        		$r =~ s{ (.) }{ $c[$1 - 1] }gxe;
		}
		$r .= convert_R ($d2);
	}
	$r;
}

sub convert_10 {
	my ($number, $base) = @_;
	my $r;
	$number =~ s/^0+//;
	$number = reverse $number;
	for (my $i = 0; $i < length $number; $i++) {
		my $digit = substr $number, $i, 1;
		$digit =~ tr [0-9A-Z] [\00-\11\12-\43];
		$r += ord($digit) * $base ** $i;
	}
	$r;
}

sub convert_B {
	my ($n, $base) = @_;
	my $r;
	while ($n) {
		my $digit = chr $n % $base;
		$digit =~ tr [\00-\11\12-\43] [0-9A-Z];
		$r .= $digit;
		$n = int $n/$base;
	}
	$r ||= 0;
	scalar reverse $r;
}

$/ = ""; $_ = <>; my ($a, $b, $c) = split;
my $n = convert_10($c, $a);
my $r = $b eq "R"? convert_R($n): convert_B($n, $b);
print $r;


Stepan has n pens. Every day he uses them, and on the i-th day he uses the pen number i. On the (n+1)-th day again he uses the pen number 1, on the (n+2)-th — he uses the pen number 2 and so on.On every working day (from Monday to Saturday, inclusive) Stepan spends exactly 1 milliliter of ink of the pen he uses that day. On Sunday Stepan has a day of rest, he does not stend the ink of the pen he uses that day. Stepan knows the current volume of ink in each of his pens. Now it's the Monday morning and Stepan is going to use the pen number 1 today. Your task is to determine which pen will run out of ink before all the rest (that is, there will be no ink left in it), if Stepan will use the pens according to the conditions described above.

The first line contains the integer n (1≤n≤50000) — the number of pens Stepan has.
The second line contains the sequence of integers a1,a2,...,an (1≤ai≤10^9), where ai is equal to the number of milliliters of ink which the pen number i currently has.

Print the index of the pen which will run out of ink before all (it means that there will be no ink left in it), if Stepan will use pens according to the conditions described above.
Pens are numbered in the order they are given in input data. The numeration begins from one.
Note that the answer is always unambiguous, since several pens can not end at the same time.

In the first test Stepan uses ink of pens as follows:
  on the day number 1 (Monday) Stepan will use the pen number 1, after that there will be 2 milliliters of ink in it;  on the day number 2 (Tuesday) Stepan will use the pen number 2, after that there will be 2 milliliters of ink in it;  on the day number 3 (Wednesday) Stepan will use the pen number 3, after that there will be 2 milliliters of ink in it;  on the day number 4 (Thursday) Stepan will use the pen number 1, after that there will be 1 milliliters of ink in it;  on the day number 5 (Friday) Stepan will use the pen number 2, after that there will be 1 milliliters of ink in it;  on the day number 6 (Saturday) Stepan will use the pen number 3, after that there will be 1 milliliters of ink in it;  on the day number 7 (Sunday) Stepan will use the pen number 1, but it is a day of rest so he will not waste ink of this pen in it;  on the day number 8 (Monday) Stepan will use the pen number 2, after that this pen will run out of ink. So, the first pen which will not have ink is the pen number 2.


Polycarp is very careful. He even types numeric sequences carefully, unlike his classmates. If he sees a sequence without a space after the comma, with two spaces in a row, or when something else does not look neat, he rushes to correct it. For example, number sequence written like "1,2 ,3,...,   10" will be corrected to "1, 2, 3, ..., 10".In this task you are given a string s, which is composed by a concatination of terms, each of which may be:   a positive integer of an arbitrary length (leading zeroes are not allowed),  a "comma" symbol (","),  a "space" symbol (" "),  "three dots" ("...", that is, exactly three points written one after another, also known as suspension points). Polycarp wants to add and remove spaces in the string s to ensure the following:   each comma is followed by exactly one space (if the comma is the last character in the string, this rule does not apply to it),  each "three dots" term is preceded by exactly one space (if the dots are at the beginning of the string, this rule does not apply to the term),  if two consecutive numbers were separated by spaces only (one or more), then exactly one of them should be left,  there should not be other spaces. Automate Polycarp's work and write a program that will process the given string s.

The input data contains a single string s. Its length is from 1 to 255 characters. The string s does not begin and end with a space. Its content matches the description given above.

Print the string s after it is processed. Your program's output should be exactly the same as the expected answer. It is permissible to end output line with a line-break character, and without it.


This is a harder version of the problem. In this version, $$$n \le 50\,000$$$.There are $$$n$$$ distinct points in three-dimensional space numbered from $$$1$$$ to $$$n$$$. The $$$i$$$-th point has coordinates $$$(x_i, y_i, z_i)$$$. The number of points $$$n$$$ is even.You'd like to remove all $$$n$$$ points using a sequence of $$$\frac{n}{2}$$$ snaps. In one snap, you can remove any two points $$$a$$$ and $$$b$$$ that have not been removed yet and form a perfectly balanced pair. A pair of points $$$a$$$ and $$$b$$$ is perfectly balanced if no other point $$$c$$$ (that has not been removed yet) lies within the axis-aligned minimum bounding box of points $$$a$$$ and $$$b$$$.Formally, point $$$c$$$ lies within the axis-aligned minimum bounding box of points $$$a$$$ and $$$b$$$ if and only if $$$\min(x_a, x_b) \le x_c \le \max(x_a, x_b)$$$, $$$\min(y_a, y_b) \le y_c \le \max(y_a, y_b)$$$, and $$$\min(z_a, z_b) \le z_c \le \max(z_a, z_b)$$$. Note that the bounding box might be degenerate. Find a way to remove all points in $$$\frac{n}{2}$$$ snaps.

The first line contains a single integer $$$n$$$ ($$$2 \le n \le 50\,000$$$; $$$n$$$ is even), denoting the number of points.
Each of the next $$$n$$$ lines contains three integers $$$x_i$$$, $$$y_i$$$, $$$z_i$$$ ($$$-10^8 \le x_i, y_i, z_i \le 10^8$$$), denoting the coordinates of the $$$i$$$-th point.
No two points coincide.

Output $$$\frac{n}{2}$$$ pairs of integers $$$a_i, b_i$$$ ($$$1 \le a_i, b_i \le n$$$), denoting the indices of points removed on snap $$$i$$$. Every integer between $$$1$$$ and $$$n$$$, inclusive, must appear in your output exactly once.
We can show that it is always possible to remove all points. If there are many solutions, output any of them.


Oh, New Year. The time to gather all your friends and reflect on the heartwarming events of the past year...$$$n$$$ friends live in a city which can be represented as a number line. The $$$i$$$-th friend lives in a house with an integer coordinate $$$x_i$$$. The $$$i$$$-th friend can come celebrate the New Year to the house with coordinate $$$x_i-1$$$, $$$x_i+1$$$ or stay at $$$x_i$$$. Each friend is allowed to move no more than once.For all friends $$$1 \le x_i \le n$$$ holds, however, they can come to houses with coordinates $$$0$$$ and $$$n+1$$$ (if their houses are at $$$1$$$ or $$$n$$$, respectively).For example, let the initial positions be $$$x = [1, 2, 4, 4]$$$. The final ones then can be $$$[1, 3, 3, 4]$$$, $$$[0, 2, 3, 3]$$$, $$$[2, 2, 5, 5]$$$, $$$[2, 1, 3, 5]$$$ and so on. The number of occupied houses is the number of distinct positions among the final ones.So all friends choose the moves they want to perform. After that the number of occupied houses is calculated. What is the minimum and the maximum number of occupied houses can there be?

The first line contains a single integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) — the number of friends.
The second line contains $$$n$$$ integers $$$x_1, x_2, \dots, x_n$$$ ($$$1 \le x_i \le n$$$) — the coordinates of the houses of the friends.

Print two integers — the minimum and the maximum possible number of occupied houses after all moves are performed.


This is a hard version of the problem. The actual problems are different, but the easy version is almost a subtask of the hard version. Note that the constraints and the output format are different.You are given a string $$$s$$$ consisting of $$$n$$$ lowercase Latin letters.You have to color all its characters the minimum number of colors (each character to exactly one color, the same letters can be colored the same or different colors, i.e. you can choose exactly one color for each index in $$$s$$$).After coloring, you can swap any two neighboring characters of the string that are colored different colors. You can perform such an operation arbitrary (possibly, zero) number of times.The goal is to make the string sorted, i.e. all characters should be in alphabetical order.Your task is to find the minimum number of colors which you have to color the given string in so that after coloring it can become sorted by some sequence of swaps. Note that you have to restore only coloring, not the sequence of swaps.

The first line of the input contains one integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) — the length of $$$s$$$.
The second line of the input contains the string $$$s$$$ consisting of exactly $$$n$$$ lowercase Latin letters.

In the first line print one integer $$$res$$$ ($$$1 \le res \le n$$$) — the minimum number of colors in which you have to color the given string so that after coloring it can become sorted by some sequence of swaps.
In the second line print any possible coloring that can be used to sort the string using some sequence of swaps described in the problem statement. The coloring is the array $$$c$$$ of length $$$n$$$, where $$$1 \le c_i \le res$$$ and $$$c_i$$$ means the color of the $$$i$$$-th character.

use strict;
use integer;

my $n = int(<>);
my @nums = split(//, <>);
my @paint = map { 0 } (1 .. $n);

my @min; #$min[0] = 'a';

for (my $i=0; $i<$n; $i++) {
    my $notin = 1;
    for (my $j=0; $notin && $j<=$#min; $j++) {
        if ($nums[$i] ge $min[$j]) {
            $paint[$i] = $j+1;
            $min[$j] = $nums[$i];
            $notin = 0;
        }
    }
    if ($notin) {
        push(@min, $nums[$i]);
        $paint[$i] = scalar @min;
    }
}
print scalar @min, "\n", join(' ', @paint), "\n";

[{'input': ['9\r\nabacbecfd\r\n'], 'output': ['2\r\n1 1 2 1 2 1 2 1 2 \r\n']}, {'input': ['8\r\naaabbcbb\r\n'], 'output': ['2\r\n1 1 1 1 1 1 2 2 \r\n']}, {'input': ['7\r\nabcdedc\r\n'], 'output': ['3\r\n1 1 1 1 1 2 3 \r\n']}, {'input': ['5\r\nabcde\r\n'], 'output': ['1\r\n1 1 1 1 1 \r\n']}, {'input': ['200\r\nraaaaabbbccccccccccdddddeeeeeeeeeeeeeeffffffffffggggggggghhhhhiiiiiiiiijjjjkkkkkkkkkkllllllllmmmmmmmmnnnnnnnooooooooppppppqqqqqqqqqqrrrrrrrrssssttttttttttuuuuuuuuvvvvvvwwwwwwxxxxxxxyyyyyyyzzzzzzzzzzzz\r\n'], 'output': ['2\r\n1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 \r\n']}, {'input': ['200\r\nazaaaaaabbbbbbbcccccccccdeeeeeeefffffffgggggggghhhhhhiijjjjjkkkkkkkkkllllllmmmmmmmmmmmmnnnnnnoooooopppppppppppqqqqqrrrrrrrrrrrrrssssssssssstttttttttttuuuuuuuuvvvvvvvwwwwwwwwwxxxxxxxyyyyyyyyyyyyzzzzzzz\r\n'], 'output': ['2\r\n1 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 \r\n']}, {'input': ['200\r\naaaaaaaaaaaabbbbccccccdddddddeeeeeeffgggggggggggghhhhhhiiiiiiiiiiiijjjjjjjjjkkkkklllllllmmmmmmmmnnnnnnnnoooooooopppppppppqqqqqrrrrrrrrrssssssssssttuuuuuuuvvvvvvvvvvwwwwwwwwxxxxxxxyyyyyyyyzzzzzzzzzzzzw\r\n'], 'output': ['2\r\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 \r\n']}, {'input': ['200\r\ncnaaaaaabbbbbccccdddddddddddddeeeeeeeeefffffffgggggggggghhhhhhhhhiiijjjjjkkkkkkklllllllmmmmmmmnnnnnnnnnooooooooooooppppppppqqqqqqqqqqqrrrssssssstuuuuuuuuvvvvvvvvvvvvwwwwwwxxxxxxxxyyyyyyyzzzzzzzzzzzzzz\r\n'], 'output': ['2\r\n1 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 \r\n']}, {'input': ['200\r\naaawaaaabbbbccccccccddddddddddeeeeeeeffffffffffgggggggggghhhhhhhhiiiiiiiiijjjjjjjkkkkkkkkklllllllmmmmmmmmnnnnnnooooooooppppppppqqqqrrrrrrrsssssssttttttuuuuuuuuuvvvvvvvvvwwwwwwwxxxxxxxyyyyyyyzzzzzzzzzz\r\n'], 'output': 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 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 1 1 1 \r\n']}, {'input': ['200\r\naaaaabbaaaaabcbebebbccecccffgjklccmcmnccoccooddoqqqdddqderreerrsfffsfsfghuuhhhvhhhhvviwixixixxixijjjxjyjzzjzkkklllllmmmmmmmnnnnnnnoooooppppppppppppqqqqqrrrrrrrsssssstttuuuvvvvvvvwwwwwwxxxyyyyyyyyyzzzz\r\n'], 'output': ['2\r\n1 1 1 1 1 1 1 2 2 2 2 2 1 1 2 1 2 1 2 2 2 2 1 2 2 2 1 1 1 1 1 1 2 2 1 2 1 1 2 2 1 2 2 1 1 2 2 1 1 1 1 2 2 2 1 2 2 1 1 2 2 1 1 1 2 2 2 1 2 1 2 2 2 1 1 2 2 2 1 2 2 2 2 1 1 2 1 2 1 2 1 2 1 1 2 1 2 2 2 2 1 2 1 2 1 1 2 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 1 1 1 1 \r\n']}, {'input': ['200\r\naaaabbbbbbcccccdddddeeeeeeeffffggggggggghhhhhiiiiijjjjjjjkkkkkkkkllmmmmmmmmmmnnoooooppppqqqqqrrrrrrsssssttttttttttttuuuvvvvvwwwwwwxxxxxxxxyyyzzzzzzzzzaccddddeeffgjjjjkkklllllmmmmnnooppqrrsssttwwxyyzzz\r\n'], 'output': ['2\r\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 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\r\naaaaaaaaabbbbcccccccccccdddeeeeeeeefffgggghhhhhhhhiiiiiiijjjjjjjkkklllmmmmmnnnnnnnoooooppppppppqqqqrrrrrrrssssssttttuuuuuuvvvvvwwwwxxxxxxyyyyyzzzzzzzzaabbbcccdeeefggggghhhhiijjjjkllnpqqqrrsssstuuvwyzz\r\n'], 'output': ['2\r\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 1 1 \r\n']}, {'input': ['200\r\naaaabbbbabcaccaadbebfbbbfgbbggchhcccchhhcccicjdkkldldddldmdenoeeooffpppfqrfffuuufggguvgggvggwghhxhyyyhhhhzhiiiiiiijjjjjjjkkkllmmmnnnooooppppppppppppqqqqrssssttttttuuuvvvvwwwwwwwwxxxxxxxxyyyyzzzzzzzzzz\r\n'], 'output': ['2\r\n1 1 1 1 1 1 1 1 2 1 1 2 1 1 2 2 1 2 1 2 1 2 2 2 1 1 2 2 1 1 2 1 1 2 2 2 2 1 1 1 2 2 2 1 2 1 2 1 1 1 2 1 2 2 2 1 2 1 2 2 1 1 2 2 1 1 2 2 1 1 1 2 1 1 2 2 2 1 1 1 2 2 2 2 1 1 2 2 2 1 2 2 1 2 2 2 1 2 1 1 1 2 2 2 2 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 \r\n']}, {'input': ['200\r\naaaabccdeffgghhijklllmnnnoopqrrrrssssssttuuvvvwxyyaaaabbbcccccddddddeeeeeeffffgggggghhhhiiiiiiiiiiijjjjjjjjjkkkkllmmmmmmmmnnoooooooooooppppppppppqqqqqqrrrsssstttttuuuuvvvvwwwwwwwxxxxxxxxxyyyyyyyyyyzzz\r\n'], 'output': ['2\r\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 1 1 1 \r\n']}, {'input': ['200\r\naaaaaaabbbbbbcccccccccdddddddeeeeffffffggggghhhhhiiiiiiiijjjjkkkkkllllllllmmmmmmmmmnnnnnnnnnooooooooopppppppppqqqqqqqqrrrrrrrrrrrsssssssttttuuvvvvvvvvvvwwwwwwwxxxxxxyyyyyyzzzzzbceghhhijjjmmooqrrttvvwx\r\n'], 'output': ['2\r\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1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 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 \r\n']}, {'input': ['200\r\naaabbsbbbbbbbbbbbbbcccccccccdddddddddddddeeeeeeeeffffffffgggggggggghhhhhhhhhhhhijjjjjjjjjjkkkkkkllllmmmmmnnnnnnoooooooppppppqqqqqqqqqqqqrrrrrsssssssssttttttuuuuuuvvvvvvvvvwwwwwwxxxxxxyyyyyyzzzzzzzzzzz\r\n'], 'output': ['2\r\n1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 \r\n']}, {'input': ['200\r\njaaaabbbbbbccccccccccccdddddddddddeeeeeeffffffggggghhhhhhhiiiijjjjjjjjjkkkkkkkkkkkllllllllllllmmmmmmmmmmmnnnooooppppppqqqqqqqqqqqqqqrrrrrrrrrrrrsssssttttttuuuuuuuvvvvvwwwwwwwwwwwwxxxxxxxyyyyyyyyzzzzzz\r\n'], 'output': ['2\r\n1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 \r\n']}, {'input': ['200\r\nzywmerhahxlqsjekpqsdqxnjiduyjrytswiweohctztgpiorwimhjmdfofqynyggcrtzslbyvkuvqrsgwyacyvcuathplliwwshusluiqwuhutnzwvuchfedhwwfdzizltdxibtsaocpnqezstblgkfdcvfsjjyzwalkksumsaljqljmmkcyejwwdkolmcgmodoiclte\r\n'], 'output': ['19\r\n1 2 3 4 5 4 5 6 5 3 5 5 4 6 7 6 6 5 4 8 5 3 7 8 9 10 4 2 8 5 2 5 6 4 9 4 10 7 10 11 5 1 5 11 7 9 8 7 4 9 9 10 10 9 12 12 8 12 8 2 9 2 11 11 13 7 5 1 6 10 14 2 5 11 6 5 8 7 7 12 4 2 15 13 2 5 13 6 15 7 12 9 10 10 12 4 4 8 13 6 8 10 6 12 9 4 6 13 6 7 10 1 4 5 6 14 13 14 15 16 13 4 4 14 16 1 12 1 11 7 16 3 12 17 7 8 18 10 17 10 11 9 15 1 8 7 18 12 14 13 15 16 17 5 15 8 14 14 2 1 4 19 12 13 13 8 6 12 8 19 13 14 9 13 14 12 12 14 17 2 16 15 4 4 17 14 11 13 12 18 16 12 11 17 11 16 18 13 7 17 \r\n']}, {'input': ['200\r\ntoimpgygoklxroowdhpacrtrrwmkhcgcpidapeyxrjmiqgilveimnazyydvnujtqpenfkeqdbylfdinompxupfwvirxohaampqihjueasygkucweptgcowjibgnwyqetynykgoujeargnhjbmntfovwusqavpdwtpnpqpkcgaxbhgdxloyealksmgkxprtpfugixdyfn\r\n'], 'output': ['19\r\n1 2 3 3 2 4 1 4 3 4 4 2 3 4 4 3 5 5 4 6 6 4 4 5 5 3 6 7 8 9 9 10 6 8 10 11 6 10 1 2 5 8 7 9 6 10 9 8 4 11 9 7 7 12 1 2 2 12 4 7 5 9 6 7 8 11 9 11 10 12 7 13 14 2 10 11 13 11 9 9 10 8 3 5 8 12 4 5 11 7 3 9 12 15 15 10 8 8 11 12 11 6 13 15 7 2 13 11 6 14 4 14 9 7 13 15 10 4 12 13 16 14 11 4 2 8 15 7 2 11 2 12 14 10 6 13 15 17 8 14 11 14 13 16 12 11 7 15 10 5 4 6 8 9 17 5 10 16 4 7 10 11 10 9 10 13 17 15 18 3 18 14 15 16 3 13 11 2 16 19 13 14 8 12 15 14 3 10 9 7 10 16 6 15 15 3 17 2 16 12 \r\n']}, {'input': ['200\r\nndwpatpnvwldptairxlxqmzzysfvglpjkwbebtosqvfnoebfvxfpupvohcaazsjbdshoducigmfoqzltdgvmdmputqmoaqscilmtafqrxdunwnijhrtbwonpvpeouednmjswhauahmgyozmbiilxxflkkmwywvuojbrwwbkyhxtdywiktkfcsmozklhrwlwyajekejrx\r\n'], 'output': ['19\r\n1 2 1 2 3 2 3 4 2 1 5 6 3 3 7 6 4 1 5 1 5 6 1 1 2 4 7 3 7 7 6 8 8 3 9 9 10 4 7 5 6 4 9 8 7 10 11 9 4 3 9 7 5 7 4 8 9 11 12 12 1 6 9 12 11 6 10 8 11 5 12 10 11 9 12 8 7 1 10 6 13 11 4 9 13 9 8 5 6 7 9 9 14 7 7 14 11 10 10 6 15 12 8 8 3 13 5 10 4 10 11 11 12 8 6 15 4 9 10 9 5 9 13 10 6 13 14 11 12 13 7 4 14 16 6 16 14 12 15 2 10 1 12 16 14 14 13 3 3 16 13 14 14 12 4 2 4 5 6 10 15 17 8 4 4 17 14 2 16 3 7 17 2 4 16 14 7 14 17 18 8 12 10 1 14 13 17 9 4 13 4 2 19 15 18 14 18 15 9 3 \r\n']}, {'input': ['200\r\nftiqlgirbkmlpzkthoivcifhflyietxsfiwiojenqgxrnetzutdsyfuhrbfpedyksfzuvnqonbyydogbrwsfuuivboanufitbjngppagzfgqwyroaofcdgrwoxwfpvcgzdnkhnwtlavnoppdbddpfpcaaipdcqskcqtccrrspvjyqpvjwziexnmmnlqvacdpgnzzhude\r\n'], 'output': ['18\r\n1 1 2 2 3 4 4 2 5 4 3 4 3 1 5 2 6 4 6 2 7 6 7 7 8 5 2 6 9 3 3 4 8 6 4 6 5 6 9 6 5 8 3 5 6 9 5 1 5 6 10 7 2 9 5 8 8 11 9 9 10 11 2 10 7 11 1 5 5 10 9 10 11 12 2 2 12 10 12 13 8 4 7 13 6 6 12 5 14 10 15 11 6 13 12 7 14 12 11 13 10 10 15 13 1 14 13 9 4 2 8 11 15 11 14 15 15 13 8 4 11 3 4 14 10 5 16 13 1 15 12 13 14 12 4 7 13 17 5 12 11 10 10 15 17 15 15 10 15 10 16 18 18 14 10 16 17 9 8 14 17 9 7 17 17 9 9 8 10 5 15 2 10 11 5 15 4 1 16 17 3 12 13 13 12 14 10 5 18 18 18 11 17 12 1 1 17 6 18 18 \r\n']}, {'input': ['2\r\ntj\r\n'], 'output': ['2\r\n1 2 \r\n']}, {'input': ['1\r\nr\r\n'], 'output': ['1\r\n1 \r\n']}, {'input': ['30\r\nrzlwlvhfatfwmlpvndtgrxyphfjnnm\r\n'], 'output': ['8\r\n1 1 2 2 3 3 4 5 6 4 5 2 5 6 5 3 6 7 4 7 5 2 2 6 7 8 7 7 7 8 \r\n']}, {'input': ['30\r\nlpxzyiymhgfemqbhburdctevpybxlv\r\n'], 'output': ['10\r\n1 1 1 1 2 3 2 3 4 5 6 7 3 3 8 4 8 3 4 8 9 4 7 3 5 2 10 3 6 4 \r\n']}, {'input': ['30\r\ndcjajwrqosgljwltqlozqmldwuukkg\r\n'], 'output': ['8\r\n1 2 1 3 1 1 2 3 4 2 5 5 6 1 5 2 3 5 4 1 3 5 6 7 2 3 3 7 7 8 \r\n']}, {'input': ['30\r\nxsvbtliwvggtjbvdebjwcirlfnnuio\r\n'], 'output': ['8\r\n1 2 2 3 3 4 5 2 3 6 6 4 5 7 3 7 7 8 5 2 8 6 5 6 7 6 6 4 7 6 \r\n']}, {'input': ['30\r\nrhkegyacbthzhghossgtqdxtmjfhhx\r\n'], 'output': ['7\r\n1 2 2 3 3 1 4 4 5 2 3 1 3 4 3 3 3 3 4 2 4 5 2 3 5 6 7 7 7 2 \r\n']}, {'input': ['100\r\nyojtyktazyfegvnnsexxiosqxdlpdwlyojsghpvjpavnvjvttbylqcdabyhleltltzalmgoelxdalcbjejsjxnfebzsxusnujdyk\r\n'], 'output': ['15\r\n1 2 3 2 1 3 2 4 1 2 4 5 4 3 4 4 4 5 3 3 5 5 4 5 3 6 6 6 7 4 7 2 7 8 5 9 9 6 5 8 6 10 5 8 5 9 5 6 6 10 2 9 7 10 10 11 11 2 10 9 11 9 6 9 6 1 12 9 9 11 8 12 10 3 13 14 10 14 15 11 12 11 7 11 3 9 12 13 15 1 7 3 6 7 9 6 11 14 2 11 \r\n']}, {'input': ['100\r\nqdvwjzmgfmgngaxzgvuuukxyfzecafuflxpkvemenkorwhmnsxuoxsatlymyjugwjmutfxcksnwhxrwruyqbouyflxhwqhflczzx\r\n'], 'output': ['14\r\n1 2 1 1 2 1 2 3 4 2 3 2 3 5 2 1 3 3 4 4 4 5 2 2 6 1 7 8 9 6 4 6 5 3 5 6 4 7 6 7 6 7 6 5 4 8 7 7 5 3 5 6 3 6 9 6 8 2 8 2 9 5 10 4 9 8 5 6 11 3 12 9 7 8 4 10 3 8 4 8 5 2 9 13 10 5 2 11 11 3 12 4 9 12 13 11 14 1 1 3 \r\n']}, {'input': ['100\r\nkshxumdmoygtdgjkwmpsiffhoswmapcogjkngvcznwhtufgjstqrbgwjtxrnoevhwaoaxporxbnrijtwkqnteergtvvwkxvbvwch\r\n'], 'output': ['12\r\n1 1 2 1 2 3 4 3 3 1 4 3 5 4 4 4 2 4 4 4 5 6 6 6 5 4 2 6 7 5 7 6 7 7 7 7 8 3 9 1 7 2 8 4 4 9 9 8 5 5 6 6 10 9 2 8 5 2 6 7 7 10 3 9 3 11 7 11 2 7 8 6 2 11 9 6 10 10 5 3 10 7 9 5 11 11 6 11 5 4 4 3 10 2 4 12 4 3 12 11 \r\n']}, {'input': ['100\r\neivzgzvqvlgzdltwjcmpublpvopzxylucxhrrltwmizxtdxdrnmuivvcewvaunkqmnjgqgcwdphbvapebhkltmkfcslvgmnqoseu\r\n'], 'output': ['14\r\n1 1 1 1 2 1 2 3 2 4 5 1 6 4 3 2 5 7 4 4 3 8 5 4 3 5 4 1 2 2 6 4 7 3 7 5 5 6 5 4 6 7 1 3 5 8 3 8 6 7 8 5 9 5 5 10 10 4 5 11 6 7 9 7 8 8 10 11 7 11 12 4 12 8 11 13 5 14 8 12 13 11 9 9 7 9 10 12 13 8 10 5 12 9 9 9 10 8 13 6 \r\n']}, {'input': ['100\r\nyvharmmxcxhibqfixtjmhurxchhkvhubxjcveajrkssbsbrxpijxolrtmvanzyybzbdpgzocicakipmkpxhcjtegksbvabfghpfg\r\n'], 'output': ['15\r\n1 2 3 4 3 4 4 2 5 2 5 5 6 4 6 5 2 3 5 5 6 3 4 2 7 6 6 6 3 7 4 8 2 7 8 3 8 9 7 5 6 5 5 9 5 9 6 2 7 8 8 2 8 9 6 5 9 3 10 9 1 2 2 10 1 10 10 7 10 1 8 11 10 11 12 10 11 7 10 11 7 3 12 13 12 5 13 13 11 6 14 4 15 14 14 13 13 7 14 14 \r\n']}, {'input': ['8\r\nenjmfmcb\r\n'], 'output': ['5\r\n1 1 2 2 3 2 4 5 \r\n']}, {'input': ['8\r\nhinzrvgh\r\n'], 'output': ['3\r\n1 1 1 1 2 2 3 3 \r\n']}]