($n, $m) = split (" ", <STDIN>);

$M = "1" x $n;

for (<STDIN>) {
	/To the (left|right) of (\d+)/ or die;
	($direction, $pos) = ($1, $2);
	if ($direction eq "left") {
		$left = 1; $right = 0;
	} else {
		$left = 0; $right = 1;
	}
	$m = ($left x ($pos - 1))."0".($right x ($n - $pos));
	$M = $M & $m;
}

$count = $M =~ y/1//;
$count = -1 if $count == 0;
print $count;

[{'input': ['2 1\r\nTo the left of 2\r\n'], 'output': ['1\r\n']}, {'input': ['3 2\r\nTo the right of 1\r\nTo the right of 2\r\n'], 'output': ['1\r\n']}, {'input': ['3 1\r\nTo the left of 3\r\n'], 'output': ['2\r\n']}, {'input': ['3 2\r\nTo the left of 2\r\nTo the right of 1\r\n'], 'output': ['-1\r\n']}, {'input': ['3 0\r\n'], 'output': ['3\r\n']}, {'input': ['2 2\r\nTo the left of 2\r\nTo the left of 2\r\n'], 'output': ['1\r\n']}, {'input': ['5 0\r\n'], 'output': ['5\r\n']}, {'input': ['6 2\r\nTo the right of 2\r\nTo the left of 4\r\n'], 'output': ['1\r\n']}, {'input': ['8 6\r\nTo the right of 3\r\nTo the left of 4\r\nTo the left of 4\r\nTo the right of 1\r\nTo the right of 5\r\nTo the left of 6\r\n'], 'output': ['-1\r\n']}, {'input': ['459 16\r\nTo the right of 9\r\nTo the right of 148\r\nTo the left of 406\r\nTo the left of 335\r\nTo the right of 240\r\nTo the left of 409\r\nTo the left of 365\r\nTo the left of 426\r\nTo the left of 416\r\nTo the right of 247\r\nTo the left of 284\r\nTo the right of 187\r\nTo the right of 134\r\nTo the right of 128\r\nTo the right of 98\r\nTo the left of 412\r\n'], 'output': ['36\r\n']}, {'input': ['1000 1\r\nTo the right of 117\r\n'], 'output': ['883\r\n']}, {'input': ['1000 0\r\n'], 'output': ['1000\r\n']}, {'input': ['1 0\r\n'], 'output': ['1\r\n']}, {'input': ['2 0\r\n'], 'output': ['2\r\n']}, {'input': ['1 1\r\nTo the right of 1\r\n'], 'output': ['-1\r\n']}, {'input': ['1 1\r\nTo the left of 1\r\n'], 'output': ['-1\r\n']}, {'input': ['2 1\r\nTo the right of 2\r\n'], 'output': ['-1\r\n']}]


$ch=<>;
chomp$ch;
$pos=index($ch,'.');

if(substr($ch,$pos-1,1) eq "9"){
print "GOTO Vasilisa.";
}
elsif(substr($ch,$pos+1,1) lt "5"){
print substr($ch,0,$pos);
}
else{
$car=substr($ch,$pos-1,1)+1;
$res= substr($ch,0,$pos-1).$car;
print $res;

}


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

sub min_jumps {
    my ($x) = @_;
    $x = abs($x);
    my $jumps = 0;
    my $distance = 0;
    while ($distance < $x or ($distance - $x) % 2 != 0) {
        $jumps++;
        $distance += $jumps;
    }
    return $jumps;
}

my $input = <STDIN>;
chomp($input);
print min_jumps($input), "\n";


use strict;
use warnings;

sub probable_self_murderers {
    my ($N, $beauty, $intellect, $richness) = @_;

    my $count = 0;

    for my $i (0..$N-1) {
        my $probable = 0;

        for my $j (0..$N-1) {
            next if $i == $j;

            if ($beauty->[$i] < $beauty->[$j] && $intellect->[$i] < $intellect->[$j] && $richness->[$i] < $richness->[$j]) {
                $probable = 1;
                last;
            }
        }

        $count++ if $probable;
    }

    return $count;
}

# Read input
my $N = <STDIN>;
chomp($N);

my @beauty = split(' ', <STDIN>);
chomp(@beauty);

my @intellect = split(' ', <STDIN>);
chomp(@intellect);

my @richness = split(' ', <STDIN>);
chomp(@richness);

# Call the function and print the result
my $result = probable_self_murderers($N, \@beauty, \@intellect, \@richness);
print "$result\n";


[{'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']}]


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";
}


#!/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']}]


#!/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";


chomp($line=<STDIN>);
@array=split / /,$line;
my ($a,$b,$c)=@array;

$c*=2;
if($a<$c or $b<$c){
	print "Second\n";
}else{
	print "First\n";
}
exit 0;


[{'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']}]


#!/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;


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";


#!/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";


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;


              const eps=0.00000001;  besk1=200000008;  nn=1600000;
             { modul=1000000007;  }
   besk=8000000000000000000;
   label 22,1,2,3,4;
    type    real=extended;   double=extended;
    mas=array [-10..nn] of int64;   point=record x,y,z:real;end;
    zap=record p1,p2,p3 :int64;end; zap1=^zap;
    mass=array[0..nn] of longint;mass1=^mass;
    var posi,posj,diam,modul,oldt,ot1,time,pos,prod,ll,rr,posx,posy,gr,n,dloch,newdl,oldn,oldm,ost,ot,aa,bb,cc,p1,p2,p3,p4,kk,znamzz,kolperiod,znam,tperiod,start,finish,kol1,kol2,lavel,x0,p0,t2,t1,jj,w,ii,ogr,q,p,pp,tt,oldtt,qq,qq1,qq2,q1,q2,pmax,imax,t,nm,m,smin,cen:int64;
   pp0,mask,k,i1,j1,step1, step, i,j:longint;
   y:mas;
    ppp,prob1,prob2,prob3,pr1new,pr2new,pr3new,pr1,pr2,pr3:zap;
    oldpos,finot,vv,znak:int64;
    aold:mas;
    px,py,xc,yc,xxc,yyc:extended;
    del:array[-1..100001,-1..150] of longint;
    kolright,a,fact,next,prev,x,xx,yy,str,kol,s,name,d,dnew, voltay,l,r,c,z,day,b:array[-300000..2600000] of int64;
    zz:array[0..125000000] of byte;
    ppole:array[-10..1002,-10..1005] of char;
    pole,ddd,dd1,dd2,dd3,dd4,dd,ddsum:array[-10..1201,-10..1220] of int64;
   newzan,marked,zanx,zany:array[-1000000..2000000] of boolean;
    sss1,sss2:string;
    def,left,right,udal,stepen,koled,dl,och,newoch,place,newnabor,stoim,nabor:array[-10..200005] of int64;
     zanleft,zanright,zan,fl:array[-100000..10000000] of boolean;
    ss1,ss2,ss:string;ch,ch1,ch2:char;
    binkoef,numleft,numright,dr: array [-10..60,-10..60] of int64;
    s3,s2,s1:array[-100..200000] of string;

    grr :array [-10..2010,-10..2010] of boolean;
    maxpr:array[0..nn] of string;
    sss:array[-10..nn] of string;
     tx,ty,vel,x1,y1,ott,v0,v1,s0,t0:int64;
     zv:point;
     ugol,rot,temp,sumtemp,vol,newx,newy:array[-1000..400000] of int64;
     sq,sqx,sqy,ottt,aaa,bbb,ccc:extended;
     xxx,yyy,yot:double;
       flag2,flag,flag1:boolean;

  function max(a,b:int64):int64;
begin max:=a; if b>a then max:=b;   end;

  function min(a,b:int64):int64;
begin min:=a; if b<a then min:=b;   end;

      function nod(x,y:int64):int64; var z:int64;
begin   repeat  z:=x mod y;x:=y;y:=z;   until  z=0 ;  nod:=x;end;

     function summ(xx,yy:zap):zap1;
var t1,t2,tt:int64; ott:zap;
 begin
    t1:=(xx.p1*yy.p2+xx.p2*yy.p1) mod modul;
    t2:=(xx.p2*yy.p2) mod modul;
    tt:=nod(t1,t2);
    t1:=t1 div tt mod modul;
    t2:=t2 div tt mod modul;
    ott.p1:=t1; ott.p2:=t2;

   summ:=@ott;
 end;

{     function prod(xx,yy:zap):zap1;
var t1,t2,tt:int64; ott:zap;
 begin
    t1:=(xx.p1*yy.p1) mod modul;
    t2:=(xx.p2*yy.p2) mod modul;
    tt:=nod(t1,t2);
    t1:=(t1 div tt) mod modul;
    t2:=(t2 div tt) mod modul;
    ott.p1:=t1; ott.p2:=t2;

   prod:=@ott;
 end;
 }

    function al(x,y:real):real; var t0,t1,p,s0,s1:real;
 begin
     if (x>0)and(y>=0) then p:=arctan(y/x);
     if x<0 then p:=pi+arctan(y/x);
     if(x>0)and(y<0) then p:=2*pi+arctan(y/x);
     if x=0 then if (y>=0) then p:=pi/2 else p:=3*pi/2;
     al:=p{/pi*180};
 end;

function degg(a,k:int64):int64; var p:int64;
begin
 if k<=0 then degg:=1 else if odd(k) then degg:=degg(a,k-1)*a mod modul else
   begin  p:=degg(a,k shr 1); degg:=p*p mod modul;   end;

end;

{function prost(tt:longint):boolean;
var aa:extended; i,p,t:longint;  fl:boolean;
 begin
   fl:=true;
   aa:=tt;
   aa:=sqrt(aa);
   t:=round(aa);
   for i:=2 to t do if tt mod i=0 then fl:=false;

   prost:=fl;
 end;
 }
function arcsin(pp:extended):extended;
var tt:extended;
begin
   if (abs(pp)<=1+eps)and (abs(pp)>=1-eps)
   then if pp>0 then arcsin:=pi/2 else arcsin:=-pi/2;
   tt:=1-pp*pp;
   if abs(tt)>=0 then
     begin
        arcsin:=arctan(pp/sqrt(tt));

     end;

end;

function gl(ch:char):boolean;
begin
 if (ch='o')or (ch='a')or(ch='e')or(ch='u')or(ch='i') then gl:=true else gl:=false;

end;

begin

  { assign (input,'input.txt');reset(input);
      assign (output,'output.txt'); rewrite(output);
   }
      readln(ss);
      n:=length(ss);
     { writeln(ss);
     } for i:=1 to n do if ss[i]='2' then begin ll:=i; break; end;
      for i:=1 to n do if ss[i]='2' then begin rr:=i;  end;
     { writeln('ll= ',ll,' rr= ',rr);
     } for i:=1 to ll do if ss[i]='0' then inc(p0);
      for i:=1 to ll do if ss[i]='1' then inc(pp0);
      if ll=0 then
        begin
           p0:=0; p1:=0;
           for i:=1 to n do if ss[i]='0' then inc(p0);
           for i:=1 to n do if ss[i]='1' then inc(p1);
           for i:=1 to p0 do write('0');
           for i:=1 to p1 do write('1');

          goto 1;
        end;

      for i:=1 to n do if ss[i]='1' then inc(p1);
      for i:=1 to p0 do write('0');
      for i:=1 to p1 do write('1');
      for i:=ll to rr do if (ss[i]='0')or(ss[i]='2') then
        begin inc(q); write(ss[i]); end;
     for i:=1 to n-p0-p1-q do write('0');

   1:          close(output);
end.


{$R+,Q+,I+}
{$apptype console}
Uses SysUtils;
Var
   a,b:Array[1..100000] of Integer;
   s:Array[1..100,1..100] of Integer;
   used:Array[1..100] of Boolean;
   i,n,m:Integer;
Procedure Dfs(i:Integer);
Var
   j:Integer;
Begin
   used[i]:=true;
   For j:=1 To n Do
      If (s[i,j]=1) and (not(used[j])) Then Dfs(j);
End;
Begin
   Read(n,m);
   For i:=1 To m Do Read(a[i],b[i]);
   For i:=1 To m Do Begin
      s[a[i],b[i]]:=1;
      s[b[i],a[i]]:=1;
   End;
   If n<>m Then Begin
      Write('NO');
      Halt;
   End;
   Dfs(1);
   For i:=1 To n Do
      If not(used[i]) Then Begin
         Write('NO');
         Halt;
      End;
   Write('FHTAGN!');
End.


{$R+ Q+ I+}
{$APPTYPE CONSOLE}
uses
  Sysutils;
var
   p : array[1..8] of integer;
   a : array[1..8,1..8] of integer;
   k,n,ans : integer;
   c : array[1..8] of integer;
   status : array[1..8] of boolean;
procedure search(i : integer);
var
   kol,r,j,min,max : integer;
begin
     if i = k then begin
        kol := 1;
        for r := 1 to n do p[r] := 0;
        for j := k downto 1 do begin
                for r := 1 to n do
                p[r] := p[r] + a[r][c[j]]*kol;
            kol := kol*10;
        end;
        min := high(min);
        max := low(max);
        for r := 1 to n do begin
            if p[r] > max then max := p[r];
            if p[r] < min then min := p[r];
        end;
        if max - min < ans then ans := max - min;
        exit;
     end;
     for j := 1 to k do begin
         if status[j] = true then continue;
         inc(i);
         c[i] := j;
         status[j] := true;
         search(i);
         status[j] := false;
         dec(i);
     end;
end;
var
   i,j : integer;
   ch : char;
begin
     readln(n,k);
     for i := 1 to n do begin
         for j := 1 to k do begin
             read(ch);
             a[i][j] := strtoint(ch);
         end;
         readln;
     end;
     ans := high(ans);
     search(0);
     write(ans);
end.


{$A8,B-,C+,D+,E-,F-,G+,H+,I+,J-,K-,L+,M-,N+,O-,P+,Q+,R+,S+,T-,U-,V+,W-,X+,Y+,Z1}
{$MINSTACKSIZE $00004000}
{$MAXSTACKSIZE $00100000}
{$IMAGEBASE $00400000}
{$APPTYPE CONSOLE}

const oo=1e+21;
      eps=1e-9;
      dohuya=maxlongint div 2;

var ss,sss:array[0..201500]of string;
    s,s0,s1,s2,s3:string;
    sc:array[0..1100,0..1100]of char;
    a,aa,qc:array[-9..2015,-9..2015]of longint;
    p2,qq,cc:array[0..1000000]of longint;
    rr,rr1,rr2,uu:int64;
    r1,r2,r3,r0,d,u,q,c,q0,c0,q1,c1,q2,c2,q3,c3,r,res,cur,n,m,i,j,k:longint;
    x,y,z,xx,yy,zz,x0,y0,z0,x1,x2,x3,y1,y2,y3,z1,z2,z3:extended;
    ch:char;
    b,bb:boolean;

procedure swap(var q,c:longint);
var i:longint;
    begin
    i:=q; q:=c; c:=i;
    end;

procedure qcsort(q,c:longint; var qc:array of longint);
var h,e,x:longint;
    ass:boolean;
    begin
    if q>=c then exit;
    x:=q+random(c-q+1);
    swap(qc[x],qc[q]);
    ass:=true;
    for h:=q to c do if qc[h]<>qc[q] then ass:=false;
    if ass then exit;
    h:=q; e:=c;
    while h<e do
      begin
      if qc[h]<qc[h+1] then begin swap(qc[h+1],qc[e]); dec(e); end
      else begin swap(qc[h],qc[h+1]); inc(h); end
      end;
    qcsort(q,h-1,qc);
    qcsort(e+1,c,qc);
    end;

procedure genpp(pow,t:longint;var pp:array of longint);
var i:longint;
    begin
    pp[0]:=1;
    for i:=1 to t do pp[i]:=pow*pp[i-1];
    end;

begin
randseed:=157293;
{assign(input,'qc.in');
assign(output,'qc.out');
reset(input); rewrite(output);{}

read(n,m,k,q,c,r3,i,j);
r1:=(k*m) div i;
r2:=q*c;
r3:=r3 div j;
res:=r1;
if r2<res then res:=r2;
if r3<res then res:=r3;
writeln(res div n);

//close(input); close(output);
end.


program Progs;

{$APPTYPE CONSOLE}

uses SysUtils, Math;

type
  Int32 = Integer;

var
  I, J, N, M: Int32;
  C: Char;
  S: string;
  Flag: Boolean;

begin
  Readln(N, M);
  C := 'a';
  Flag := True;
  for I := 1 to N do
  begin
    Readln(S);
    if C = S[1] then
      Flag := False;
    C := S[1];
    for J := 1 to M do
      if C <> S[J] then
        Flag := False;
  end;
  if Flag then
    Writeln('YES')
  else
    Writeln('NO');
end.


program ZAD_1;

{$APPTYPE CONSOLE}

uses
  SysUtils,Math;
var
   max,s,s1:string;
   i,j,p:integer;
begin
   readln(s);
   max:=s[1];
   for i:=1 to trunc(power(2,length(s))-1) do
      begin
         j:=i;
         p:=1;
         s1:='';
         while j>0 do
            begin
               if  odd(j) then s1:=s1+s[p];
               inc(p);
               j:=j div 2;
            end;
         p:=length(s1) div 2+1;
         for j:=1 to p do
            begin
               if (s1[j]<>s1[length(s1)-j+1]) then break;
               if (j=p) and (s1>max) then max:=s1;
            end;
      end;
   writeln(max);
   readln;
end.

[{'input': ['radar\r\n'], 'output': ['rr\r\n']}, {'input': ['bowwowwow\r\n'], 'output': ['wwwww\r\n']}, {'input': ['codeforces\r\n'], 'output': ['s\r\n']}, {'input': ['mississipp\r\n'], 'output': ['ssss\r\n']}, {'input': ['tourist\r\n'], 'output': ['u\r\n']}, {'input': ['romka\r\n'], 'output': ['r\r\n']}, {'input': ['helloworld\r\n'], 'output': ['w\r\n']}, {'input': ['zzzzzzzazz\r\n'], 'output': ['zzzzzzzzz\r\n']}, {'input': ['testcase\r\n'], 'output': ['tt\r\n']}, {'input': ['hahahahaha\r\n'], 'output': ['hhhhh\r\n']}, {'input': ['abbbbbbbbb\r\n'], 'output': ['bbbbbbbbb\r\n']}, {'input': ['zaz\r\n'], 'output': ['zz\r\n']}, {'input': ['aza\r\n'], 'output': ['z\r\n']}, {'input': ['dcbaedcba\r\n'], 'output': ['e\r\n']}, {'input': ['abcdeabcd\r\n'], 'output': ['e\r\n']}, {'input': ['edcbabcde\r\n'], 'output': ['ee\r\n']}, {'input': ['aaaaaaaaab\r\n'], 'output': ['b\r\n']}, {'input': ['testzzzzzz\r\n'], 'output': ['zzzzzz\r\n']}, {'input': ['zzzzzzwait\r\n'], 'output': ['zzzzzz\r\n']}, {'input': ['rrrrrqponm\r\n'], 'output': ['rrrrr\r\n']}, {'input': ['zzyzyy\r\n'], 'output': ['zzz\r\n']}, {'input': ['aababb\r\n'], 'output': ['bbb\r\n']}, {'input': ['zanzibar\r\n'], 'output': ['zz\r\n']}, {'input': ['hhgfedcbaa\r\n'], 'output': ['hh\r\n']}, {'input': ['aabcdefghh\r\n'], 'output': ['hh\r\n']}, {'input': ['aruaru\r\n'], 'output': ['uu\r\n']}, {'input': ['uraura\r\n'], 'output': ['uu\r\n']}, {'input': ['aru\r\n'], 'output': ['u\r\n']}, {'input': ['aburvabur\r\n'], 'output': ['v\r\n']}, {'input': ['ura\r\n'], 'output': ['u\r\n']}, {'input': ['eurottat\r\n'], 'output': ['u\r\n']}, {'input': ['referee\r\n'], 'output': ['rr\r\n']}, {'input': ['joking\r\n'], 'output': ['o\r\n']}, {'input': ['seriously\r\n'], 'output': ['y\r\n']}, {'input': ['sets\r\n'], 'output': ['t\r\n']}, {'input': ['test\r\n'], 'output': ['tt\r\n']}, {'input': ['klmgameklm\r\n'], 'output': ['mmm\r\n']}, {'input': ['dfkjafdkdd\r\n'], 'output': ['kk\r\n']}, {'input': ['zzzzzzzzzz\r\n'], 'output': ['zzzzzzzzzz\r\n']}, {'input': ['aaaaaaaaaa\r\n'], 'output': ['aaaaaaaaaa\r\n']}, {'input': ['buzz\r\n'], 'output': ['zz\r\n']}, {'input': ['b\r\n'], 'output': ['b\r\n']}, {'input': ['y\r\n'], 'output': ['y\r\n']}, {'input': ['yy\r\n'], 'output': ['yy\r\n']}, {'input': ['zz\r\n'], 'output': ['zz\r\n']}, {'input': ['bb\r\n'], 'output': ['bb\r\n']}, {'input': ['aa\r\n'], 'output': ['aa\r\n']}, {'input': ['a\r\n'], 'output': ['a\r\n']}, {'input': ['z\r\n'], 'output': ['z\r\n']}, {'input': ['zz\r\n'], 'output': ['zz\r\n']}, {'input': ['zzazazzzaz\r\n'], 'output': ['zzzzzzz\r\n']}, {'input': ['hellhellhe\r\n'], 'output': ['llll\r\n']}, {'input': ['hellohello\r\n'], 'output': ['oo\r\n']}, {'input': ['refer\r\n'], 'output': ['rr\r\n']}]


program Project2;

{$APPTYPE CONSOLE}

uses
  SysUtils;

var
  x,t,da,db,a,b,i,j:Integer;
begin
  readln(x,t,a,b,da,db);
  for i:=0 to t-1 do
    for j:=0 to t-1 do
      if (x=a-da*i+b-db*j) or (x=0) or (x=a-da*i) or (x=b-db*j) then
      begin
        write('YES');
        exit;
      end;
  write('NO');
  readln;
  readln;
end.


program Project2;

{$APPTYPE CONSOLE}

uses
  SysUtils;
   var
   a,b:array[0..1001,0..1001] of integer;
   n,m,ans,i,x,y:integer;
begin
  readln(n,m);
  fillchar(a,sizeof(a),0);
  fillchar(b,sizeof(b),0);
  ans:=-1;
   for i:=1 to m do
   begin
     readln(x,y);
     if (ans<>-1) then continue;
     b[x,y]:=1;
     a[x,y]:=1;
     inc(a[x,y],b[x-1,y-1]);
     inc(a[x,y],b[x-1,y]);
     inc(a[x,y],b[x-1,y+1]);
     inc(a[x,y],b[x,y-1]);
     inc(a[x,y],b[x,y+1]);
     inc(a[x,y],b[x+1,y-1]);
     inc(a[x,y],b[x+1,y]);
     inc(a[x,y],b[x+1,y+1]);

     inc(a[x-1,y-1]);
     inc(a[x-1,y]);
     inc(a[x-1,y+1]);
     inc(a[x,y-1]);
     inc(a[x,y+1]);
     inc(a[x+1,y-1]);
     inc(a[x+1,y]);
     inc(a[x+1,y+1]);
     if (ans<>-1) then continue;
     if (a[x,y]=9)or(a[x-1,y-1]=9)or(a[x-1,y]=9)or(a[x-1,y+1]=9)or(a[x,y-1]=9)or(a[x,y+1]=9)or(a[x+1,y-1]=9)or(a[x+1,y]=9)or(a[x+1,y+1]=9)
     then ans:=i;
   end;
   writeln(ans);

end.


program Project2;

{$APPTYPE CONSOLE}

uses
  SysUtils;

var
  m,k,g,x,y,i:int64;
  n:extended;
begin
  readln(m);
  n:=m;
  i:=trunc(sqrt(n))-1000000;
  if (i<0) then
    i:=0;
  y:=i+2000000;
  while (i<=y) do
  begin
    g:=i;
    k:=0;
    while (g>0) do
    begin
      k:=k+g mod 10;
      g:=g div 10;
    end;
    if (k*i+i*i-m=0) then
    begin
      write(i);
      readln;
      exit;
    end;
    inc(i);
  end;
  write(-1);
  readln;
  readln;
end.


program codforces;

{$APPTYPE CONSOLE}

uses
  SysUtils;

var
  n, i, j: integer;
  s, s1: string;

begin
  readln(s);
  readln(s1);

  if (length(s) <> length(s1)) then begin
    writeln('NO');
    exit;
  end;

  i := 1;
  j := length(s1);

  while (i <= length(s)) do begin
    if (s[i] <> s1[j]) then begin
      writeln('NO');
      exit;
    end;
    inc(i);
    dec(j);
  end;

  writeln('YES');

  readln;
  readln;
end.

[{'input': ['code\r\nedoc\r\n'], 'output': ['YES\r\n']}, {'input': ['abb\r\naba\r\n'], 'output': ['NO\r\n']}, {'input': ['code\r\ncode\r\n'], 'output': ['NO\r\n']}, {'input': ['abacaba\r\nabacaba\r\n'], 'output': ['YES\r\n']}, {'input': ['q\r\nq\r\n'], 'output': ['YES\r\n']}, {'input': ['asrgdfngfnmfgnhweratgjkk\r\nasrgdfngfnmfgnhweratgjkk\r\n'], 'output': ['NO\r\n']}, {'input': ['z\r\na\r\n'], 'output': ['NO\r\n']}, {'input': ['asd\r\ndsa\r\n'], 'output': ['YES\r\n']}, {'input': ['abcdef\r\nfecdba\r\n'], 'output': ['NO\r\n']}, {'input': ['ywjjbirapvskozubvxoemscfwl\r\ngnduubaogtfaiowjizlvjcu\r\n'], 'output': ['NO\r\n']}, {'input': ['mfrmqxtzvgaeuleubcmcxcfqyruwzenguhgrmkuhdgnhgtgkdszwqyd\r\nmfxufheiperjnhyczclkmzyhcxntdfskzkzdwzzujdinf\r\n'], 'output': ['NO\r\n']}, {'input': ['bnbnemvybqizywlnghlykniaxxxlkhftppbdeqpesrtgkcpoeqowjwhrylpsziiwcldodcoonpimudvrxejjo\r\ntiynnekmlalogyvrgptbinkoqdwzuiyjlrldxhzjmmp\r\n'], 'output': ['NO\r\n']}, {'input': ['pwlpubwyhzqvcitemnhvvwkmwcaawjvdiwtoxyhbhbxerlypelevasmelpfqwjk\r\nstruuzebbcenziscuoecywugxncdwzyfozhljjyizpqcgkyonyetarcpwkqhuugsqjuixsxptmbnlfupdcfigacdhhrzb\r\n'], 'output': ['NO\r\n']}, {'input': ['gdvqjoyxnkypfvdxssgrihnwxkeojmnpdeobpecytkbdwujqfjtxsqspxvxpqioyfagzjxupqqzpgnpnpxcuipweunqch\r\nkkqkiwwasbhezqcfeceyngcyuogrkhqecwsyerdniqiocjehrpkljiljophqhyaiefjpavoom\r\n'], 'output': ['NO\r\n']}, {'input': ['umeszdawsvgkjhlqwzents\r\nhxqhdungbylhnikwviuh\r\n'], 'output': ['NO\r\n']}, {'input': ['juotpscvyfmgntshcealgbsrwwksgrwnrrbyaqqsxdlzhkbugdyx\r\nibqvffmfktyipgiopznsqtrtxiijntdbgyy\r\n'], 'output': ['NO\r\n']}, {'input': ['zbwueheveouatecaglziqmudxemhrsozmaujrwlqmppzoumxhamwugedikvkblvmxwuofmpafdprbcftew\r\nulczwrqhctbtbxrhhodwbcxwimncnexosksujlisgclllxokrsbnozthajnnlilyffmsyko\r\n'], 'output': ['NO\r\n']}, {'input': ['nkgwuugukzcv\r\nqktnpxedwxpxkrxdvgmfgoxkdfpbzvwsduyiybynbkouonhvmzakeiruhfmvrktghadbfkmwxduoqv\r\n'], 'output': ['NO\r\n']}, {'input': ['incenvizhqpcenhjhehvjvgbsnfixbatrrjstxjzhlmdmxijztphxbrldlqwdfimweepkggzcxsrwelodpnryntepioqpvk\r\ndhjbjjftlvnxibkklxquwmzhjfvnmwpapdrslioxisbyhhfymyiaqhlgecpxamqnocizwxniubrmpyubvpenoukhcobkdojlybxd\r\n'], 'output': ['NO\r\n']}, {'input': ['w\r\nw\r\n'], 'output': ['YES\r\n']}, {'input': ['vz\r\nzv\r\n'], 'output': ['YES\r\n']}, {'input': ['ry\r\nyr\r\n'], 'output': ['YES\r\n']}, {'input': ['xou\r\nuox\r\n'], 'output': ['YES\r\n']}, {'input': ['axg\r\ngax\r\n'], 'output': ['NO\r\n']}, {'input': ['zdsl\r\nlsdz\r\n'], 'output': ['YES\r\n']}, {'input': ['kudl\r\nldku\r\n'], 'output': ['NO\r\n']}, {'input': ['zzlzwnqlcl\r\nlclqnwzlzz\r\n'], 'output': ['YES\r\n']}, {'input': ['vzzgicnzqooejpjzads\r\nsdazjpjeooqzncigzzv\r\n'], 'output': ['YES\r\n']}, {'input': ['raqhmvmzuwaykjpyxsykr\r\nxkysrypjkyawuzmvmhqar\r\n'], 'output': ['NO\r\n']}, {'input': ['ngedczubzdcqbxksnxuavdjaqtmdwncjnoaicvmodcqvhfezew\r\nwezefhvqcdomvciaonjcnwdmtqajdvauxnskxbqcdzbuzcdegn\r\n'], 'output': ['YES\r\n']}, {'input': ['muooqttvrrljcxbroizkymuidvfmhhsjtumksdkcbwwpfqdyvxtrlymofendqvznzlmim\r\nmimlznzvqdnefomylrtxvydqfpwwbckdskmutjshhmfvdiumykziorbxcjlrrvttqooum\r\n'], 'output': ['YES\r\n']}, {'input': ['vxpqullmcbegsdskddortcvxyqlbvxmmkhevovnezubvpvnrcajpxraeaxizgaowtfkzywvhnbgzsxbhkaipcmoumtikkiyyaivg\r\ngviayyikkitmuomcpiakhbxszgbnhvwyzkftwoagzixaearxpjacrnvpvbuzenvovehkmmxvblqyxvctroddksdsgebcmlluqpxv\r\n'], 'output': ['YES\r\n']}, {'input': ['mnhaxtaopjzrkqlbroiyipitndczpunwygstmzevgyjdzyanxkdqnvgkikfabwouwkkbzuiuvgvxgpizsvqsbwepktpdrgdkmfdc\r\ncdfmkdgrdptkpewbsqvszipgxvgvuiuzbkkwuowbafkikgvnqdkxnayzdjygvezmtsgywnupocdntipiyiorblqkrzjpzatxahnm\r\n'], 'output': ['NO\r\n']}, {'input': ['dgxmzbqofstzcdgthbaewbwocowvhqpinehpjatnnbrijcolvsatbblsrxabzrpszoiecpwhfjmwuhqrapvtcgvikuxtzbftydkw\r\nwkdytfbztxukivgctvparqhuwmjfhwpceiozsprzbaxrslbbqasvlocjirbnntajphenipthvwocowbweabhtgdcztsfoqbzmxgd\r\n'], 'output': ['NO\r\n']}, {'input': ['gxoixiecetohtgjgbqzvlaobkhstejxdklghowtvwunnnvauriohuspsdmpzckprwajyxldoyckgjivjpmbfqtszmtocovxwgeh\r\nhegwxvocotmzstqfbmpjvijgkcyodlxyjawrpkczpmdspsuhoiruavnnnuwvtwohglkdxjetshkboalvzqbgjgthoteceixioxg\r\n'], 'output': ['YES\r\n']}, {'input': ['sihxuwvmaambplxvjfoskinghzicyfqebjtkysotattkahssumfcgrkheotdxwjckpvapbkaepqrxseyfrwtyaycmrzsrsngkh\r\nhkgnsrszrmcyaytwrfyesxrqpeakbpavpkcjwxdtoehkrgcfmusshakttatosyktjbeqfycizhgniksofjvxlpbmaamvwuxhis\r\n'], 'output': ['YES\r\n']}, {'input': ['ycnahksbughnonldzrhkysujmylcgcfuludjvjiahtkyzqvkopzqcnwhltbzfugzojqkjjlggmvnultascmygelkiktmfieok\r\nkoeifmtkiklegkmcsatlunvmggkjjlqjozgufzbtlhwncqzpokvqzykthaijvjdulufcgclymjusyyhrzdlnonhgubskhancy\r\n'], 'output': ['NO\r\n']}, {'input': ['wbqasaehtkfojruzyhrlgwmtyiovmzyfifslvlemhqheyaelzwnthrenjsbmntwaoryzwfbxmscmypvxlfmzpnkkjlvwvmtz\r\nztmvwvljkknpzmflxvpymcsmxbfwzyroawtnmbsjnerhtnwzleayehqhmelvlsfifyzmvoiytmwglrhyzurjofktheasaqbw\r\n'], 'output': ['YES\r\n']}, {'input': ['imippqurprbhfugngtgifelytadegwrgaefnfhbjjnmzikvjaccotqzemufqieqldgnbmviisgkynzeldlhqxuqphjfmyij\r\njiymfjhpquxqhldleznykgsiivmbngdlqeiqfumezqtoccajvkizmnjjbhfnfeagrwgedatylefigtgngufhbrpruqppimi\r\n'], 'output': ['YES\r\n']}, {'input': ['bikydffiuisckpvzqlteqfhegsagimodb\r\nbdomigasgehfqetlqzvpkcsiuiffdykib\r\n'], 'output': ['YES\r\n']}]


var i, x, y, n:integer;
s:string;
begin
	readln(s);
	n := length(s);
	for i := 1 to n do
	if s[i] in ['a'..'z'] then inc(y)
	else inc(x);
	if x > y then
		for i := 1 to n do
		if s[i] in ['a'..'z'] then s[i] := chr(ord(s[i]) - 32);
		if x <= y then
		for i := 1 to n do
		if s[i] in ['A'..'Z'] then s[i] := chr(ord(s[i]) + 32);
		writeln(s);
end.

[{'input': ['HoUse\r\n'], 'output': ['house\r\n']}, {'input': ['ViP\r\n'], 'output': ['VIP\r\n']}, {'input': ['maTRIx\r\n'], 'output': ['matrix\r\n']}, {'input': ['BNHWpnpawg\r\n'], 'output': ['bnhwpnpawg\r\n']}, {'input': ['VTYGP\r\n'], 'output': ['VTYGP\r\n']}, {'input': ['CHNenu\r\n'], 'output': ['chnenu\r\n']}, {'input': ['ERPZGrodyu\r\n'], 'output': ['erpzgrodyu\r\n']}, {'input': ['KSXBXWpebh\r\n'], 'output': ['KSXBXWPEBH\r\n']}, {'input': ['qvxpqullmcbegsdskddortcvxyqlbvxmmkhevovnezubvpvnrcajpxraeaxizgaowtfkzywvhnbgzsxbhkaipcmoumtikkiyyaiv\r\n'], 'output': ['qvxpqullmcbegsdskddortcvxyqlbvxmmkhevovnezubvpvnrcajpxraeaxizgaowtfkzywvhnbgzsxbhkaipcmoumtikkiyyaiv\r\n']}, {'input': ['Amnhaxtaopjzrkqlbroiyipitndczpunwygstmzevgyjdzyanxkdqnvgkikfabwouwkkbzuiuvgvxgpizsvqsbwepktpdrgdkmfd\r\n'], 'output': ['amnhaxtaopjzrkqlbroiyipitndczpunwygstmzevgyjdzyanxkdqnvgkikfabwouwkkbzuiuvgvxgpizsvqsbwepktpdrgdkmfd\r\n']}, {'input': ['ISAGFJFARYFBLOPQDSHWGMCNKMFTLVFUGNJEWGWNBLXUIATXEkqiettmmjgydwcpafqrppdsrrrtguinqbgmzzfqwonkpgpcwenv\r\n'], 'output': ['isagfjfaryfblopqdshwgmcnkmftlvfugnjewgwnblxuiatxekqiettmmjgydwcpafqrppdsrrrtguinqbgmzzfqwonkpgpcwenv\r\n']}, {'input': ['XHRPXZEGHSOCJPICUIXSKFUZUPYTSGJSDIYBCMNMNBPNDBXLXBzhbfnqvwcffvrdhtickyqhupmcehlsyvncqmfhautvxudqdhgg\r\n'], 'output': ['xhrpxzeghsocjpicuixskfuzupytsgjsdiybcmnmnbpndbxlxbzhbfnqvwcffvrdhtickyqhupmcehlsyvncqmfhautvxudqdhgg\r\n']}, {'input': ['RJIQZMJCIMSNDBOHBRAWIENODSALETAKGKPYUFGVEFGCBRENZGAdkcetqjljtmttlonpekcovdzebzdkzggwfsxhapmjkdbuceak\r\n'], 'output': ['RJIQZMJCIMSNDBOHBRAWIENODSALETAKGKPYUFGVEFGCBRENZGADKCETQJLJTMTTLONPEKCOVDZEBZDKZGGWFSXHAPMJKDBUCEAK\r\n']}, {'input': ['DWLWOBHNMMGTFOLFAECKBRNNGLYLYDXTGTVRLMEESZOIUATZZZXUFUZDLSJXMEVRTESSFBWLNZZCLCQWEVNNUCXYVHNGNXHCBDFw\r\n'], 'output': ['DWLWOBHNMMGTFOLFAECKBRNNGLYLYDXTGTVRLMEESZOIUATZZZXUFUZDLSJXMEVRTESSFBWLNZZCLCQWEVNNUCXYVHNGNXHCBDFW\r\n']}, {'input': ['NYCNHJWGBOCOTSPETKKHVWFGAQYNHOVJWJHCIEFOUQZXOYUIEQDZALFKTEHTVDBVJMEUBJUBCMNVPWGDPNCHQHZJRCHYRFPVIGUB\r\n'], 'output': ['NYCNHJWGBOCOTSPETKKHVWFGAQYNHOVJWJHCIEFOUQZXOYUIEQDZALFKTEHTVDBVJMEUBJUBCMNVPWGDPNCHQHZJRCHYRFPVIGUB\r\n']}, {'input': ['igxoixiecetohtgjgbqzvlaobkhstejxdklghowtvwunnnvauriohuspsdmpzckprwajyxldoyckgjivjpmbfqtszmtocovxwge\r\n'], 'output': ['igxoixiecetohtgjgbqzvlaobkhstejxdklghowtvwunnnvauriohuspsdmpzckprwajyxldoyckgjivjpmbfqtszmtocovxwge\r\n']}, {'input': ['Ykkekrsqolzryiwsmdlnbmfautxxxauoojrddvwklgnlyrfcvhorrzbmtcrvpaypqhcffdqhwziipyyskcmztjprjqvmzzqhqnw\r\n'], 'output': ['ykkekrsqolzryiwsmdlnbmfautxxxauoojrddvwklgnlyrfcvhorrzbmtcrvpaypqhcffdqhwziipyyskcmztjprjqvmzzqhqnw\r\n']}, {'input': ['YQOMLKYAORUQQUCQZCDYMIVDHGWZFFRMUVTAWCHERFPMNRYRIkgqrciokgajamehmcxgerpudvsqyonjonsxgbnefftzmygncks\r\n'], 'output': ['yqomlkyaoruqqucqzcdymivdhgwzffrmuvtawcherfpmnryrikgqrciokgajamehmcxgerpudvsqyonjonsxgbnefftzmygncks\r\n']}, {'input': ['CDOZDPBVVVHNBJVBYHEOXWFLJKRWJCAJMIFCOZWWYFKVWOGTVJcuusigdqfkumewjtdyitveeiaybwrhomrwmpdipjwiuxfnwuz\r\n'], 'output': ['CDOZDPBVVVHNBJVBYHEOXWFLJKRWJCAJMIFCOZWWYFKVWOGTVJCUUSIGDQFKUMEWJTDYITVEEIAYBWRHOMRWMPDIPJWIUXFNWUZ\r\n']}, {'input': ['WHIUVEXHVOOIJIDVJVPQUBJMEVPMPDKQWJKFBZSGSKUXMIPPMJWuckzcpxosodcjaaakvlxpbiigsiauviilylnnqlyucziihqg\r\n'], 'output': ['WHIUVEXHVOOIJIDVJVPQUBJMEVPMPDKQWJKFBZSGSKUXMIPPMJWUCKZCPXOSODCJAAAKVLXPBIIGSIAUVIILYLNNQLYUCZIIHQG\r\n']}, {'input': ['VGHUNFOXKETUYMZDJNGTAOIOANYXSGYNFOGOFFLDAWEUKYFOZXCJTCAFXZYLQZERYZLRSQXYQGAPCSUDPMEYTNCTTTMFAGVDWBO\r\n'], 'output': ['VGHUNFOXKETUYMZDJNGTAOIOANYXSGYNFOGOFFLDAWEUKYFOZXCJTCAFXZYLQZERYZLRSQXYQGAPCSUDPMEYTNCTTTMFAGVDWBO\r\n']}, {'input': ['EDUANHCQDOCJHFONTTSWBUJSTTIXBIXMAIUFSGFLXWAYIURTVAVZPYQDLAWIGCLMPHXCEFCJPFAAHXVNGQUFNHADAIUAZIDMHDd\r\n'], 'output': ['EDUANHCQDOCJHFONTTSWBUJSTTIXBIXMAIUFSGFLXWAYIURTVAVZPYQDLAWIGCLMPHXCEFCJPFAAHXVNGQUFNHADAIUAZIDMHDD\r\n']}, {'input': ['EBWOVSNLYTWWXrnovgugogtjahnmatomubebyxakas\r\n'], 'output': ['ebwovsnlytwwxrnovgugogtjahnmatomubebyxakas\r\n']}, {'input': ['AORNNDKTRLRVGDPXJKXFTPFpopuzrlqumrxssskvbm\r\n'], 'output': ['AORNNDKTRLRVGDPXJKXFTPFPOPUZRLQUMRXSSSKVBM\r\n']}, {'input': ['DBBZJCWQEVGYHEEUHJAWRHBDPsnplijbwtdibqrrheebfxqcvn\r\n'], 'output': ['dbbzjcwqevgyheeuhjawrhbdpsnplijbwtdibqrrheebfxqcvn\r\n']}, {'input': ['t\r\n'], 'output': ['t\r\n']}, {'input': ['N\r\n'], 'output': ['N\r\n']}, {'input': ['kv\r\n'], 'output': ['kv\r\n']}, {'input': ['Ur\r\n'], 'output': ['ur\r\n']}, {'input': ['CN\r\n'], 'output': ['CN\r\n']}]


program Project2;

{$APPTYPE CONSOLE}

uses
  SysUtils;

var
    s: string;
    sum, k: int64;

begin
    k := 0;
    sum := 0;
    while not(eof) do begin
        readln(s);
        if(s[1] = '+') then
            inc(k)
        else if(s[1] = '-') then
            dec(k)
        else
            sum := sum + k * (length(s) - pos(':', s));
    end;
    writeln(sum);
end.

[{'input': ['+Mike\r\nMike:hello\r\n+Kate\r\n+Dmitry\r\n-Dmitry\r\nKate:hi\r\n-Kate\r\n'], 'output': ['9\r\n']}, {'input': ['+Mike\r\n-Mike\r\n+Mike\r\nMike:Hi   I am here\r\n-Mike\r\n+Kate\r\n-Kate\r\n'], 'output': ['14\r\n']}, {'input': ['+Dmitry\r\n+Mike\r\nDmitry:All letters will be used\r\nDmitry:qwertyuiopasdfghjklzxcvbnm QWERTYUIOPASDFGHJKLZXCVBNM\r\nDmitry:And digits too\r\nDmitry:1234567890 0987654321\r\n-Dmitry\r\n'], 'output': ['224\r\n']}, {'input': ['+Dmitry\r\n+Mike\r\n+Kate\r\nDmitry:\r\n'], 'output': ['0\r\n']}, {'input': ['+Dmitry\r\nDmitry:No phrases with spaces at the beginning and at the end\r\n+Mike\r\nDmitry:spaces    spaces\r\n-Dmitry\r\n'], 'output': ['86\r\n']}, {'input': ['+XqD\r\n+aT537\r\nXqD:x6ZPjMR1DDKG2\r\nXqD:lLCriywPnB\r\n-XqD\r\n'], 'output': ['46\r\n']}, {'input': ['+8UjgAJ\r\n8UjgAJ:02hR7UBc1tqqfL\r\n-8UjgAJ\r\n+zdi\r\n-zdi\r\n'], 'output': ['14\r\n']}, {'input': ['+6JPKkgXDrA\r\n+j6JHjv70An\r\n+QGtsceK0zJ\r\n6JPKkgXDrA:o4\r\n+CSmwi9zDra\r\nQGtsceK0zJ:Zl\r\nQGtsceK0zJ:0\r\nj6JHjv70An:7\r\nj6JHjv70An:B\r\nQGtsceK0zJ:OO\r\n'], 'output': ['34\r\n']}, {'input': ['+1aLNq9S7uLV\r\n-1aLNq9S7uLV\r\n+O9ykq3xDJv\r\n-O9ykq3xDJv\r\n+54Yq1xJq14F\r\n+0zJ5Vo0RDZ\r\n-54Yq1xJq14F\r\n-0zJ5Vo0RDZ\r\n+lxlH7sdolyL\r\n-lxlH7sdolyL\r\n'], 'output': ['0\r\n']}, {'input': ['+qlHEc2AuYy\r\nqlHEc2AuYy:YYRwD0 edNZgpE nGfOguRWnMYpTpGUVM aXDKGXo1Gv1tHL9\r\nqlHEc2AuYy:yvh3GsPcImqrvoUcBNQcP6ezwpU0 xAVltaKZp94VKiNao\r\nqlHEc2AuYy:zuCO6Opey L  eu7lTwysaSk00zjpv zrDfbt8l  hpHfu\r\n+pErDMxgVgh\r\nqlHEc2AuYy:I1FLis  mmQbZtd8Ui7y 1vcax6yZBMhVRdD6Ahlq7MNCw\r\nqlHEc2AuYy:lz MFUNJZhlqBYckHUDlNhLiEkmecRh1o0t7alXBvCRVEFVx\r\npErDMxgVgh:jCyMbu1dkuEj5TzbBOjyUhpfC50cL8R900Je3R KxRgAI dT\r\nqlHEc2AuYy:62b47eabo2hf vSUD7KioN ZHki6WB6gh3u GKv5rgwyfF\r\npErDMxgVgh:zD5 9 ympl4wR gy7a7eAGAn5xVdGP9FbL6hRCZAR6O4pT6zb\r\n'], 'output': ['615\r\n']}, {'input': ['+adabacaba0\r\n'], 'output': ['0\r\n']}, {'input': ['+acabadab\r\n+caba0aba\r\n'], 'output': ['0\r\n']}, {'input': ['+dabaca\r\n-dabaca\r\n+aba0ab\r\n'], 'output': ['0\r\n']}, {'input': ['+cab\r\n+abac\r\n-abac\r\n+baca\r\n'], 'output': ['0\r\n']}, {'input': ['+cabadabac\r\n-cabadabac\r\n+abacaba1ab\r\n-abacaba1ab\r\n+ba0abaca\r\n'], 'output': ['0\r\n']}, {'input': ['+adabacaba\r\n-adabacaba\r\n+aca\r\naca:caba\r\n-aca\r\n+bacaba\r\n-bacaba\r\n+aba\r\n-aba\r\n+bad\r\n'], 'output': ['4\r\n']}, {'input': ['+acabadab\r\n-acabadab\r\n+aba0abacab\r\n+baca\r\n+abacaba0ab\r\n-baca\r\n-abacaba0ab\r\n-aba0abacab\r\n+cab\r\n-cab\r\n+abacabada\r\n-abacabada\r\n+badabaca\r\n-badabaca\r\n+badaba\r\n'], 'output': ['0\r\n']}, {'input': ['+badabac\r\nbadabac:abacabad\r\n-badabac\r\n+0ab\r\n-0ab\r\n+dabacab\r\n-dabacab\r\n+a0ab\r\n-a0ab\r\n+0abaca\r\n-0abaca\r\n+dabac\r\n-dabac\r\n+abaca\r\n-abaca\r\n+bacabada\r\n-bacabada\r\n+aca\r\n-aca\r\n+abadabaca\r\n-abadabaca\r\n+acaba\r\n-acaba\r\n+abacabadab\r\n-abacabadab\r\n'], 'output': ['8\r\n']}]


program format;

{$APPTYPE CONSOLE}

uses
  SysUtils;

var
  a: array [1..10000] of string;
  mx, r, n, k, f, j, i: integer;
  b: boolean;

begin
  b := true;
  mx := 0;
  r := 0;
  while not eof do
  begin
    inc(r);
    readln(a[r]);
    if (length(a[r]) > mx) then mx := length(a[r]);
  end;
  for i := 1 to mx + 2 do write('*');
  writeln;
  for i := 1 to r do
  begin
    f := mx - length(a[i]);
    n := f div 2;
    k := f div 2;
    write('*');
    if (f mod 2 = 1) then
    begin
      if b then inc(k)
      else inc(n);
      b := not b;
    end;
    for j := 1 to n do write(' ');
    write(a[i]);
    for j := 1 to k do write(' ');
    writeln('*');
  end;
  for i := 1 to mx + 2 do write('*');
  writeln;
end.


{$R+,Q+,I+}
{$apptype console}
Uses SysUtils;
Var
   n,m,i,j,ans:Integer;
   l,r,t,c,b,h:Array[1..100] of Integer;
Begin
   Read(n,m);
   For i:=1 To m Do Read(l[i],r[i],t[i],c[i]);
   For i:=1 To n Do b[i]:=High(Integer);
   For i:=1 To n Do h[i]:=High(Integer);
   For i:=1 To m Do
      For j:=l[i] To r[i] Do Begin
         If (t[i]<b[j]) or ((t[i]=b[j]) and (i<h[j])) Then Begin
            b[j]:=t[i];
            h[j]:=i;
         End;
      End;
   ans:=0;
   For i:=1 To n Do
      If b[i]<>High(Integer) Then ans:=ans+c[h[i]];
   Write(ans);
End.


                  const eps=0.0000000001;  besk=20000000000008;  nn=200000;
   label 1,2,3,4,5,6;
    type
    mas=array [0..nn] of int64;   point=record x,y,z:real;end;
    zap=record p1,p2,p3 :int64;end; zap1=^zap;
    mass=array[0..nn] of int64;mass1=^mass;
    var start,kk,ans,pp,qq,aaa,bbb,ccc,tt,aa,bb,jj,ii,ott,time,ppp,istart,jstart,iii,newdl, t1,t2,cc,ll,rr,oldpos,t,jjj,kol,pos,dloch,told,p,q,pmin,ppold,ot,pmax,imax,p1,p2,p3,p4,l,nm,n,s2,m,smin,cen:int64;
   mask,k, step, i,j:longint;
    s0,s1,aanew,bbnew:extended;
    y,xx,yy,och,s,d11,a,b,prev,next,z,x,newc,d,c,nap:array[-10..1000001] of int64;
    sd:array[-1000..1000000] of char;
    yyy:array[-10..1000000,0..11] of longint;
    dot,dd:array[-10..1010,-10..1010] of int64;
    ddminus, ppole:array[-1..2000,-100..1502] of int64;
   sss,text1,text2:array[-10..2000000] of string;
     stest,ss3,ss1,ss2:string;
     ch1,ch2:char;
     ddd1:array[-1..400000,-1..10] of int64;
     marked:array[-100..1500,-100..1500] of boolean;
    {sss:string;ch:char;
   } pole :array [-10..1500,-10..1500] of char;
    st:array[0..nn] of string;
    stest1,ss:string;
     v0,v1,t0:real;
     zv:point;
     newx,newy:array[-1..200000] of int64;

     koef,yot:extended;
      globflag, flag2,flag,flag1:boolean;
    function al(x,y:real):real; var t0,t1,p,s0,s1:real;
 begin
     if (x>0)and(y>=0) then p:=arctan(y/x);
     if x<0 then p:=pi+arctan(y/x);
     if(x>0)and(y<0) then p:=2*pi+arctan(y/x);
     if x=0 then if (y>=0) then p:=pi/2 else p:=3*pi/2;
     al:=p/pi*180;
 end;
  function min(x,y:int64):int64;begin min:=x;if y<x then min:=y; end;
  function max(x,y:int64):int64;begin max:=x;if y>x then max:=y; end;

  function nod(x,y:int64):int64; var z:int64;
begin   repeat  z:=x mod y;x:=y;y:=z;   until  z=0 ;  nod:=x;end;

procedure udal(ii:longint);
begin  next[prev[ii]]:=next[ii]; prev[next[ii]]:=prev[ii];  end;

begin
   { assign (input,'input.txt');reset(input);
      assign (output,'output.txt'); rewrite(output);
    }

     read(n);
     for i:=1 to n do begin read(a[i]);  end;

     for i:=0 to n+1 do begin next[i]:=i+1;prev[i]:=i-1; end;
while next[0]<=n do
  begin
     inc(p); q:=0;
     start:=next[0];
     pos:=start;
     repeat udal(pos); inc(q); pos:=a[pos];  until pos=start;
     x[p]:=q;

  end;

  if p<=2 then begin  writeln(n*n); goto 1; end;
  {writeln('p= ',p);
  for i:=1 to p do write(x[i],' '); writeln;
   }
  t1:=0;
  for i:=1 to p do if x[i]>t1 then begin imax:=i; t1:=x[i]; end;

  t2:=0;
  for i:=1 to p do if (x[i]>t2)and(i<>imax) then begin  t2:=x[i]; ii:=i; end;

 { writeln(t1,' ',t2);
  }
  for i:=1 to n do if (i<>imax)and(i<>ii) then ans:=ans+x[i]*x[i];

 { writeln('ans= ',ans);
  }
  writeln(ans+(t1+t2)*(t1+t2));

   1:    close(output);
end.


var i, j, n, m, l, r: Longint;
    xq, yq, dq: array [1..10000000] of Longint;
    a: array [1..2000, 1..2000] of Char;
    dist: array [1..2000, 1..2000, 1..4] of Longint;
    mark: array [1..2000, 1..2000, 1..4] of Boolean;

function able(x, y, d: Longint): Boolean;
Begin
    if (x >= 1) and (x <= n) and (y >= 1) and (y <= m) and (mark[x, y, d] = false) then
        able := true
    else
        able := false;
End;

function gox(x: Longint): Longint;
Begin
    if x = 2 then
        gox := -1
    else
    if x = 4 then
        gox := 1
    else
        gox := 0;
End;

function goy(x: Longint): Longint;
Begin
    if x = 1 then
        goy := -1
    else
    if x = 3 then
        goy := 1
    else
        goy := 0;
End;

Begin
    readln(n, m);
    for i := 1 to n do begin
        for j := 1 to m do
            read(a[i, j]);
        readln;
    end;
    inc(m);
    l := 1;
    r := 1;
    xq[1] := 1;
    yq[1] := 1;
    dq[1] := 3;
    dist[1, 1, 3] := 0;
    mark[xq[1], yq[1], dq[1]] := true;
    while l <= r do begin
        if a[xq[l], yq[l]] = '#' then
        for i := 1 to 4 do
            if (i <> dq[l]) and (able(xq[l] + gox(i), yq[l] + goy(i), i)) then begin
                inc(r);
                xq[r] := xq[l] + gox(i);
                yq[r] := yq[l] + goy(i);
                dq[r] := i;
                dist[xq[r], yq[r], dq[r]] := dist[xq[l], yq[l], dq[l]] + 1;
                mark[xq[r], yq[r], dq[r]] := true;
            end;

        if able(xq[l] + gox(dq[l]), yq[l] + goy(dq[l]), dq[l]) then begin
            dist[xq[l] + gox(dq[l]), yq[l] + goy(dq[l]), dq[l]] := dist[xq[l], yq[l], dq[l]];
            xq[l] := xq[l] + gox(dq[l]);
            yq[l] := yq[l] + goy(dq[l]);
            mark[xq[l], yq[l], dq[l]] := true;
        end else
            inc(l);
    end;
    if mark[n, m, 3] = false then
        write(-1)
    else
        write(dist[n, m, 3]);
End.


uses math;
type mass=array[0..100000] of integer;
     maxx=array[1..100000,1..2] of integer;
var d,kol,q,q1,i1,z1,q2,k,uk,p,n,kolv,res,r,l,j,b,c,e,e1,max1:int64;s:string;i,z:integer;
    m,m1:mass;ch:char;u:boolean;qq,w,o,g,a:int64;min1,a1,b1,c1:extended;
    m2:maxx;
begin
  // assign(input,'input.txt');
  // assign(output,'output.txt');
   readln(n);
   for i:=1 to n do
     read(m[i]);
   a:=0;
   b:=0;
   for i:=1 to n do
      Begin
         while (a>0) and (m[i]<m[m1[a]]) do
            Begin
               for z:=max(m[i],m[m1[a-1]]) to m[m1[a]]-1 do
                  Begin
                     inc(b);
                     m2[b,1]:=m1[a];
                     m2[b,2]:=i-1;
                  end;
               if m[i]>m[m1[a-1]]
               then m[m1[a]]:=m[i]
               else dec(a);
            end;
         if m[i]>m[m1[a]]
         then Begin
                 inc(a);
                 m1[a]:=i;
              end;
      end;
   for i:=a downto 1 do
      Begin
         for z:=m[m1[i-1]] to m[m1[i]]-1 do
            Begin
               inc(b);
               m2[b,1]:=m1[i];
               m2[b,2]:=n;
            end;
      end;
   writeln(b);
   for i:=1 to b do
      writeln(m2[i,1],' ',m2[i,2]);
end.


{$R+,Q+,I+}
{$apptype console}
Uses SysUtils;
Var
   a,b,s:Array[0..100000] of Int64;
   i,j,n,q:Integer;
   r,p,k,t:Int64;
procedure qSort(l,r:integer);
var i,j:integer;
    w,q:integer;
begin
  i := l; j := r;
  randomize;
  q := a[random(r-l+1) + l];
  repeat
    while (a[i] < q) do inc(i);
    while (q < a[j]) do dec(j);
    if (i <= j) then
    begin
      w:=a[i]; a[i]:=a[j]; a[j]:=w;
      inc(i); dec(j);
    end;
  until (i > j);
  if (l < j) then qSort(l,j);
  if (i < r) then qSort(i,r);
end;
Begin
   Read(n);
   For i:=1 To n Do Read(a[i]);
   qSort(1,n);
   s[1]:=a[1];
   For i:=2 To n Do s[i]:=a[i]+s[i-1];
   For i:=1 To 100000 Do b[i]:=0;
   Read(q);
   For i:=1 To q Do Begin
      Read(k);
      If b[k]<>0 Then Begin
         Write(b[k],' ');
         Continue;
      End;
      If k=1 Then Begin
         r:=0;
         For j:=1 To n-1 Do r:=r+s[j];
         Write(r,' ');
         b[1]:=r;
      End
      Else Begin
         If n<=k+1 Then r:=s[n-1]
         Else Begin
            r:=0;
            j:=n-1;
            t:=k;
            p:=1;
            While True Do Begin
               If j-t<1 Then Begin
                  r:=r+s[j]*p;
                  Break;
               End;
               r:=r+p*(s[j]-s[j-t]);
               j:=j-t;
               t:=t*k;
               p:=p+1;
            End;
         End;
         Write(r,' ');
         b[k]:=r;
      End;
   End;
End.


uses math;
type mass=array[1..100000] of integer;
var r,l,k:int64;s,s1:string;u:boolean;d,max1,min1,n,res,de:int64;i:integer;z,x,code,j,a,b,c,y:int64;
    m:mass;
procedure qsort(var A:mass);
    procedure sort(l,r: integer);
      var i,j,x,y: integer;
    begin
      i := l;
      j := r;
      x := A[l+random(r-l)];
      repeat
        while A[i] < x do inc(i);
        while x < A[j] do dec(j);
        if not (i>j) then
          begin
            y    := A[i];
            A[i] := A[j];
            A[j] := y;
            inc(i);
            dec(j);
          end;
      until i>j;
      if l < j then sort(l,j);
      if i < r then sort(i,r);
    end;
begin
  sort(1,n);
end;
begin
//  reset(input,'input.txt');
//  assign(output,'output.txt');
  readln(n,k);
  for i:=1 to n do
     read(m[i]);
  qsort(m);
  r:=0;
  max1:=0;
  j:=0;
  b:=0;
  a:=0;
  for i:=1 to n do
     Begin
        r:=max(r,i);
        a:=max(a,1);
        while r<n do
           Begin
              if b+(m[r+1]-m[r])*a>k
              then break;
              inc(r);
              inc(b,(m[r]-m[r-1])*a);
              inc(a);
           end;
        if a>max1
        then Begin
                max1:=a;
                j:=m[r];
             end;
        dec(b,m[r]-m[i]);
        dec(a);
     end;
  writeln(max1,' ',j);
end.


var sol,a,b,n,m,j,i,t,t2,q:longint;
    c:array[1..100007]of array of longint;
    e,tin,tout,p,x,y,v,s,r,new,o,suma:array[0..100007]of longint;
    w:array[1..100007,0..20]of longint;

procedure dfs1(x,pr:longint);
var u,tu:longint;
begin
if v[x]=1 then exit;
 v[x]:=1;
 t:=t+1;
 s[t]:=x;
 r[x]:=t;
 for u:=0 to p[x] do if ((v[c[x,u]]=0)or(c[x,u]=pr))
 then dfs1(c[x,u],x) else
  begin
  tu:=r[c[x,u]];
  for j:=tu to t do new[s[j]]:=c[x,u];
  end;
 t:=t-1;
end;

procedure dfs2(x,pr:longint);
var u:longint;
begin
  t:=t+1;
  tin[x]:=t;
  suma[x]:=suma[pr]+o[x];
  w[x][0]:=pr;
  v[x]:=1;
  for u:=0 to p[x] do if v[c[x,u]]=0 then dfs2(c[x,u],x);
  t2:=t2+1;
  tout[x]:=t2;
end;

function f(x,y:longint):boolean;
begin
 f:=(tin[x]<=tin[y])and(tout[x]>=tout[y]);
end;

function lca(x,y:longint):longint;
begin
 if f(x,y) then lca:=x else
 if f(y,x) then lca:=y else
 begin
 for i:=20 downto 0 do
   if not f(w[x][i],y) then x:=w[x][i];
 lca:=w[x][0];
 end;
end;

begin
fillchar(o,sizeof(o),0);
fillchar(p,sizeof(p),-1);
readln(n,m);
for i:=1 to m do begin
 readln(x[i],y[i]);
 p[x[i]]:=p[x[i]]+1;
 p[y[i]]:=p[y[i]]+1;
 end;
 for i:=1 to n do setlength(c[i],p[i]+1);
 for j:=1 to n do p[j]:=-1;
 for i:=1 to m do
 begin
 p[x[i]]:=p[x[i]]+1;
 p[y[i]]:=p[y[i]]+1;
 c[y[i],p[y[i]]]:=x[i];
 c[x[i],p[x[i]]]:=y[i];
 end;
 fillchar(v,sizeof(v),0);
 t:=0;
 for i:=1 to n do new[i]:=i;
 dfs1(1,-1);

for i:=1 to m do begin
                  x[i]:=new[x[i]];
                  y[i]:=new[y[i]];
                 end;
fillchar(p,sizeof(p),-1);
for i:=1 to m do
if x[i]<>y[i] then begin
p[x[i]]:=p[x[i]]+1;
p[y[i]]:=p[y[i]]+1;
end else o[x[i]]:=1;

 for i:=1 to n do setlength(c[i],p[i]+1);
 for j:=1 to n do p[j]:=-1;
 for i:=1 to m do if x[i]<>y[i] then
 begin
 p[x[i]]:=p[x[i]]+1;
 p[y[i]]:=p[y[i]]+1;
 c[y[i],p[y[i]]]:=x[i];
 c[x[i],p[x[i]]]:=y[i];
 end;

 {
for i:=1 to n do
begin
if o[i]=1 then write(i,'* ') else write(i,'  ');
for j:=0 to p[i] do write(c[i,j],' ');
writeln;
end;}
  t:=0;
  t2:=0;
   fillchar(v,sizeof(v),0);
   fillchar(s,sizeof(s),0);
  dfs2(1,1);
  for j:=1 to 20 do
   for i:=1 to n do begin
   w[i][j]:=w[w[i][j-1]][j-1];
   end;
readln(q);
e[0]:=1;
for i:=1 to 100000 do e[i]:=(e[i-1] shl 1) mod 1000000007;
for i:=1 to q do  begin
readln(a,b);
a:=new[a];
b:=new[b];
m:=lca(a,b);
sol:=suma[a]+suma[b]-2*suma[m]+o[m];

writeln(e[sol]);
end;

end.


type mass=array[1..100000] of integer;
Var m:mass; z,a,j,rez,b,i,n,kol:integer;
procedure swap(h,f:integer);
var a:integer;
Begin
   a:=m[h];
   m[h]:=m[f];
   m[f]:=a;
end;
begin
   // assign(input,'input.txt');
   // assign(output,'output.txt');
    readln(n);
    if n<3
    then Begin
            writeln(-1);
            halt(0);
         end;
    a:=0;
    for i:=1 to n do
       Begin
          read(m[i]);
          if m[i]=m[1]
          then inc(a);
       end;
    if a=n
    then Begin
            writeln(-1);
            halt(0);
         end;
    for i:=1 to n do
       for z:=i+1 to n do
          if m[z]<>m[i]
          then Begin
                  swap(i,z);
                  b:=2;
                  while m[b]=m[1] do
                     inc(b);
                  if m[b]>m[1]
                  then for j:=b to n do
                          Begin
                            if m[j]<m[j-1]
                            then Begin
                                    writeln(i,' ',z);
                                    halt(0);
                                 end;
                          end
                  else for j:=b to n do
                         if m[j]>m[j-1]
                         then Begin
                                 writeln(i,' ',z);
                                 halt(0);
                              end;
                  swap(i,z);
               end;
    writeln(-1);
end.


{$R+,Q+,I+]
{$apptype console}
{$maxstacksize 10000000}
Uses SysUtils;
Var
   i,j,k:Integer;
   m,md,f,t,ans,y:Int64;
   g,p,h,w,a:Array[0..300000] of Int64;
   dp:Array[0..10,-10..10,0..2] of Int64;
Procedure Solve(i,sum,f:Integer);
Var
   j,i1:Integer;
   r,pr:Int64;
Begin
   If f=1 Then Begin
      If sum>=w[1] Then Exit;
   End;
   If i>7 Then Begin
      For j:=0 To y-1 Do h[j]:=0;
      For j:=2 To 7 Do h[w[j]]:=h[w[j]]+1;
      pr:=1;
      For i1:=0 To y-1 Do Begin
         r:=0;
         For j:=1 To h[i1] Do Begin
            pr:=(pr*(p[i1]-r)) mod md;
            r:=r+1;
         End;
      End;
      pr:=(pr*p[w[1]]) mod md;
      ans:=(ans+pr) mod md;
      Exit;
   End;
   For j:=0 To y Do Begin
      w[i]:=j;
      If i<>1 Then Solve(i+1,sum+j,1)
              Else Solve(i+1,sum,1);
   End;
End;
Begin
   Read(m);
   md:=1000000007;
   t:=m;
   i:=0;
   While t>0 Do Begin
      i:=i+1;
      t:=t div 10;
   End;
   y:=i;
   t:=m;
   i:=y;
   While t>0 Do Begin
      g[i]:=t mod 10;
      i:=i-1;
      t:=t div 10;
   End;
   If g[1]<>1 Then dp[1,0,0]:=1
              Else dp[1,0,1]:=1;
   For i:=2 To 9 Do Begin
      f:=0;
      If i=g[1] Then f:=1;
      If i<=g[1] Then Begin
         If (i<>4) and (i<>7) Then dp[1,0,f]:=dp[1,0,f]+1
                              Else dp[1,1,f]:=dp[1,1,f]+1;
      End;
      If i>g[1] Then Begin
         If (i<>4) and (i<>7) Then dp[1,0,2]:=dp[1,0,2]+1
                              Else dp[1,1,2]:=dp[1,1,2]+1;
      End;
   End;
   For i:=2 To y Do
      For j:=0 To y Do Begin
         dp[i,j,0]:=dp[i-1,j,0];
         If g[i]<>0 Then dp[i,j,0]:=dp[i,j,0]+dp[i-1,j,1];
         dp[i,j,2]:=dp[i-1,j,2];
         If g[i]=0 Then dp[i,j,1]:=dp[i-1,j,1];
         For k:=1 To 9 Do Begin
            If (k<>4) and (k<>7) Then Begin
               dp[i,j,0]:=dp[i,j,0]+dp[i-1,j,0];
               If k<g[i] Then dp[i,j,0]:=dp[i,j,0]+dp[i-1,j,1];
               dp[i,j,2]:=dp[i,j,2]+dp[i-1,j,2];
               If k>g[i] Then dp[i,j,2]:=dp[i,j,2]+dp[i-1,j,1];
            End
            Else Begin
               dp[i,j,0]:=dp[i,j,0]+dp[i-1,j-1,0];
               If k<g[i] Then dp[i,j,0]:=dp[i,j,0]+dp[i-1,j-1,1];
               dp[i,j,2]:=dp[i,j,2]+dp[i-1,j-1,2];
               If k>g[i] Then dp[i,j,2]:=dp[i,j,2]+dp[i-1,j-1,1];
            End;
            If k=g[i] Then Begin
               If (k<>4) and (k<>7) Then dp[i,j,1]:=dp[i-1,j,1]
                                    Else dp[i,j,1]:=dp[i-1,j-1,1];
            End;
         End;
      End;
   For j:=0 To y Do
      For k:=1 To y Do
         If k<>y Then p[j]:=p[j]+dp[k,j,0]+dp[k,j,1]+dp[k,j,2]
                 Else p[j]:=p[j]+dp[k,j,0]+dp[k,j,1];
   ans:=0;
   Solve(1,0,0);
   Write(ans);
End.


Var z,m:array [1..100] of longint;
b,a:array [1..100] of Boolean;
i1,j,n,i:longint;
f:boolean;
procedure dfs(v:longint);
begin
  if a[v]
  then Exit;
  a[v]:=true;
  if v+z[v]<=n
  then dfs(v+z[v]);
  if v-z[v]>=1
  then dfs(v-z[v]);
end;

procedure dfs1(v:longint);
begin
  if b[v]
  then Exit;
  b[v]:=true;
  if v+z[v]<=n
  then dfs1(v+z[v]);
  if v-z[v]>=1
  then dfs1(v-z[v]);
end;
begin
//  Assign(input,'input.txt');
//  Assign(output,'output.txt');
  Readln(n);
  for i:=1 to n do
  read(m[i]);
  for i:=1 to n do
  read(z[i]);
  for i:=1 to n do
  begin
  FillChar(a,SizeOf(a),false);
  dfs(i);
   for j:=1 to n do
   if i<>j
   then
   begin
      FillChar(b,SizeOf(b),false);
      dfs1(j);
      f:=false;
      for i1:=1 to n do
      if a[i1] and b[i1]
      then begin
            f:=True;
            break;
           end;
      if f
      then for i1:=1 to n do
           a[i1]:=a[i1] or b[i1];
   end;
   if a[m[i]]=false
   then begin writeln('NO'); halt(0); end;
  end;
  writeln('YES');
end.


{$R+}{$Q-}{$O-}
Uses math;
Var m1,m:array [0..3200,0..3200] of LongInt;
a:array [1..2,1..100000] of longint;
a5,a4:array [0..3200,0..3200] of longint;
pred,m2,zz:array [1..100000] of longint;
i2,j2,used:array [1..3200] of Boolean;
mt:array [1..3200] of longint;
kol,i1,k,rez,n,i,j:longint;
s:longint;
f:boolean;
procedure add(i,j:longint);
begin
  m2[kol]:=j;
  pred[kol]:=zz[i];
  zz[i]:=kol;
end;
function dfs(v:longint):boolean;
Var i:longint;
begin
  if used[v]
  then begin dfs:=false; exit; end;
  used[v]:=true;
  i:=zz[v];
  while i<>0 do
  begin
    if (mt[m2[i]]=-1)or(dfs(mt[m2[i]]))
    then begin
          mt[m2[i]]:=v;
          dfs:=true;
          exit;
         end;
    i:=pred[i];
  end;
  dfs:=false;
end;
procedure dfs2(v:longint);
Var i:longint;
begin
  if i2[v]
  then exit;
  i2[v]:=true;
  i:=zz[v];
  while i<>0 do
  begin
    if (mt[m2[i]]<>-1)and(mt[m2[i]]<>v)
    then begin j2[m2[i]]:=True; dfs2(mt[a[2,i]]); end;
    i:=pred[i];
  end;
end;
begin
  //Assign(input,'input.txt'); reset(input);
  //Assign(output,'output.txt'); rewrite(output);
  Readln(n,k);
  for i:=1 to n do
  for j:=1 to k do
  read(a4[i,j]);
  for i:=1 to (n*k) div 2 do
  for j:=1 to (n*k) div 2 do
  m[i,j]:=10000;
  s:=0;
  i1:=0;
  for i:=1 to n do
  for j:=1 to k do
  if (i+j) mod 2=0
  then begin
        inc(s);
        a5[i,j]:=s;
       end
  else begin
        inc(i1);
        a5[i,j]:=i1;
       end;
  for i:=1 to n do
  for j:=1 to k do
  if (i+j) mod 2=0
  then begin
        if a4[i,j]=a4[i,j+1]
        then m[a5[i,j],a5[i,j+1]]:=0
        else m[a5[i,j],a5[i,j+1]]:=1;
        if a4[i,j]=a4[i,j-1]
        then m[a5[i,j],a5[i,j-1]]:=0
        else m[a5[i,j],a5[i,j-1]]:=1;
        if a4[i,j]=a4[i+1,j]
        then m[a5[i,j],a5[i+1,j]]:=0
        else m[a5[i,j],a5[i+1,j]]:=1;
        if a4[i,j]=a4[i-1,j]
        then m[a5[i,j],a5[i-1,j]]:=0
        else m[a5[i,j],a5[i-1,j]]:=1;
      end;
  n:=(n*k) div 2;
  k:=n;
  m1:=m;

  while 1=1 do
  begin
  for i:=1 to k do
  begin
    i1:=MaxLongint;
    for j:=1 to k do
    i1:=min(i1,m[i,j]);
    for j:=1 to k do
    m[i,j]:=m[i,j]-i1;
  end;
  for j:=1 to k do
  begin
    i1:=MaxLongint;
    for i:=1 to k do
    i1:=min(i1,m[i,j]);
    for i:=1 to k do
    m[i,j]:=m[i,j]-i1;
  end;
    FillChar(zz,SizeOf(zz),0);
    kol:=0;
    for i:=1 to k do
    for j:=1 to k do
    if m[i,j]=0
    then begin
          inc(kol);
          add(i,j);
          a[1,kol]:=i;
          a[2,kol]:=j;
         end;
    for i:=1 to k do
    mt[i]:=-1;
    for i:=1 to k do
    begin
      FillChar(used,SizeOf(used),false);
      dfs(i);
    end;
    f:=true;
    fillchar(used,sizeof(used),false);
    for i:=1 to k do
    if mt[i]=-1
    then f:=False
    else used[mt[i]]:=true;
    FillChar(i2,sizeof(i2),false);
    FillChar(j2,sizeof(j2),false);
    if f
    then Break;
    for i:=1 to k do
    if not used[i]
    then dfs2(i);
    i1:=MaxLongint;
    for i:=1 to k do
    if i2[i]
    then
    for j:=1 to k do
    if (not j2[j])and(m[i,j]<>0)
    then i1:=min(i1,m[i,j]);
    for i:=1 to k do
    if i2[i]
    then
    for j:=1 to k do
    m[i,j]:=m[i,j]-i1;
    for j:=1 to k do
    if j2[j]
    then  for i:=1 to k do
          m[i,j]:=m[i,j]+i1;
  end;
  m:=m1;
  rez:=0;
  for i:=1 to k do
  rez:=rez+m[mt[i],i];
  Writeln(rez);
end.


{$R-,S-,Q-,I-,O+}
{$M 32000000}

{$APPTYPE CONSOLE}

uses Math;
const
    inf = round(1e9);
    maxn = round(1e1) + 200;
    md = round(1e9) + 7;
type
    node = record
             val, id : longint;
           end;
    edge = record
             u, f, t, cost : longint;
           end;
var
    n, k, i, j, heap_sz, ll, rr, mid : longint;
    cost : int64;
    e : array of edge;
    g : array [1..maxn] of array of longint;
    d, phi, vert, p, p_rib : array [1..maxn] of longint;
    h : array [1..maxn] of node;
    c : array [1..maxn, 1..maxn] of longint;

  procedure AddEdge(a, b, cap, cost : longint);
  var
     cur : edge;
  begin
    cur.u := cap; cur.f := 0; cur.t := b; cur.cost := cost;
    setlength(e, length(e) + 1);
    e[length(e) - 1] := cur;
    setlength(g[a], length(g[a]) + 1);
    g[a][length(g[a]) - 1] := length(e) - 1;

    cur.u := 0; cur.f := 0; cur.t := a; cur.cost := -cost;
    setlength(e, length(e) + 1);
    e[length(e) - 1] := cur;
    setlength(g[b], length(g[b]) + 1);
    g[b][length(g[b]) - 1] := length(e) - 1;
  end;

  procedure heapify(v : longint);
  var
    l, r, lowest : longint;
    t : node;
  begin
    l := v shl 1;
    r := v shl 1 + 1;
    if (l <= heap_sz) and (h[l].val < h[v].val) then lowest := l
                                                else lowest := v;
    if (r <= heap_sz) and (h[r].val < h[lowest].val) then lowest := r;
    if lowest <> v then
    begin
      vert[h[lowest].id] := v;
      vert[h[v].id] := lowest;
      t := h[v]; h[v] := h[lowest]; h[lowest] := t;
      heapify(lowest);
    end;
  end;

  procedure build_heap();
  var
     i : longint;
  begin
    heap_sz := n;
    for i := n shr 1 downto 1 do heapify(i);
  end;

  function extract_min() : longint;
  begin
    extract_min := h[1].id;
    h[1] := h[heap_sz];
    vert[h[heap_sz].id] := 1;
    dec(heap_sz);
    heapify(1);
  end;

  procedure decrease_key(v, x : longint);
  var
     t : node;
  begin
    h[v].val := x;
    while (v > 1) and (h[v shr 1].val > h[v].val) do
    begin
      vert[h[v].id] := v shr 1;
      vert[h[v shr 1].id] := v;
      t := h[v]; h[v] := h[v shr 1]; h[v shr 1] := t;
      v := v shr 1;
    end;
  end;

  procedure dijkstra(ss : longint);
  var
     v, i, id, w, t : longint;
  begin
    for i := 1 to n do
    begin
      d[i] := inf;
      vert[i] := i;
      h[i].val := inf;
      h[i].id := i;
    end;
    h[ss].val := 0;
    d[ss] := 0;
    build_heap();
    while heap_sz > 0 do
    begin
      v := extract_min();
      if d[v] = inf then break;
      for i := 0 to length(g[v]) - 1 do
      begin
        id := g[v][i];
        t := e[id].t;
        w := d[v] + e[id].cost + phi[v] - phi[t];
        if (w < d[t]) and (e[id].u - e[id].f > 0) then
        begin
          d[t] := w;
          p[t] := v;
          p_rib[t] := i;
          Decrease_Key(vert[t], d[t]);
        end;
      end;
    end;
  end;

  procedure FB(ss : longint);
  var
    i, j, r, id : longint;
    any : boolean;
  begin
    for i := 1 to n do d[i] := inf;
    d[ss] := 0;
    for i := 1 to n - 1 do
    begin
      any := false;
      for j := 1 to n do
        for r := 0 to length(g[j]) - 1 do
        begin
          id := g[j][r];
          if (e[id].u - e[id].f > 0) and (d[e[id].t] > d[j] + e[id].cost) then
          begin
            d[e[id].t] := d[j] + e[id].cost;
            any := true;
          end;
        end;
      if not any then break;
    end;

    for i := 1 to n do phi[i] := d[i];
  end;

  function mcmf(ss, tt, want : longint) : int64;
  var
     i, v, pv, pr, id : longint;
     maxflow, addflow, cost : int64;
  begin
    maxflow := 0;
    cost := 0;
    FB(ss);
    while maxflow < want do
    begin
      dijkstra(ss);
      if d[tt] = inf then break;
      for i := 1 to n do
      if d[i] < inf then phi[i] := phi[i] + d[i];

      addflow := want - maxflow;
      v := tt;
      while v <> ss do
      begin
        pv := p[v];
        pr := p_rib[v];
        id := g[pv][pr];
        addflow := min(addflow, e[id].u - e[id].f);
        v := pv;
      end;

      v := tt;
      while v <> ss do
      begin
        pv := p[v];
        pr := p_rib[v];
        id := g[pv][pr];
        e[id].f := e[id].f + addflow;
        e[id xor 1].f := e[id xor 1].f - addflow;
        cost := cost + int64(addflow) * e[id].cost;
        v := pv;
      end;

      maxflow := maxflow + addflow;
    end;

   if maxflow < want then mcmf := inf
                     else mcmf := cost;
  end;

begin
  //assign(input,'input.txt'); reset(input);
  //assign(output,'output.txt'); rewrite(output);
  randomize;
  readln(n, k);
  for i := 1 to n do
  begin
    for j := 1 to n do read(c[i][j]);
    readln;
  end;

  ll := 0;
  rr := 51 * round(1e6);
  while ll < rr do
  begin
    mid := (ll + rr) shr 1;
    for i := 1 to n do setlength(g[i], 0);
    setlength(e, 0);
    for i := 1 to n do
      for j := 1 to n do
      if c[i][j] > 0 then
      begin
        AddEdge(i, j, c[i][j], 0);
        AddEdge(i, j, inf, 1);
      end;
    cost := mcmf(1, n, mid);
    if cost <= k then ll := mid + 1
                 else rr := mid;
  end;
  setlength(e, 0);
  for i := 1 to n do
    for j := 1 to n do
    if c[i][j] > 0 then
    begin
      AddEdge(i, j, c[i][j], 0);
      AddEdge(i, j, inf, 1);
    end;
  cost := mcmf(1, n, ll);
  if cost > k then dec(ll);

  writeln(ll);
end.


const w:array[1..3]of int64=(1,1,0);
      z:array[1..3]of int64=(-1,0,1);
var n,m,x,i,j,k,l,t,o:longint;
    f:array[0..999,0..999]of int64;
begin
  f[0,0]:=1;
  read(n,m,x);
  if m<n then
    begin
      write(0);
      halt
    end;
  for i:=1to m do
    begin
      if i<n then t:=i
      else t:=n;
      for j:=t downto 0do
        for k:=t-j downto 0do
          if f[j,k]>0then
            begin
              inc(f[j+1,k],f[j,k]);
              inc(f[j,k+1],f[j,k]);
              if x=i then f[j,k]:=0
              else if k>0then inc(f[j+1,k-1],f[j,k]);
              for o:=1to 3do
                if f[j+w[o],k+z[o]]>=1000000007then dec(f[j+w[o],k+z[o]],1000000007)
            end;
    end;
  for i:=1to n do
    f[n,0]:=f[n,0]*i mod 1000000007;
  write(f[n,0])
end.


uses math;
type mass=array[0..500,0..500] of int64;
     maxx=array[0..500] of int64;
var m,m1,m2,res:mass;m3:maxx;ch,ch1:char;d,x1,x2,x3,c,kol,w,k,l,r,a,b,e,n:int64;i,z,j:longint;u:boolean;s:string;
const dd=-maxlongint;
Begin
//   assign(input,'input.txt');
//   assign(output,'output.txt');
   readln(n,k);
   for i:=1 to n do
      for z:=1 to n do
         if i<>z
         then Begin
                 m[i,z]:=maxlongint;
                 m1[i,z]:=maxlongint;
              end;
   for i:=1 to k do
      Begin
         readln(a,b,c);
         m[a,b]:=min(m[a,b],c);
         m[b,a]:=min(m[b,a],c);
         m1[a,b]:=min(m1[a,b],c);
         m1[b,a]:=min(m1[b,a],c);
         m2[a,b]:=1;
         m2[b,a]:=1;
      end;
   for i:=1 to n do
      for z:=1 to n do
         for j:=1 to n do
            if (m[i,z]<maxlongint) and (m[z,i]+m[i,j]<=m[z,j])
            then m[z,j]:=m[z,i]+m[i,j];
   for i:=1 to n do
     Begin
         fillchar(m3,sizeof(m3),0);
         for z:=1 to n do
            for j:=1 to n do
               if (z<>j) and (m[z,j]<>maxlongint) and (m[j,i]+m1[z,j]=m[z,i])
               then inc(m3[z]);
         for z:=1 to n do
            for j:=1 to n do
               if m[z,j]+m[j,i]=m[z,i]
               then inc(res[z,i],m3[j]);
     end;
   for i:=1 to n do
      for z:=i+1 to n do
         write(res[i,z],' ');
end.


var
 a,b,i,j,k,n,tt1,tt2,x,ans,s,ss:longint;
 tt,ww:array [0..100,0..202] of longint;
 vv:array [0..100,0..202] of integer;
 zt:array [0..100] of integer;
 zz1,zz2,yy1,yy2:array [0..202] of longint;
function min(a,b:longint):longint;
 begin
 if a>b then
  begin
  min:=b;
  exit;
  end;
 min:=a;
 end;
procedure swap(var a,b:longint);
 var t:longint;
 begin
 t:=a; a:=b; b:=t;
 end;
procedure qsort(x,l,r:longint);
 var xx,i,j:longint;
 begin
 i:=l; j:=r;
 xx:=tt[x,(l+r) div 2];
 while i<=j do
  begin
  while tt[x,i]<xx do inc(i);
  while tt[x,j]>xx do dec(j);
  if i<=j then
   begin
   swap(ww[x,i],ww[x,j]);
   swap(tt[x,i],tt[x,j]);
   inc(i); dec(j);
   end;
  end;
 if l<j then qsort(x,l,j);
 if i<r then qsort(x,i,r);
 end;
begin
{ assign(input,'a.in');
reset(input);
assign(output,'a.out');
rewrite(output);   }
 readln(n,s);
 for i:=1 to n do
  begin
  read(k);
  for j:=1 to k do
   begin
   read(vv[i,j],tt[i,j+1]);
   ww[i,j+1]:=ww[i,j]+vv[i,j]*tt[i,j+1];
   tt[i,j+1]:=tt[i,j+1]+tt[i,j];
   end;
  zt[i]:=k+1;
  readln;
  end;
 for i:=1 to n-1 do
  for j:=i+1 to n do
   begin
   for k:=1 to zt[i] do
     begin
     zz1[k]:=ww[i,k]; yy1[k]:=tt[i,k];
     end;
   for k:=1 to zt[j] do
     begin
     zz2[k]:=ww[j,k]; yy2[k]:=tt[j,k];
     end;
   tt1:=zt[i]; tt2:=zt[j];
   x:=1;
   for k:=2 to zt[i] do
    begin
    if tt[i,k]>=tt[j,zt[j]] then break;
    while (tt[j,x]<=tt[i,k])  do inc(x);
    dec(x);
    if tt[j,x]=tt[i,k] then continue;
    inc(tt2); ww[j,tt2]:=ww[j,x]+(tt[i,k]-tt[j,x])*vv[j,x];
    tt[j,tt2]:=tt[i,k];
    end;
  x:=1;
  for k:=2 to zt[j] do
   begin
   if tt[j,k]>=tt[i,zt[i]] then break;
   while (tt[i,x]<=tt[j,k])  do inc(x);
   dec(x);
   if tt[i,x]=tt[j,k] then continue;
   inc(tt1); ww[i,tt1]:=ww[i,x]+(tt[j,k]-tt[i,x])*vv[i,x];
   tt[i,tt1]:=tt[j,k];
   end;
  qsort(i,1,tt1); qsort(j,1,tt2);
  x:=min(tt1,tt2);
  ss:=0;
  for k:=2 to x do
   begin
   if ww[i,k]>ww[j,k] then s:=1
    else if ww[i,k]<ww[j,k] then s:=-1
     else s:=ss;
   if ss*s=-1 then inc(ans);
   ss:=s;
   end;
   for k:=1 to zt[i] do
     begin
     ww[i,k]:=zz1[k]; tt[i,k]:=yy1[k];
     end;
  for k:=1 to zt[j] do
     begin
     ww[j,k]:=zz2[k]; tt[j,k]:=yy2[k];
     end;
  end;
 writeln(ans);
{ close(input);
close(output);   }
end.


program solution;

{$APPTYPE CONSOLE}
{MODE DELPHI}
{$MAXSTACKSIZE 1000000000}
{O-,R+,Q+}
{$O+,R-,Q-}

uses
  SysUtils,
  Math;

var
  n, a, b, e, num, all, mask, i, j, z, t : integer;
  c : char;
  fl : boolean;
  sz : array[0..6] of integer;
  m, next1, next2 : array[0..6, 0..6] of integer;
  d : array[0..600001] of boolean;

procedure getc(var c : char);
begin
  read(c);
  while not (c in ['.', 'O']) do
    read(c);
end;

function good(a, b : integer) : boolean;
begin
  result := a and (1 shl (b - 1)) > 0;
end;

function add(a, b : integer) : integer;
begin
  result := a xor (1 shl (b - 1));
end;

begin
  //assign(input, 'input.txt'); reset(input);
  //assign(output, 'output.txt'); rewrite(output);
  n := 0;
  sz[1] := 3;
  sz[2] := 4;
  sz[3] := 5;
  sz[4] := 4;
  sz[5] := 3;
  for i := 1 to 5 do
    for j := 1 to sz[i] do begin
      getc(c);
      if c = 'O' then begin
        inc(n);
        m[i, j] := n;
      end;
    end;
  next1[1, 1] := 1;
  next1[1, 2] := 2;
  next1[1, 3] := 3;
  next1[2, 1] := 1;
  next1[2, 2] := 2;
  next1[2, 3] := 3;
  next1[2, 4] := 4;
  next1[3, 2] := 1;
  next1[3, 3] := 2;
  next1[3, 4] := 3;
  next1[3, 5] := 4;
  next1[4, 2] := 1;
  next1[4, 3] := 2;
  next1[4, 4] := 3;
  next2[1, 1] := 2;
  next2[1, 2] := 3;
  next2[1, 3] := 4;
  next2[2, 1] := 2;
  next2[2, 2] := 3;
  next2[2, 3] := 4;
  next2[2, 4] := 5;
  next2[3, 1] := 1;
  next2[3, 2] := 2;
  next2[3, 3] := 3;
  next2[3, 4] := 4;
  next2[4, 1] := 1;
  next2[4, 2] := 2;
  next2[4, 3] := 3;
  all := 1 shl n - 1;
  for i := 1 to all do begin
    fl := false;
    for j := 1 to 5 do begin
      for z := 1 to sz[j] do begin
        a := m[j, z];
        if (a > 0) and (good(i, a)) then begin
          b := add(i, a);
          if not d[b] then begin
            fl := true;
            break;
          end;
          mask := b;
          for t := 1 to sz[j] do begin
            e := m[j, z + t];
            if (e > 0) and (good(i, e)) then begin
              mask := add(mask, e);
              if not d[mask] then begin
                fl := true;
                break;
              end;
            end
            else
              break;
          end;
          if fl then
            break;
          mask := b;
          num := next1[j, z];
          for t := 1 to 5 do begin
            e := m[j + t, num];
            if (e > 0) and (good(i, e)) then begin
              mask := add(mask, e);
              if not d[mask] then begin
                fl := true;
                break;
              end;
            end
            else
              break;
            num := next1[j + t, num];
          end;
          if fl then
            break;
          mask := b;
          num := next2[j, z];
          for t := 1 to 5 do begin
            e := m[j + t, num];
            if (e > 0) and (good(i, e)) then begin
              mask := add(mask, e);
              if not d[mask] then begin
                fl := true;
                break;
              end;
            end
            else
              break;
            num := next2[j + t, num];
          end;
          if fl then
            break;
        end;
      end;
      if fl then

        break;
    end;
    d[i] := fl;
  end;
  if d[all] then
    writeln('Karlsson')
  else
    writeln('Lillebror');
end.


Var zz,l,r:int64;
z,i:longint;
function kol(x:int64):longint;
Var n:longint;
begin
  n:=0;
  while x<>0 do
  begin
    x:=x div 10;
    inc(n);
  end;
  kol:=n;
end;
function probeg(x:int64):int64;
Var z,rez:int64;
begin
  rez:=0;
  z:=1;
  while x<>0 do
  begin
    rez:=rez+z*(9-x mod 10);
    x:=x div 10;
    z:=z*10;
  end;
  probeg:=rez;
end;
begin
//  Assign(input,'input.txt'); reset(input);
//  Assign(output,'output.txt'); rewrite(output);
  read(l,r);
  if kol(l)<>kol(r)
  then begin
         z:=kol(r);
         l:=1;
         for i:=1 to z-1 do
         l:=l*10;
       end;
  z:=kol(r);
  zz:=1;
  for i:=1 to z-1 do
  zz:=zz*10;
  if r<=5*zz-1
  then writeln(r*probeg(r))
  else begin
        if l>5*zz-1
        then writeln(l*probeg(l))
        else writeln((5*zz-1)*probeg(5*zz-1));
       end;
end.