<?php
$paragraphs = intval(trim(fgets(STDIN)));
$unreaded = $paragraphs;

while (STDIN && $paragraphs != 0) {
    $paragraph[] = explode(' ', trim(fgets(STDIN)));
    $paragraphs--;
}

$readed = intval(trim(fgets(STDIN)));

$i = 0;
foreach ($paragraph as $val) {
    if (filter_var(
        $readed,
        FILTER_VALIDATE_INT,
        array(
      'options' => array(
          'min_range' => $val[0],
          'max_range' => $val[1]
      )
    )
    )) {
        echo $unreaded - $i . PHP_EOL;
    } else {
        $i++;
    }
}

<?php

$n = trim(fgets(STDIN));

$r = [];

for($i = 0; $i<$n; $i++){
	$data = explode(' ', trim(fgets(STDIN)));
	$r[] = $data[1];
}

$k = trim(fgets(STDIN));
$c = 0;
for($i = 0; $i<$n; $i++){
	if($k > $r[$i]){
		$c++;
	}
}

fwrite(STDOUT, $n-$c);

?>

<?php
$n = fgets(STDIN);
$array;
for($i = 0; $i < $n; $i++){
    list($array[$i][0], $array[$i][1]) = explode(' ', fgets(STDIN));
}
$k = (int) fgets(STDIN);
for($i = 0; $i < $n; $i++){
    if($array[$i][0] <= $k && $array[$i][1] >= $k){
        $n = $n - $i;
        echo $n;
        return 0;
    }
}
?>

<?php

    $stdin = fopen('php://stdin', 'r');
    // $stdout = fopen('php://stdout', 'w');

    // $input = $_GET['url'];
    // $inputArray = explode('/', $input);

    // $nrParams = count($inputArray);

    // $nrChapters = (int)$nrChapters;

    $input = stream_get_contents($stdin);

    $arr = preg_split("/\r\n|\n|\r/", $input);

    $nrChapters = (int)$arr[0];

    for($i = 1; $i <= $nrChapters; $i++) {
        $chaptersDescription[$i] = array_map(function($val){ return (int)$val;}, explode(" ", trim($arr[$i])));
        // echo $inputArray[$i][0] . " : " . $inputArray[$i][1] . "\n";
    }

    $unreadPageIndex = (int)trim($arr[count($arr) - 2]);
    // echo $arr[count($arr) - 2] . "\n";
    // echo $unreadPageIndex . "\n";
    // exit();
    // for($i = 0; $i < $nrChapters; $i++) {

    // }

    // if ($nrParams < 3) {
    //     echo "There are less parameters than expected!";
    //     exit();
    // }

    // $nrChapters = $inputArray[0];
    // $nrLinesDescribingChapters = $nrParams - 2;
    // $unreadPageIndex = $inputArray[$nrParams - 1];

    // unset($inputArray[0], $inputArray[$nrParams - 1]);

    // if ($nrChapters != $nrParams - 2) {
    //     echo "Wrong number of parameters!";
    //     exit();
    // }

    foreach ($chaptersDescription as $index => $chapter) {
        if ($unreadPageIndex <= (int)$chapter[1]) {
            $chaptersRemained = $nrChapters - $index + 1;
            echo $chaptersRemained;
            exit();
        }

        if ($index == $nrChapters){
            echo "Wrong unread page index!";
            exit();
        }
    }

<?php
$a = trim(fgets(STDIN));
$b = array();
$c = 1;
for($x = 0; $x < $a; $x++)
{
     list($d, $e) = explode(" ", trim(fgets(STDIN)));
     for($y = $d; $y <= $e; $y++)
     {
          $b[$y] = $c;
     }
     $c++;
}
$f = trim(fgets(STDIN));
print $a - $b[$f] + 1;
?>

<?php
$n = fgets(STDIN);
$array;
$count = 0;
for($i = 0; $i < $n; $i++){
    list($array[$i][0], $array[$i][1]) = explode(' ', fgets(STDIN));
}
$k = fgets(STDIN);
for($i = 0; $i < $n; $i++){
    if($array[$i][0] <= $k && $array[$i][1] >= $k){
        echo $n - $i;
        return 0;
    }
}
?>

<?php

    $stdin = fopen('php://stdin', 'r');
    // $stdout = fopen('php://stdout', 'w');

    // $input = $_GET['url'];
    // $inputArray = explode('/', $input);

    // $nrParams = count($inputArray);

    // $nrChapters = (int)$nrChapters;

    $input = stream_get_contents($stdin);

    $arr = preg_split("/\r\n|\n|\r/", $input);

    $nrChapters = (int)$arr[0];

    for($i = 1; $i <= $nrChapters; $i++) {
        $inputArray[$i] = array_map(function($val){ return (int)$val;}, explode(" ", trim($arr[$i])));
    }

    $unreadPageIndex = (int)trim(end($arr));
    echo $unreadPageIndex;
    exit();
    // for($i = 0; $i < $nrChapters; $i++) {

    // }

    // if ($nrParams < 3) {
    //     echo "There are less parameters than expected!";
    //     exit();
    // }

    // $nrChapters = $inputArray[0];
    // $nrLinesDescribingChapters = $nrParams - 2;
    // $unreadPageIndex = $inputArray[$nrParams - 1];

    // unset($inputArray[0], $inputArray[$nrParams - 1]);

    // if ($nrChapters != $nrParams - 2) {
    //     echo "Wrong number of parameters!";
    //     exit();
    // }

    $chaptersDescription = array_map(
        function ($value) {
            $array = explode(' ', $value);

            return $array;
        },
        $inputArray
    );

    foreach ($chaptersDescription as $index => $chapter) {
        if ($unreadPageIndex <= (int)$chapter[1]) {
            $chaptersRemained = $nrChapters - $index + 1;
            echo $chaptersRemained;
            exit();
        }

        if ($index == $nrChapters){
            echo "Wrong unread page index!";
            exit();
        }
    }

<?php

    $stdin = fopen('php://stdin', 'r');
    // $stdout = fopen('php://stdout', 'w');

    // $input = $_GET['url'];
    // $inputArray = explode('/', $input);

    // $nrParams = count($inputArray);

    // $nrChapters = (int)$nrChapters;

    $input = stream_get_contents($stdin);

    $arr = preg_split("/\r\n|\n|\r/", $input);

    $nrChapters = (int)$arr[0];

    for($i = 1; $i <= $nrChapters; $i++) {
        $inputArray[$i] = array_map(function($val){ return (int)$val;}, explode(" ", trim($arr[$i])));
    }

    $unreadPageIndex = (int)trim($arr[count($arr) - 1]);
    echo $unreadPageIndex;
    exit();
    // for($i = 0; $i < $nrChapters; $i++) {

    // }

    // if ($nrParams < 3) {
    //     echo "There are less parameters than expected!";
    //     exit();
    // }

    // $nrChapters = $inputArray[0];
    // $nrLinesDescribingChapters = $nrParams - 2;
    // $unreadPageIndex = $inputArray[$nrParams - 1];

    // unset($inputArray[0], $inputArray[$nrParams - 1]);

    // if ($nrChapters != $nrParams - 2) {
    //     echo "Wrong number of parameters!";
    //     exit();
    // }

    $chaptersDescription = array_map(
        function ($value) {
            $array = explode(' ', $value);

            return $array;
        },
        $inputArray
    );

    foreach ($chaptersDescription as $index => $chapter) {
        if ($unreadPageIndex <= (int)$chapter[1]) {
            $chaptersRemained = $nrChapters - $index + 1;
            echo $chaptersRemained;
            exit();
        }

        if ($index == $nrChapters){
            echo "Wrong unread page index!";
            exit();
        }
    }

<?php

    $stdin = fopen('php://stdin', 'r');
    // $stdout = fopen('php://stdout', 'w');

    // $input = $_GET['url'];
    // $inputArray = explode('/', $input);

    // $nrParams = count($inputArray);

    // $nrChapters = (int)$nrChapters;

    $input = stream_get_contents($stdin);

    $arr = preg_split("/\r\n|\n|\r/", $input);

    $nrChapters = (int)$arr[0];

    for($i = 1; $i <= $nrChapters; $i++) {
        $inputArray[$i] = array_map(function($val){ return (int)$val;}, explode(" ", trim($arr[$i])));
        echo $inputArray[$i][0] . " : " . $inputArray[$i][1] . "\n";
    }

    $unreadPageIndex = (int)trim($arr[count($arr) - 2]);
    // echo $arr[count($arr) - 2] . "\n";
    // echo $unreadPageIndex . "\n";
    // exit();
    // for($i = 0; $i < $nrChapters; $i++) {

    // }

    // if ($nrParams < 3) {
    //     echo "There are less parameters than expected!";
    //     exit();
    // }

    // $nrChapters = $inputArray[0];
    // $nrLinesDescribingChapters = $nrParams - 2;
    // $unreadPageIndex = $inputArray[$nrParams - 1];

    // unset($inputArray[0], $inputArray[$nrParams - 1]);

    // if ($nrChapters != $nrParams - 2) {
    //     echo "Wrong number of parameters!";
    //     exit();
    // }

    $chaptersDescription = array_map(
        function ($value) {
            $array = explode(' ', $value);

            return $array;
        },
        $inputArray
    );

    foreach ($chaptersDescription as $index => $chapter) {
        if ($unreadPageIndex <= (int)$chapter[1]) {
            $chaptersRemained = $nrChapters - $index + 1;
            echo $chaptersRemained;
            exit();
        }

        if ($index == $nrChapters){
            echo "Wrong unread page index!";
            exit();
        }
    }

<?php

    $stdin = fopen('php://stdin', 'r');
    $stdout = fopen('php://stdout', 'w');

    // $input = $_GET['url'];
    // $inputArray = explode('/', $input);

    // $nrParams = count($inputArray);

    // $nrChapters = (int)$nrChapters;

    echo "Epta : '" . stream_get_contents($stdin) . "'";
    exit();

    // for($i = 0; $i < $nrChapters; $i++) {

    // }

    // if ($nrParams < 3) {
    //     echo "There are less parameters than expected!";
    //     exit();
    // }

    // $nrChapters = $inputArray[0];
    // $nrLinesDescribingChapters = $nrParams - 2;
    // $unreadPageIndex = $inputArray[$nrParams - 1];

    // unset($inputArray[0], $inputArray[$nrParams - 1]);

    if ($nrChapters != $nrParams - 2) {
        echo "Wrong number of parameters!";
        exit();
    }

    $chaptersDescription = array_map(
        function ($value) {
            $array = explode(' ', $value);

            return $array;
        },
        $inputArray
    );

    foreach ($chaptersDescription as $index => $chapter) {
        if ($unreadPageIndex <= $chapter[1]) {
            $chaptersRemained = $nrChapters - $index + 1;
            echo $chaptersRemained;
            exit();
        }

        if ($index == $nrChapters){
            echo "Wrong unread page index!";
            exit();
        }
    }

<?php

    $stdin = fopen('php://stdin', 'r');
    $stdout = fopen('php://stdout', 'w');

    // $input = $_GET['url'];
    // $inputArray = explode('/', $input);

    // $nrParams = count($inputArray);

    $nrChapters = stream_get_contents($dir);
    // $nrChapters = (int)$nrChapters;

    fwrite($stdout, "Epta : '" . $nrChapters . "'");
    exit();

    // for($i = 0; $i < $nrChapters; $i++) {

    // }

    // if ($nrParams < 3) {
    //     echo "There are less parameters than expected!";
    //     exit();
    // }

    // $nrChapters = $inputArray[0];
    // $nrLinesDescribingChapters = $nrParams - 2;
    // $unreadPageIndex = $inputArray[$nrParams - 1];

    // unset($inputArray[0], $inputArray[$nrParams - 1]);

    if ($nrChapters != $nrParams - 2) {
        echo "Wrong number of parameters!";
        exit();
    }

    $chaptersDescription = array_map(
        function ($value) {
            $array = explode(' ', $value);

            return $array;
        },
        $inputArray
    );

    foreach ($chaptersDescription as $index => $chapter) {
        if ($unreadPageIndex <= $chapter[1]) {
            $chaptersRemained = $nrChapters - $index + 1;
            echo $chaptersRemained;
            exit();
        }

        if ($index == $nrChapters){
            echo "Wrong unread page index!";
            exit();
        }
    }

<?php

    $stdin = fopen('php://stdin', 'r');
    // $stdout = fopen('php://stdout', 'w');

    // $input = $_GET['url'];
    // $inputArray = explode('/', $input);

    // $nrParams = count($inputArray);

    // $nrChapters = (int)$nrChapters;

    $input = stream_get_contents($stdin);

    $arr = preg_split("/\r\n|\n|\r/", $input);

    $nrChapters = (int)$arr[0];

    for($i = 1; $i <= $nrChapters; $i++) {
        $inputArray[$i] = array_map(function($val){ return (int)$val;}, explode(" ", trim($arr[$i])));
    }

    $unreadPageIndex = (int)trim($arr[count($arr) - 1]);
    // for($i = 0; $i < $nrChapters; $i++) {

    // }

    // if ($nrParams < 3) {
    //     echo "There are less parameters than expected!";
    //     exit();
    // }

    // $nrChapters = $inputArray[0];
    // $nrLinesDescribingChapters = $nrParams - 2;
    // $unreadPageIndex = $inputArray[$nrParams - 1];

    // unset($inputArray[0], $inputArray[$nrParams - 1]);

    // if ($nrChapters != $nrParams - 2) {
    //     echo "Wrong number of parameters!";
    //     exit();
    // }

    $chaptersDescription = array_map(
        function ($value) {
            $array = explode(' ', $value);

            return $array;
        },
        $inputArray
    );

    foreach ($chaptersDescription as $index => $chapter) {
        if ($unreadPageIndex <= $chapter[1]) {
            $chaptersRemained = $nrChapters - $index + 1;
            echo $chaptersRemained;
            exit();
        }

        if ($index == $nrChapters){
            echo "Wrong unread page index!";
            exit();
        }
    }

<?php

    $stdin = fopen('php://stdin', 'r');
    // $stdout = fopen('php://stdout', 'w');

    // $input = $_GET['url'];
    // $inputArray = explode('/', $input);

    // $nrParams = count($inputArray);

    // $nrChapters = (int)$nrChapters;

    $input = stream_get_contents($stdin);

    $arr = preg_split("/\r\n|\n|\r/", $input);

    $nrChapters = (int)$arr[0];

    for($i = 1; $i <= $nrChapters; $i++) {
        $inputArray[$i] = array_map(function($val){ return (int)$val;}, explode(" ", trim($arr[$i])));
    }

    $unreadPageIndex = (int)trim($arr[count($arr) - 2]);
    // echo $arr[count($arr) - 2] . "\n";
    // echo $unreadPageIndex . "\n";
    // exit();
    // for($i = 0; $i < $nrChapters; $i++) {

    // }

    // if ($nrParams < 3) {
    //     echo "There are less parameters than expected!";
    //     exit();
    // }

    // $nrChapters = $inputArray[0];
    // $nrLinesDescribingChapters = $nrParams - 2;
    // $unreadPageIndex = $inputArray[$nrParams - 1];

    // unset($inputArray[0], $inputArray[$nrParams - 1]);

    // if ($nrChapters != $nrParams - 2) {
    //     echo "Wrong number of parameters!";
    //     exit();
    // }

    $chaptersDescription = array_map(
        function ($value) {
            $array = explode(' ', $value);

            return $array;
        },
        $inputArray
    );

    foreach ($chaptersDescription as $index => $chapter) {
        if ($unreadPageIndex <= (int)$chapter[1]) {
            $chaptersRemained = $nrChapters - $index + 1;
            echo $chaptersRemained;
            exit();
        }

        if ($index == $nrChapters){
            echo "Wrong unread page index!";
            exit();
        }
    }

<?php

    $stdin = fopen('php://stdin', 'r');
    $stdout = fopen('php://stdout', 'w');

    // $input = $_GET['url'];
    // $inputArray = explode('/', $input);

    // $nrParams = count($inputArray);

    readline($nrChapters);
    readline($sec);
    // $nrChapters = (int)$nrChapters;

    fwrite($stdout, "Epta : '" . $nrChapters . "' | '$sec'");
    exit();

    // for($i = 0; $i < $nrChapters; $i++) {

    // }

    // if ($nrParams < 3) {
    //     echo "There are less parameters than expected!";
    //     exit();
    // }

    // $nrChapters = $inputArray[0];
    // $nrLinesDescribingChapters = $nrParams - 2;
    // $unreadPageIndex = $inputArray[$nrParams - 1];

    // unset($inputArray[0], $inputArray[$nrParams - 1]);

    if ($nrChapters != $nrParams - 2) {
        echo "Wrong number of parameters!";
        exit();
    }

    $chaptersDescription = array_map(
        function ($value) {
            $array = explode(' ', $value);

            return $array;
        },
        $inputArray
    );

    foreach ($chaptersDescription as $index => $chapter) {
        if ($unreadPageIndex <= $chapter[1]) {
            $chaptersRemained = $nrChapters - $index + 1;
            echo $chaptersRemained;
            exit();
        }

        if ($index == $nrChapters){
            echo "Wrong unread page index!";
            exit();
        }
    }

<?php

    $stdin = fopen('php://stdin', 'r');
    // $stdout = fopen('php://stdout', 'w');

    // $input = $_GET['url'];
    // $inputArray = explode('/', $input);

    // $nrParams = count($inputArray);

    // $nrChapters = (int)$nrChapters;

    $input = stream_get_contents($stdin);

    $arr = preg_split("/\r\n|\n|\r/", $input);

    $nrChapters = (int)$arr[0];

    for($i = 1; $i <= $nrChapters; $i++) {
        $inputArray[] = array_map(function($val){ return (int)$val;}, explode(" ", trim($arr[$i])));
    }

    $unreadPageIndex = (int)trim($arr[count($arr) - 1]);
    // for($i = 0; $i < $nrChapters; $i++) {

    // }

    // if ($nrParams < 3) {
    //     echo "There are less parameters than expected!";
    //     exit();
    // }

    // $nrChapters = $inputArray[0];
    // $nrLinesDescribingChapters = $nrParams - 2;
    // $unreadPageIndex = $inputArray[$nrParams - 1];

    // unset($inputArray[0], $inputArray[$nrParams - 1]);

    // if ($nrChapters != $nrParams - 2) {
    //     echo "Wrong number of parameters!";
    //     exit();
    // }

    $chaptersDescription = array_map(
        function ($value) {
            $array = explode(' ', $value);

            return $array;
        },
        $inputArray
    );

    foreach ($chaptersDescription as $index => $chapter) {
        if ($unreadPageIndex <= $chapter[1]) {
            $chaptersRemained = $nrChapters - $index + 1;
            echo $chaptersRemained;
            exit();
        }

        if ($index == $nrChapters){
            echo "Wrong unread page index!";
            exit();
        }
    }

<?php

    $stdin = fopen('php://stdin', 'r');
    // $stdout = fopen('php://stdout', 'w');

    // $input = $_GET['url'];
    // $inputArray = explode('/', $input);

    // $nrParams = count($inputArray);

    // $nrChapters = (int)$nrChapters;

    $input = stream_get_contents($stdin);

    $arr = preg_split("/\r\n|\n|\r/", $input);

    $nrChapters = (int)$arr[0];

    for($i = 1; $i <= $nrChapters; $i++) {
        $inputArray[$i] = array_map(function($val){ return (int)$val;}, explode(" ", trim($arr[$i])));
    }

    $unreadPageIndex = (int)trim(end($arr));
    echo end($arr) . "\n";
    echo $unreadPageIndex . "\n";
    exit();
    // for($i = 0; $i < $nrChapters; $i++) {

    // }

    // if ($nrParams < 3) {
    //     echo "There are less parameters than expected!";
    //     exit();
    // }

    // $nrChapters = $inputArray[0];
    // $nrLinesDescribingChapters = $nrParams - 2;
    // $unreadPageIndex = $inputArray[$nrParams - 1];

    // unset($inputArray[0], $inputArray[$nrParams - 1]);

    // if ($nrChapters != $nrParams - 2) {
    //     echo "Wrong number of parameters!";
    //     exit();
    // }

    $chaptersDescription = array_map(
        function ($value) {
            $array = explode(' ', $value);

            return $array;
        },
        $inputArray
    );

    foreach ($chaptersDescription as $index => $chapter) {
        if ($unreadPageIndex <= (int)$chapter[1]) {
            $chaptersRemained = $nrChapters - $index + 1;
            echo $chaptersRemained;
            exit();
        }

        if ($index == $nrChapters){
            echo "Wrong unread page index!";
            exit();
        }
    }

<?php

    $stdin = fopen('php://stdin', 'r');
    $stdout = fopen('php://stdout', 'w');

    // $input = $_GET['url'];
    // $inputArray = explode('/', $input);

    // $nrParams = count($inputArray);

    fread($stdin, $nrChapters);
    fread($stdin, $sec);
    // $nrChapters = (int)$nrChapters;

    fwrite($stdout, "Epta : '" . $nrChapters . "' | '$sec'");
    exit();

    // for($i = 0; $i < $nrChapters; $i++) {

    // }

    // if ($nrParams < 3) {
    //     echo "There are less parameters than expected!";
    //     exit();
    // }

    // $nrChapters = $inputArray[0];
    // $nrLinesDescribingChapters = $nrParams - 2;
    // $unreadPageIndex = $inputArray[$nrParams - 1];

    // unset($inputArray[0], $inputArray[$nrParams - 1]);

    if ($nrChapters != $nrParams - 2) {
        echo "Wrong number of parameters!";
        exit();
    }

    $chaptersDescription = array_map(
        function ($value) {
            $array = explode(' ', $value);

            return $array;
        },
        $inputArray
    );

    foreach ($chaptersDescription as $index => $chapter) {
        if ($unreadPageIndex <= $chapter[1]) {
            $chaptersRemained = $nrChapters - $index + 1;
            echo $chaptersRemained;
            exit();
        }

        if ($index == $nrChapters){
            echo "Wrong unread page index!";
            exit();
        }
    }

<?php

    $stdin = fopen('php://stdin', 'r');
    // $stdout = fopen('php://stdout', 'w');

    // $input = $_GET['url'];
    // $inputArray = explode('/', $input);

    // $nrParams = count($inputArray);

    // $nrChapters = (int)$nrChapters;

    $input = stream_get_contents($stdin);

    $arr = preg_split("/\r\n|\n|\r/", $input);

    $nrChapters = (int)$arr[0];

    for($i = 1; $i <= $nrChapters; $i++) {
        $inputArray[] = array_map(function($val){ return (int)$val;}, explode(" ", trim($arr[$i])));
    }

    $unreadPageIndex = (int)trim($arr[count($arr) - 1]);
    // for($i = 0; $i < $nrChapters; $i++) {

    // }

    // if ($nrParams < 3) {
    //     echo "There are less parameters than expected!";
    //     exit();
    // }

    // $nrChapters = $inputArray[0];
    // $nrLinesDescribingChapters = $nrParams - 2;
    // $unreadPageIndex = $inputArray[$nrParams - 1];

    // unset($inputArray[0], $inputArray[$nrParams - 1]);

    if ($nrChapters != $nrParams - 2) {
        echo "Wrong number of parameters!";
        exit();
    }

    $chaptersDescription = array_map(
        function ($value) {
            $array = explode(' ', $value);

            return $array;
        },
        $inputArray
    );

    foreach ($chaptersDescription as $index => $chapter) {
        if ($unreadPageIndex <= $chapter[1]) {
            $chaptersRemained = $nrChapters - $index + 1;
            echo $chaptersRemained;
            exit();
        }

        if ($index == $nrChapters){
            echo "Wrong unread page index!";
            exit();
        }
    }

<?php

    $stdin = fopen('php://stdin', 'r');
    $stdout = fopen('php://stdout', 'w');

    // $input = $_GET['url'];
    // $inputArray = explode('/', $input);

    // $nrParams = count($inputArray);

    fread($stdin, $nrChapters);
    $nrChapters = (int)$nrChapters;

    fwrite($stdout, "Epta : '" . $nrChapters . "'");
    exit();

    // for($i = 0; $i < $nrChapters; $i++) {

    // }

    // if ($nrParams < 3) {
    //     echo "There are less parameters than expected!";
    //     exit();
    // }

    // $nrChapters = $inputArray[0];
    // $nrLinesDescribingChapters = $nrParams - 2;
    // $unreadPageIndex = $inputArray[$nrParams - 1];

    // unset($inputArray[0], $inputArray[$nrParams - 1]);

    if ($nrChapters != $nrParams - 2) {
        echo "Wrong number of parameters!";
        exit();
    }

    $chaptersDescription = array_map(
        function ($value) {
            $array = explode(' ', $value);

            return $array;
        },
        $inputArray
    );

    foreach ($chaptersDescription as $index => $chapter) {
        if ($unreadPageIndex <= $chapter[1]) {
            $chaptersRemained = $nrChapters - $index + 1;
            echo $chaptersRemained;
            exit();
        }

        if ($index == $nrChapters){
            echo "Wrong unread page index!";
            exit();
        }
    }

<?php

    $stdin = fopen('php://stdin', 'r');
    // $stdout = fopen('php://stdout', 'w');

    // $input = $_GET['url'];
    // $inputArray = explode('/', $input);

    // $nrParams = count($inputArray);

    // $nrChapters = (int)$nrChapters;

    $input = stream_get_contents($stdin);

    $arr = preg_split("/\r\n|\n|\r/", $input);

    $nrChapters = (int)$arr[0];

    for($i = 1; $i <= $nrChapters; $i++) {
        $inputArray[$i] = array_map(function($val){ return (int)$val;}, explode(" ", trim($arr[$i])));
    }

    $unreadPageIndex = (int)trim($arr[count($arr) - 2]);
    echo $arr[count($arr) - 2] . "\n";
    echo $unreadPageIndex . "\n";
    exit();
    // for($i = 0; $i < $nrChapters; $i++) {

    // }

    // if ($nrParams < 3) {
    //     echo "There are less parameters than expected!";
    //     exit();
    // }

    // $nrChapters = $inputArray[0];
    // $nrLinesDescribingChapters = $nrParams - 2;
    // $unreadPageIndex = $inputArray[$nrParams - 1];

    // unset($inputArray[0], $inputArray[$nrParams - 1]);

    // if ($nrChapters != $nrParams - 2) {
    //     echo "Wrong number of parameters!";
    //     exit();
    // }

    $chaptersDescription = array_map(
        function ($value) {
            $array = explode(' ', $value);

            return $array;
        },
        $inputArray
    );

    foreach ($chaptersDescription as $index => $chapter) {
        if ($unreadPageIndex <= (int)$chapter[1]) {
            $chaptersRemained = $nrChapters - $index + 1;
            echo $chaptersRemained;
            exit();
        }

        if ($index == $nrChapters){
            echo "Wrong unread page index!";
            exit();
        }
    }


<?php

$l = trim(fgets(STDIN));
$r = trim(fgets(STDIN));

// base case sanity check
if($r > strlen($l))
{
    echo "impossible";
    exit;
}

$cc = array();
foreach(str_split($l) as $c) {
    if (!isset($cc[$c]))
        $cc[$c] = true;
}

$rr = max(0, $r - sizeof($cc));
echo ($rr);

<?php
$p = fopen('php://stdin', 'r');
$s = trim(fgets($p));
$k = intval(fgets($p));
fclose($p);
if (strlen($s) < $k) {
    echo 'impossible', PHP_EOL; die;
}
$chars = str_split($s);
$distinctLength = count(array_unique($chars));
$missing = $k - $distinctLength;
if ($missing < 0) {
    echo 0, PHP_EOL;
} else {
    echo $missing, PHP_EOL;
}

<?php
$a = trim(fgets(STDIN));
$b = trim(fgets(STDIN));
if(strlen($a) < $b)
{
     print "impossible";
}
else
{
     $c = array_unique(str_split($a));
     sort($c);
     if(count($c) >= $b)
     {
          print "0";
     }
     else
     {
          print $b - count($c);
     }
}
?>

<?php
$a = trim(fgets(STDIN));
$b = trim(fgets(STDIN));
if(strlen($a) < $b)
{
     print "impossible";
}
else
{
     $c = array_unique(str_split($a));
     sort($c);
     $d = $b - count($c);
     print $d;
}
?>

<?php

$r = trim(fgets(STDIN));
$l = explode("", trim(fgets(STDIN)));

// base case sanity check
if($r > $l)
{
    echo "impossible";
    exit;
}

$cc = array();
foreach($l as $c) {
    if (!isset($cc[$c]))
        $cc[$c] = true;
}

echo ($r - sizeof($cc));

<?php

$l = trim(fgets(STDIN));
$r = trim(fgets(STDIN));

// base case sanity check
if($r > strlen($l))
{
    echo "impossible";
    exit;
}

$cc = array();
foreach(str_split($l) as $c) {
    if (!isset($cc[$c]))
        $cc[$c] = true;
}

echo ($r - sizeof($cc));


<?php
$mod = 1000000007;
$intMaxValue = 2147483646; //2147483647

$loop = true;
$t = $loop ? IO::getInt() : 1;
while($t--) {
    solve();
}

function solve()
{
    $n = IO::getInt();
    $s = IO::getInt();
    $ans = $n;
    for($i=1; $i<$n; $i++) {
         if($s[$i] !=  $s[$i-1]) {
               $ans += $i;
         }
    }

     IO::pr($ans);
}

class IO {
    public static function getInt()
    {
        return trim(fgets(STDIN));
    }

    public static function getArray()
    {
        return explode(' ', trim(fgets(STDIN)));
    }
    public static function pr($s)
    {
        echo $s, PHP_EOL;
    }
    public static function prArray($s)
    {
        echo implode( ' ', $s), PHP_EOL;
    }
    public static function getMinValue($x, $y) {
        return $x > $y ? $y : $x;
    }
    public static function getMaxValue($x, $y) {
        return $x > $y ? $x : $y;
    }
}

<?php
$mod = 1000000007;
$intMaxValue = 2147483646; //2147483647

$loop = true;
$t = $loop ? IO::getInt() : 1;
while($t--) {
    solve();
}

function solve()
{
    $n = IO::getInt();
    $s = IO::getInt();
    $ans = 0;
    $t0 = 0;
    $t1 = 0;
    for($i=0; $i<$n; $i++) {
         if($s[$i] == '0') {
              $t0++;
         } else {
             $t1++;
         }
    }
     $max = IO::getMaxValue($t0, $t1);
     $min = $n - $max;
     $ans = $n;
     if($min > 0) {
         $ans += pow($min, $max);

     }
     IO::pr($ans);
}

class IO {
    public static function getInt()
    {
        return trim(fgets(STDIN));
    }

    public static function getArray()
    {
        return explode(' ', trim(fgets(STDIN)));
    }
    public static function pr($s)
    {
        echo $s, PHP_EOL;
    }
    public static function prArray($s)
    {
        echo implode( ' ', $s), PHP_EOL;
    }
    public static function getMinValue($x, $y) {
        return $x > $y ? $y : $x;
    }
    public static function getMaxValue($x, $y) {
        return $x > $y ? $x : $y;
    }
}

<?php
$mod = 1000000007;
$intMaxValue = 2147483646; //2147483647

$loop = true;
$t = $loop ? IO::getInt() : 1;
while($t--) {
    solve();
}

function solve()
{
    $n = IO::getInt();
    $s = IO::getInt();
    $ans = $n;
    while($n > 1) {
        $sN = '';
        $tt = $n;
         for($i=0; $i<$tt-1; $i++) {
              if($s[$i] == '0' && $s[$i+1] == '1') {
                    $sN .= '1';
                    $n--;
                    $i++;
              } elseif($s[$i] == '1' && $s[$i+1] == '0') {
                  $sN .= '0';
                  $n--;
                    $i++;
              } else {
                 $sN .= $s[$i];
              }
         }
         if($tt == $n) {
              break;
         } else {
              $ans += $tt - $n == 1 ? 1 : ($tt - $n) + 1 ;
              $s = $sN;
         }
    }

     IO::pr($ans);
}

class IO {
    public static function getInt()
    {
        return trim(fgets(STDIN));
    }

    public static function getArray()
    {
        return explode(' ', trim(fgets(STDIN)));
    }
    public static function pr($s)
    {
        echo $s, PHP_EOL;
    }
    public static function prArray($s)
    {
        echo implode( ' ', $s), PHP_EOL;
    }
    public static function getMinValue($x, $y) {
        return $x > $y ? $y : $x;
    }
    public static function getMaxValue($x, $y) {
        return $x > $y ? $x : $y;
    }
}


<?php

$handle = fopen("php://stdin", "r");

$n = fgets($handle);

$list = array_map('intval', explode(' ', trim(fgets($handle))));

sort($list);

$value = 0;
for($i = 0; $i < $n - 1; $i++)
{
	if($list[$i] + 1 != $list[$i + 1])
	{
		$value+=($list[$i + 1] - $list[$i] - 1);
	}
}

echo $value;

<?php
$a = trim(fgets(STDIN));
$b = explode(" ", trim(fgets(STDIN)));
$c = min($b);
$d = max($b);
$e = $d - $c + 1 - $a;
print $e;
?>

<?php
fscanf(STDIN, "%d", $N);
$a = explode(" ", trim(fgets(STDIN)));

$num = max($a) - min($a) + 1;

echo $num - $N;

<?php
$a = trim(fgets(STDIN));
$b = explode(" ", trim(fgets(STDIN)));
$c = min($b);
$d = max($b);
$e = range($c, $d - $c + $c);
$f = array_diff($e, $b);
print count($f);
?>

<?php

$handle = fopen("php://stdin", "r");

$n = fgets($handle);

$list = array_map('intval', explode(' ', trim(fgets($handle))));

sort($list);

$value = 0;
for($i = 0; $i < $n - 1; $i++)
{
	if($list[$i] + 1 != $list[$i + 1])
	{
		$value++;
	}
}

echo $value;


<?

error_reporting(false);
//error_reporting(E_ALL);

$handle = fopen('php://stdin', 'r');
//$handle = fopen('in.txt', 'r');

$str = trim(fgets($handle));

//set_time_limit(3);

$c = 0;
$hh = 0;
$mm = 0;

for($i=0; $i<strlen($str); $i++) {

    if (h($str, $i)) {
        $hh++;
    }

    if (m($str, $i)) {
        $mm++;
        $c += $hh;
    }
}

function h($str, $ind){
    $t = "heavy";
    for($i=0; $i<5; $i++) {

        if($t[$i] != $str[$i + $ind]) return false;
    }
    return true;
}

function m($str, $ind){
    $t = "metal";
    for($i=$ind; $i<$ind+5; $i++) if($t[$i-$ind]!=$str[$i]) return false;
    return true;
}

echo $c;

?>

<?php

function FindSubString($string){

    $heavy_positions = FindPosition($string, "heavy");
    $metal_positions = FindPosition($string, "metal");
    $substring       = 0;
    $j               = 0;
    $metal_length    = count($metal_positions);
    //print_r($heavy_positions);echo "\n";
    //print_r($metal_positions);
    for($i=0;$i<count($heavy_positions);$i++){
        if($metal_length>0){
            while ($metal_length>$j && $heavy_positions[$i]>$metal_positions[$j]){
                $j++;
            }
            if($metal_length>$j){
                if($heavy_positions[$i]<$metal_positions[$j]){
                    $substring += $metal_length-$j;
                }
            }
        }
    }
    return $substring;
}

function FindPosition($string,$needle){
    $lastPos = 0;
    $positions = array();

    while (($lastPos = strpos($string, $needle, $lastPos))!== false) {
        $positions[] = $lastPos;
        $lastPos = $lastPos + strlen($needle);
    }
    return $positions;
}

$string      = trim(fgets(STDIN));
echo FindSubString($string);


<?php
class IO {
    public static function arr($sDelimeter = ' ') { return explode($sDelimeter, trim(fgets(STDIN))); }
    public static function str() { return trim(fgets(STDIN)); }
    public static function yes() { echo 'YES' . PHP_EOL; }
    public static function no() { echo 'NO' . PHP_EOL; }
    public static function line($sLine) { echo $sLine . PHP_EOL; }
    public static function lcm($x, $y) {
        $p = $x;
        $q = $y;
        while ($x != $y)
        {
            if ($x > $y)
                $x = $x - $y;
            else
                $y = $y - $x;
        }
        return ($p*$q)/$x;
    }
    public static function gcd($a, $b) {
        return ($a % $b) ? self::gcd($b,$a % $b) : $b;
    }
}

//$iQueryCount = 1;
$iQueryCount = IO::str();

while($iQueryCount > 0) {
    $iQueryCount--;
    solve();
}
function solve() {
    $n = IO::str();
    $l = strlen($n);
    $last = 1;
    $res = 0;
    for ($i = 1; $i < 10; $i++) {
        $r = '';
        for ($j = 0; $j < $l; $j++) {
            $r .= $i;
            if ((int)$r <= $n) {
                $res++;
                $last = (int)$r + 1;
            }
        }
    }

    IO::line($res);
}

?>

<?php
$fileName = 'php://stdin';
$file = fopen($fileName, "r");

$t = trim(fgets($file));

for ($i = 0; $i < $t; $i++) {
  $n = trim(fgets($file));

  if ($n < 10) { echo $n.PHP_EOL; }
  else {
    if ($n == 10) { echo '9'.PHP_EOL; }
    else {
      $len = strlen($n);
      if ($len >= 2) { $ans = 9 * ($len - 1); }

      $s = (string) $n;
      $f = $s[0];
      $m = '';
      for ($j = 0; $j < $len; $j++) { $m .= $f; }

      if ($m > $n) { $ans += $f - 1; }
      else { $ans += $f; }

      echo $ans.PHP_EOL;
    }
  }
}

?>

<?php
class IO {
    public static function arr($sDelimeter = ' ') { return explode($sDelimeter, trim(fgets(STDIN))); }
    public static function str() { return trim(fgets(STDIN)); }
    public static function yes() { echo 'YES' . PHP_EOL; }
    public static function no() { echo 'NO' . PHP_EOL; }
    public static function line($sLine) { echo $sLine . PHP_EOL; }
    public static function lcm($x, $y) {
        $p = $x;
        $q = $y;
        while ($x != $y)
        {
            if ($x > $y)
                $x = $x - $y;
            else
                $y = $y - $x;
        }
        return ($p*$q)/$x;
    }
    public static function gcd($a, $b) {
        return ($a % $b) ? self::gcd($b,$a % $b) : $b;
    }

    public static function res($res) {
        foreach ($res as $r) {
            echo $r . "\n";
        }
    }

    public static function dd($val){
        echo $val; exit;
    }
}

$nums = array(
    2 => 9,
    3 => 18,
    4 => 27,
    5 => 36,
    6 => 45,
    7 => 54,
    8 => 63,
    9 => 72,
    10 => 81,
    11 => 90,
);

$t = IO::str();

function makeDel($q)
{
    $s = '';
    while($q--) {
        $s .= '1';
    }
    return $s;
}
while($t--){
    $n = IO::str();

    if ($n < 10) {
        $res[] = $n;
        continue;
    }

    $s = $nums[strlen($n)];
    $del = makeDel(strlen($n));

    while($n >= $del) {
        $s++;
        $n = $n - $del;
    }

    $res[] = $s;
}

IO::res($res);

<?php
$fileName = 'php://stdin';
$file = fopen($fileName, "r");

$t = trim(fgets($file));

for ($i = 0; $i < $t; $i++) {
  $n = trim(fgets($file));

  if ($n < 10) { echo $n.PHP_EOL; }
  else {
    if ($n == 10) { echo '9'.PHP_EOL; }
    else {
      $len = strlen($n);
      if ($len >= 2) { $ans = 9 * ($len - 1); }

      $s = (string) $n;
      $f = $s[0];
      $m = '';
      for ($j = 0; $j < $len; $j++) { $m .= $f; }

      if ($m > $v[$i]) { $ans += $f - 1; }
      else { $ans += $f; }
      echo $ans.PHP_EOL;
    }
  }
}

?>

<?php
$fileName = 'php://stdin';
$file = fopen($fileName, "r");

$t = trim(fgets($file));

for ($i = 0; $i < $t; $i++) {
  $n = trim(fgets($file));

  if ($n < 10) { echo $n.PHP_EOL; }
  else {
    if ($n == 10) { echo '9'.PHP_EOL; }
    else {
      $len = strlen($n);
      if ($len > 2) { $ans = 9 * ($len - 1); }

      $s = (string) $n;
      $f = $s[0];
      $m = '';
      for ($j = 0; $j < $len; $j++) { $m .= $f; }

      if ($m > $v[$i]) { $ans += $f - 1; }
      else { $ans += $f; }
      echo $ans.PHP_EOL;
    }
  }
}

?>

<?php
$fileName = 'php://stdin';
$file = fopen($fileName, "r");

$t = trim(fgets($file));

for ($i = 0; $i < $t; $i++) {
  $n = trim(fgets($file));

  if ($n < 10) { echo $n.PHP_EOL; }
  else {
    $ans = 9;
    $len = strlen($n);
    if ($len > 2) { $ans += 9 * ($len - 2); }

    $s = (string) $n;
    $f = $s[0];
    $m = '';
    for ($j = 0; $j < $len; $j++) { $m .= $f; }

    if ($m > $v[$i]) { $ans += $f - 1; }
    else { $ans += $f; }
    echo $ans.PHP_EOL;
  }
}

?>

<?php
class IO {
    public static function arr($sDelimeter = ' ') { return explode($sDelimeter, trim(fgets(STDIN))); }
    public static function str() { return trim(fgets(STDIN)); }
    public static function yes() { echo 'YES' . PHP_EOL; }
    public static function no() { echo 'NO' . PHP_EOL; }
    public static function line($sLine) { echo $sLine . PHP_EOL; }
    public static function lcm($x, $y) {
        $p = $x;
        $q = $y;
        while ($x != $y)
        {
            if ($x > $y)
                $x = $x - $y;
            else
                $y = $y - $x;
        }
        return ($p*$q)/$x;
    }
    public static function gcd($a, $b) {
        return ($a % $b) ? self::gcd($b,$a % $b) : $b;
    }

    public static function res($res) {
        foreach ($res as $r) {
            echo $r . "\n";
        }
    }

    public static function dd($val){
        echo $val; exit;
    }
}

$nums = array(
    2 => 9,
    3 => 18,
    4 => 27,
    5 => 36,
    6 => 45,
    7 => 54,
    8 => 63,
    9 => 72,
    10 => 81,
    11 => 90,
);

$t = IO::str();

function makeDel($q)
{
    $s = '';
    while($q--) {
        $s .= '1';
    }
    return $s;
}
while($t--){
    $n = IO::str();

    if ($n < 10) {
        $res[] = $n;
        continue;
    }

    $s = $nums[strlen($n)];
    $del = makeDel(strlen($n));

    while($n > $del) {
        $s++;
        $n = $n - $del;
    }

    $res[] = $s;
}

IO::res($res);


<?php

$line = array_map('intval',explode(' ', trim(fgets(STDIN))));
$n = $line[0];
$k = $line[1];

for ($i = 0; $i < $n; $i++) {
	for ($j = 0; $j < $n; $j++) {
		if ($i == $j) {
			echo $k." ";
		}
		else {
			echo "0 ";
		}
	}
	echo "\n";
}


<?php
define('LOCAL_ENV', false);
if (LOCAL_ENV) {
    error_reporting(E_ALL & !E_NOTICE);
    $test = <<<INPUT
5 1 4
12 6 11 9 1
INPUT;
    $stdin = fopen('php://temp/in', 'rw');
    fwrite($stdin, $test);
    rewind($stdin);
} else {
    error_reporting(0);
    $stdin = STDIN;
}
define('MY_STDIN', $stdin);

list($n,$a,$b) = explode(' ', trim(fgets(MY_STDIN)));
$ww = explode(' ', trim(fgets(MY_STDIN)));
$res = array_fill(0, $n, 0);
for ($i = 0; $i < $n; $i++) {
    $wa = bcmul($ww[$i], $a);
    $x = bcdiv($wa, $b, 0);
    $xb = bcmul($x, $b);
    $r = bcsub($wa, $xb);
    $ws = bcdiv($r, $a, 0);
    $res[$i] = $ws;
}

echo join(' ', $res);

<?PHP

$fileIN = fopen("php://stdin", "r");
$fileOUT = fopen("php://stdout", "w");

$line = explode(" ", trim(fgets($fileIN)));

$n = $line[0];
$a = $line[1];
$b = $line[2];

$line = explode(" ", trim(fgets($fileIN)));

for ($i = 0; $i < $n; ++$i) {
    fprintf($fileOUT, (int) (fmod($line[$i] * $a, $b) / $a) . " ");
}

fclose($fileIN);
fclose($fileOUT);

?>

<?php
define('LOCAL_ENV', FALSE);
if (LOCAL_ENV) {
    error_reporting(E_ALL & !E_NOTICE);
    $test = <<<INPUT
1 1 1
1
INPUT;
    $stdin = fopen('php://temp/in', 'rw');
    fwrite($stdin, $test);
    rewind($stdin);
} else {
    error_reporting(0);
    $stdin = STDIN;
}
define('MY_STDIN', $stdin);

list($n,$a,$b) = explode(' ', trim(fgets(MY_STDIN)));
$x = explode(' ', trim(fgets(MY_STDIN)));
$res = array_fill(0, $n, 0);
for ($i = 0; $i < $n; $i++) {
    $aa = bcmod(bcmul($a, $x[$i]), $b);
    $res[$i] = $aa;
}

echo join(' ', $res);

<?php
define('LOCAL_ENV', false);
if (LOCAL_ENV) {
    error_reporting(E_ALL & !E_NOTICE);
    $test = <<<INPUT
3 1 2
1 2 3
INPUT;
    $stdin = fopen('php://temp/in', 'rw');
    fwrite($stdin, $test);
    rewind($stdin);
} else {
    error_reporting(0);
    $stdin = STDIN;
}
define('MY_STDIN', $stdin);

list($n,$a,$b) = explode(' ', trim(fgets(MY_STDIN)));
$x = explode(' ', trim(fgets(MY_STDIN)));
$res = array_fill(0, $n, 0);
for ($i = 0; $i < $n; $i++) {
    $aa = bcmod($x[$i], $b);
    $res[$i] = $aa;
}

echo join(' ', $res);

<?PHP

$fileIN = fopen("php://stdin", "r");
$fileOUT = fopen("php://stdout", "w");

$line = explode(" ", trim(fgets($fileIN)));

$n = $line[0];
$a = $line[1];
$b = $line[2];

$line = explode(" ", trim(fgets($fileIN)));

for ($i = 0; $i < $n; ++$i) {
    fprintf($fileOUT, ((int) ((int) $line[$i] * (int) $a) % (int) $b / (int) $a) . " ");
}

fclose($fileIN);
fclose($fileOUT);

?>

<?PHP

$fileIN = fopen("php://stdin", "r");
$fileOUT = fopen("php://stdout", "w");

$line = explode(" ", trim(fgets($fileIN)));

$n = $line[0];
$a = $line[1];
$b = $line[2];

$line = explode(" ", trim(fgets($fileIN)));

for ($i = 0; $i < $n; ++$i) {
    fprintf($fileOUT, floor((float) (($line[$i] * $a) % $b) / (int) $a) . " ");
}

fclose($fileIN);
fclose($fileOUT);

?>

<?PHP

$fileIN = fopen("php://stdin", "r");
$fileOUT = fopen("php://stdout", "w");

$line = explode(" ", trim(fgets($fileIN)));

$n = $line[0];
$a = $line[1];
$b = $line[2];

$line = explode(" ", trim(fgets($fileIN)));

for ($i = 0; $i < $n; ++$i) {
    fprintf($fileOUT, (int) ((int) ($line[$i] * $a) % (int) $b / (int) $a) . " ");
}

fclose($fileIN);
fclose($fileOUT);

?>

<?PHP

$fileIN = fopen("php://stdin", "r");
$fileOUT = fopen("php://stdout", "w");

$line = explode(" ", trim(fgets($fileIN)));

$n = $line[0];
$a = $line[1];
$b = $line[2];

$line = explode(" ", trim(fgets($fileIN)));

for ($i = 0; $i < $n; ++$i) {
    fprintf($fileOUT, (($line[$i] * $a) % $b / $a) . " ");
}

fclose($fileIN);
fclose($fileOUT);

?>


<?php
class Token {
	private $token;
	private $tok;

	public function __construct($str_line, $tok) {
		$this->tok = $tok;
		$this->token = strtok($str_line, $this->tok);
	}

	public function nextToken() {
		$thisToken = $this->token;
		$this->token = strtok($this->tok);
		return $thisToken;
	}

	public function nextFloat() {
		return (float)$this->nextToken();
	}

	public function nextInt() {
		return (int)$this->nextToken();
	}
}

function array_printf(array $arr) {
	$message = "";
	foreach ($arr as $value) {
		$message .= "$value" . " ";
	}
	$message = rtrim($message);
	printf('%s', $message);
}

function solve(){

/* basic coding (this code is not best, because changing token and float is not good)
	$vp = (float)strtok(rtrim(fgets(STDIN, 10), "\n"), " ");
	$vd = (float)strtok(" ");
	$t = (float)strtok(" ");
	$f = (float)strtok(" ");
	$c = (float)strtok(" ");
*/
	//use Token class(advatage of using this class is changing token and float is more easy)
	//$Token = new Token(rtrim(fgets(STDIN, 5), "\n"), " ");
	$Token = new Token(rtrim(fgets(STDIN), "\n"), " ");
	$n = $Token->nextInt();
	$a = $Token->nextInt();
	$b = $Token->nextInt();

	if ($a === $n - 1 && $n != 1) {
		printf("%d",-1);
		return;
	} elseif ($b === 0 && $a !== 0) {
		$array_a = array(1, 1,);
		for ($i = 2; $i < $a + 2; $i++) {
			$array_a[] = $i;
		}

		$num = $n - count($array_a);
		//$array_a = array_fill(count($array_a) - 1, $n - $a - 2, (int)1);
		//for ($i = 0; $i < $n - count($array_a); $i++) {
		for ($i = 0; $i < $num; $i++) {
			$array_a[] = 1;
		}
		array_printf($array_a);
		return;
	}
	//this is for more reading.really array() is not useful.
	$arr = array();
	$arr[] = 1;
	for ($i = 0; $i < $b; $i++) {
		$arr[] = array_sum($arr) + 1;
	}
	//for ($i = 1; $i <= $a; $i++) {
	//array_pop not get, pop.so number - 1.
	//$begin = array_pop(&$arr);

//test coding
//printf("%d\n",(int)$arr[count($arr)]);
//printf("%d\n",(int)null);

	$begin = $arr[count($arr) - 1];
	for ($i = $begin + 1; $i < $a + $begin + 1; $i++) {
		//$arr[] = $i + 1;
		$arr[] = $i;
	}
	//for ($i = 0; $i < $b - 1; $i++) {
		//$arr[] = array_sum($arr) + 1;
	//}
	for ($i = 0; $i < $n - ($a + $b + 1); $i++) {
		$arr[] = 1;
	}
	array_printf($arr);
}

function run(){
	solve();
}

ob_end_clean();
run();
?>

<?php
class Token {
	private $token;
	private $tok;

	public function __construct($str_line, $tok) {
		$this->tok = $tok;
		$this->token = strtok($str_line, $this->tok);
	}

	public function nextToken() {
		$thisToken = $this->token;
		$this->token = strtok($this->tok);
		return $thisToken;
	}

	public function nextFloat() {
		return (float)$this->nextToken();
	}

	public function nextInt() {
		return (int)$this->nextToken();
	}
}

function array_printf(array $arr) {
	$message = "";
	foreach ($arr as $value) {
		$message .= "$value" . " ";
	}
	$message = rtrim($message);
	printf('%s', $message);
}

function solve(){

/* basic coding (this code is not best, because changing token and float is not good)
	$vp = (float)strtok(rtrim(fgets(STDIN, 10), "\n"), " ");
	$vd = (float)strtok(" ");
	$t = (float)strtok(" ");
	$f = (float)strtok(" ");
	$c = (float)strtok(" ");
*/
	//use Token class(advatage of using this class is changing token and float is more easy)
	//$Token = new Token(rtrim(fgets(STDIN, 5), "\n"), " ");
	$Token = new Token(rtrim(fgets(STDIN), "\n"), " ");
	$n = $Token->nextInt();
	$a = $Token->nextInt();
	$b = $Token->nextInt();

	if ($a === $n - 1) {
		printf("%d",-1);
		return;
	} elseif ($b === 0 && $a !== 0) {
		$array_a = array(1, 1,);
		for ($i = 2; $i < $a + 2; $i++) {
			$array_a[] = $i;
		}

		$num = $n - count($array_a);
		//$array_a = array_fill(count($array_a) - 1, $n - $a - 2, (int)1);
		//for ($i = 0; $i < $n - count($array_a); $i++) {
		for ($i = 0; $i < $num; $i++) {
			$array_a[] = 1;
		}
		array_printf($array_a);
		return;
	}
	//this is for more reading.really array() is not useful.
	$arr = array();
	$arr[] = 1;
	for ($i = 0; $i < $b; $i++) {
		$arr[] = array_sum($arr) + 1;
	}
	//for ($i = 1; $i <= $a; $i++) {
	//array_pop not get, pop.so number - 1.
	//$begin = array_pop(&$arr);

//test coding
//printf("%d\n",(int)$arr[count($arr)]);
//printf("%d\n",(int)null);

	$begin = $arr[count($arr) - 1];
	for ($i = $begin + 1; $i < $a + $begin + 1; $i++) {
		//$arr[] = $i + 1;
		$arr[] = $i;
	}
	//for ($i = 0; $i < $b - 1; $i++) {
		//$arr[] = array_sum($arr) + 1;
	//}
	for ($i = 0; $i < $n - ($a + $b + 1); $i++) {
		$arr[] = 1;
	}
	array_printf($arr);
}

function run(){
	solve();
}

ob_end_clean();
run();
?>

<?php
class Token {
	private $token;
	private $tok;

	public function __construct($str_line, $tok) {
		$this->tok = $tok;
		$this->token = strtok($str_line, $this->tok);
	}

	public function nextToken() {
		$thisToken = $this->token;
		$this->token = strtok($this->tok);
		return $thisToken;
	}

	public function nextFloat() {
		return (float)$this->nextToken();
	}

	public function nextInt() {
		return (int)$this->nextToken();
	}
}

function solve(){

/* basic coding (this code is not best, because changing token and float is not good)
	$vp = (float)strtok(rtrim(fgets(STDIN, 10), "\n"), " ");
	$vd = (float)strtok(" ");
	$t = (float)strtok(" ");
	$f = (float)strtok(" ");
	$c = (float)strtok(" ");
*/
	//use Token class(advatage of using this class is changing token and float is more easy)
	//$Token = new Token(rtrim(fgets(STDIN, 5), "\n"), " ");
	$Token = new Token(rtrim(fgets(STDIN), "\n"), " ");
	$n = $Token->nextInt();
	$a = $Token->nextInt();
	$b = $Token->nextInt();

	//this is for more reading.really array() is not useful.
	$arr = array();
	$arr[] = 1;
	//for ($i = 1; $i <= $a; $i++) {
	for ($i = 1; $i < $a + 2; $i++) {
		$arr[] = $i + 1;
	}
	for ($i = 0; $i < $b - 1; $i++) {
		$arr[] = array_sum($arr) + 1;
	}
	for ($i = 0; $i < $n - ($a + $b + 1); $i++) {
		$arr[] = 1;
	}
	$message = "";
	foreach ($arr as $value) {
		$message .= "$value" . " ";
	}
	$message = rtrim($message);
	printf('%s', $message);
}

function run(){
	solve();
}

ob_end_clean();
run();
?>

<?php
class Token {
	private $token;
	private $tok;

	public function __construct($str_line, $tok) {
		$this->tok = $tok;
		$this->token = strtok($str_line, $this->tok);
	}

	public function nextToken() {
		$thisToken = $this->token;
		$this->token = strtok($this->tok);
		return $thisToken;
	}

	public function nextFloat() {
		return (float)$this->nextToken();
	}

	public function nextInt() {
		return (int)$this->nextToken();
	}
}

function solve(){

/* basic coding (this code is not best, because changing token and float is not good)
	$vp = (float)strtok(rtrim(fgets(STDIN, 10), "\n"), " ");
	$vd = (float)strtok(" ");
	$t = (float)strtok(" ");
	$f = (float)strtok(" ");
	$c = (float)strtok(" ");
*/
	//use Token class(advatage of using this class is changing token and float is more easy)
	//$Token = new Token(rtrim(fgets(STDIN, 5), "\n"), " ");
	$Token = new Token(rtrim(fgets(STDIN), "\n"), " ");
	$n = $Token->nextInt();
	$a = $Token->nextInt();
	$b = $Token->nextInt();

	//this is for more reading.really array() is not useful.
	$arr = array();
	$arr[] = 1;
	//for ($i = 1; $i <= $a; $i++) {
	for ($i = 2; $i <= ($a + 1); $i++) {
		$arr[] = $i + 1;
	}
	for ($i = 0; $i < $b; $i++) {
		$arr[] = array_sum($arr) + 1;
	}
	for ($i = 0; $i < $n - ($a + $b); $i++) {
		$arr[] = 1;
	}
	$message = "";
	foreach ($arr as $value) {
		$message .= "$value" . " ";
	}
	$message = rtrim($message);
	printf('%s', $message);
}

function run(){
	solve();
}

ob_end_clean();
run();
?>

<?php
class Token {
	private $token;
	private $tok;

	public function __construct($str_line, $tok) {
		$this->tok = $tok;
		$this->token = strtok($str_line, $this->tok);
	}

	public function nextToken() {
		$thisToken = $this->token;
		$this->token = strtok($this->tok);
		return $thisToken;
	}

	public function nextFloat() {
		return (float)$this->nextToken();
	}

	public function nextInt() {
		return (int)$this->nextToken();
	}
}

function solve(){

/* basic coding (this code is not best, because changing token and float is not good)
	$vp = (float)strtok(rtrim(fgets(STDIN, 10), "\n"), " ");
	$vd = (float)strtok(" ");
	$t = (float)strtok(" ");
	$f = (float)strtok(" ");
	$c = (float)strtok(" ");
*/
	//use Token class(advatage of using this class is changing token and float is more easy)
	//$Token = new Token(rtrim(fgets(STDIN, 5), "\n"), " ");
	$Token = new Token(rtrim(fgets(STDIN), "\n"), " ");
	$n = $Token->nextInt();
	$a = $Token->nextInt();
	$b = $Token->nextInt();

	//this is for more reading.really array() is not useful.
	$arr = array();
	$arr[] = 1;
	for ($i = 1; $i <= $a; $i++) {
		$arr[] = $i + 1;
	}
	for ($i = 0; $i < $b; $i++) {
		$arr[] = array_sum($arr) + 1;
	}
	for ($i = 0; $i < $n - ($a + $b); $i++) {
		$arr[] = 1;
	}
	$message = "";
	foreach ($arr as $value) {
		$message .= "$value" . " ";
	}
	$message = rtrim($message);
	printf('%s', $message);
}

function run(){
	solve();
}

ob_end_clean();
run();
?>

<?php
class Token {
	private $token;
	private $tok;

	public function __construct($str_line, $tok) {
		$this->tok = $tok;
		$this->token = strtok($str_line, $this->tok);
	}

	public function nextToken() {
		$thisToken = $this->token;
		$this->token = strtok($this->tok);
		return $thisToken;
	}

	public function nextFloat() {
		return (float)$this->nextToken();
	}

	public function nextInt() {
		return (int)$this->nextToken();
	}
}

function solve(){

/* basic coding (this code is not best, because changing token and float is not good)
	$vp = (float)strtok(rtrim(fgets(STDIN, 10), "\n"), " ");
	$vd = (float)strtok(" ");
	$t = (float)strtok(" ");
	$f = (float)strtok(" ");
	$c = (float)strtok(" ");
*/
	//use Token class(advatage of using this class is changing token and float is more easy)
	//$Token = new Token(rtrim(fgets(STDIN, 5), "\n"), " ");
	$Token = new Token(rtrim(fgets(STDIN), "\n"), " ");
	$n = $Token->nextInt();
	$a = $Token->nextInt();
	$b = $Token->nextInt();

	//this is for more reading.really array() is not useful.
	$arr = array();
	$arr[] = 1;
	//for ($i = 1; $i <= $a; $i++) {
	for ($i = 2; $i <= ($a + 2); $i++) {
		$arr[] = $i + 1;
	}
	for ($i = 0; $i < $b - 1; $i++) {
		$arr[] = array_sum($arr) + 1;
	}
	for ($i = 0; $i < $n - ($a + $b); $i++) {
		$arr[] = 1;
	}
	$message = "";
	foreach ($arr as $value) {
		$message .= "$value" . " ";
	}
	$message = rtrim($message);
	printf('%s', $message);
}

function run(){
	solve();
}

ob_end_clean();
run();
?>

<?php
class Token {
	private $token;
	private $tok;

	public function __construct($str_line, $tok) {
		$this->tok = $tok;
		$this->token = strtok($str_line, $this->tok);
	}

	public function nextToken() {
		$thisToken = $this->token;
		$this->token = strtok($this->tok);
		return $thisToken;
	}

	public function nextFloat() {
		return (float)$this->nextToken();
	}

	public function nextInt() {
		return (int)$this->nextToken();
	}
}

function solve(){

/* basic coding (this code is not best, because changing token and float is not good)
	$vp = (float)strtok(rtrim(fgets(STDIN, 10), "\n"), " ");
	$vd = (float)strtok(" ");
	$t = (float)strtok(" ");
	$f = (float)strtok(" ");
	$c = (float)strtok(" ");
*/
	//use Token class(advatage of using this class is changing token and float is more easy)
	//$Token = new Token(rtrim(fgets(STDIN, 5), "\n"), " ");
	$Token = new Token(rtrim(fgets(STDIN), "\n"), " ");
	$n = $Token->nextInt();
	$a = $Token->nextInt();
	$b = $Token->nextInt();

	//this is for more reading.really array() is not useful.
	$arr = array();
	$arr[] = 1;
	for ($i = 0; $i < $b; $i++) {
		$arr[] = array_sum($arr) + 1;
	}
	//for ($i = 1; $i <= $a; $i++) {
	$begin = array_sum($arr);
	for ($i = $begin; $i < $a + $begin; $i++) {
		$arr[] = $i + 1;
	}
	//for ($i = 0; $i < $b - 1; $i++) {
		//$arr[] = array_sum($arr) + 1;
	//}
	for ($i = 0; $i < $n - ($a + $b + 1); $i++) {
		$arr[] = 1;
	}
	$message = "";
	foreach ($arr as $value) {
		$message .= "$value" . " ";
	}
	$message = rtrim($message);
	printf('%s', $message);
}

function run(){
	solve();
}

ob_end_clean();
run();
?>

<?php
class Token {
	private $token;
	private $tok;

	public function __construct($str_line, $tok) {
		$this->tok = $tok;
		$this->token = strtok($str_line, $this->tok);
	}

	public function nextToken() {
		$thisToken = $this->token;
		$this->token = strtok($this->tok);
		return $thisToken;
	}

	public function nextFloat() {
		return (float)$this->nextToken();
	}

	public function nextInt() {
		return (int)$this->nextToken();
	}
}

function solve(){

/* basic coding (this code is not best, because changing token and float is not good)
	$vp = (float)strtok(rtrim(fgets(STDIN, 10), "\n"), " ");
	$vd = (float)strtok(" ");
	$t = (float)strtok(" ");
	$f = (float)strtok(" ");
	$c = (float)strtok(" ");
*/
	//use Token class(advatage of using this class is changing token and float is more easy)
	//$Token = new Token(rtrim(fgets(STDIN, 5), "\n"), " ");
	$Token = new Token(rtrim(fgets(STDIN), "\n"), " ");
	$n = $Token->nextInt();
	$a = $Token->nextInt();
	$b = $Token->nextInt();

	//this is for more reading.really array() is not useful.
	$arr = array();
	//$arr[] = 1;
	$arr[] = 2;
	//for ($i = 1; $i <= $a; $i++) {
	for ($i = 2; $i <= ($a + 1); $i++) {
		$arr[] = $i + 1;
	}
	for ($i = 0; $i < $b; $i++) {
		$arr[] = array_sum($arr) + 1;
	}
	for ($i = 0; $i < $n - ($a + $b); $i++) {
		$arr[] = 1;
	}
	$message = "";
	foreach ($arr as $value) {
		$message .= "$value" . " ";
	}
	$message = rtrim($message);
	printf('%s', $message);
}

function run(){
	solve();
}

ob_end_clean();
run();
?>

<?php
class Token {
	private $token;
	private $tok;

	public function __construct($str_line, $tok) {
		$this->tok = $tok;
		$this->token = strtok($str_line, $this->tok);
	}

	public function nextToken() {
		$thisToken = $this->token;
		$this->token = strtok($this->tok);
		return $thisToken;
	}

	public function nextFloat() {
		return (float)$this->nextToken();
	}

	public function nextInt() {
		return (int)$this->nextToken();
	}
}

function solve(){

/* basic coding (this code is not best, because changing token and float is not good)
	$vp = (float)strtok(rtrim(fgets(STDIN, 10), "\n"), " ");
	$vd = (float)strtok(" ");
	$t = (float)strtok(" ");
	$f = (float)strtok(" ");
	$c = (float)strtok(" ");
*/
	//use Token class(advatage of using this class is changing token and float is more easy)
	//$Token = new Token(rtrim(fgets(STDIN, 5), "\n"), " ");
	$Token = new Token(rtrim(fgets(STDIN), "\n"), " ");
	$n = $Token->nextInt();
	$a = $Token->nextInt();
	$b = $Token->nextInt();

	//this is for more reading.really array() is not useful.
	$arr = array();
	$arr[] = 1;
	for ($i = 0; $i < $b; $i++) {
		$arr[] = array_sum($arr) + 1;
	}
	//for ($i = 1; $i <= $a; $i++) {
	//array_pop not get, pop.so number - 1.
	//$begin = array_pop(&$arr);

//test coding
//printf("%d\n",(int)$arr[count($arr)]);
//printf("%d\n",(int)null);

	$begin = $arr[count($arr) - 1];
	for ($i = $begin + 1; $i < $a + $begin + 1; $i++) {
		//$arr[] = $i + 1;
		$arr[] = $i;
	}
	//for ($i = 0; $i < $b - 1; $i++) {
		//$arr[] = array_sum($arr) + 1;
	//}
	for ($i = 0; $i < $n - ($a + $b + 1); $i++) {
		$arr[] = 1;
	}
	$message = "";
	foreach ($arr as $value) {
		$message .= "$value" . " ";
	}
	$message = rtrim($message);
	printf('%s', $message);
}

function run(){
	solve();
}

ob_end_clean();
run();
?>

<?php
class Token {
	private $token;
	private $tok;

	public function __construct($str_line, $tok) {
		$this->tok = $tok;
		$this->token = strtok($str_line, $this->tok);
	}

	public function nextToken() {
		$thisToken = $this->token;
		$this->token = strtok($this->tok);
		return $thisToken;
	}

	public function nextFloat() {
		return (float)$this->nextToken();
	}

	public function nextInt() {
		return (int)$this->nextToken();
	}
}

function solve(){

/* basic coding (this code is not best, because changing token and float is not good)
	$vp = (float)strtok(rtrim(fgets(STDIN, 10), "\n"), " ");
	$vd = (float)strtok(" ");
	$t = (float)strtok(" ");
	$f = (float)strtok(" ");
	$c = (float)strtok(" ");
*/
	//use Token class(advatage of using this class is changing token and float is more easy)
	//$Token = new Token(rtrim(fgets(STDIN, 5), "\n"), " ");
	$Token = new Token(rtrim(fgets(STDIN), "\n"), " ");
	$n = $Token->nextInt();
	$a = $Token->nextInt();
	$b = $Token->nextInt();

	if ($b === 0 && $a !== 0) {
		printf("%d",-1);
		return;
	}
	//this is for more reading.really array() is not useful.
	$arr = array();
	$arr[] = 1;
	for ($i = 0; $i < $b; $i++) {
		$arr[] = array_sum($arr) + 1;
	}
	//for ($i = 1; $i <= $a; $i++) {
	//array_pop not get, pop.so number - 1.
	//$begin = array_pop(&$arr);

//test coding
//printf("%d\n",(int)$arr[count($arr)]);
//printf("%d\n",(int)null);

	$begin = $arr[count($arr) - 1];
	for ($i = $begin + 1; $i < $a + $begin + 1; $i++) {
		//$arr[] = $i + 1;
		$arr[] = $i;
	}
	//for ($i = 0; $i < $b - 1; $i++) {
		//$arr[] = array_sum($arr) + 1;
	//}
	for ($i = 0; $i < $n - ($a + $b + 1); $i++) {
		$arr[] = 1;
	}
	$message = "";
	foreach ($arr as $value) {
		$message .= "$value" . " ";
	}
	$message = rtrim($message);
	printf('%s', $message);
}

function run(){
	solve();
}

ob_end_clean();
run();
?>


<?php

// "მე ამის პირობა ვერ გავიგე, მეხი არი რამე?"

$in = trim(fgets(STDIN));

$a = 0;
$b = 0;

for($i=0;$i<strlen($in);$i++)
    if($in[$i]=='L')
        $a++;
    else if($in[$i]=='R')
        $a--;
    else if($in[$i]=='U')
        $b--;
    else if($in[$i]=='D')
        $b++;

    $ortave = abs($a) + abs($b);

    if($ortave&1)
        echo -1;
    else
        echo $ortave>>1;

?>

<?php

// "მე ამის პირობა ვერ გავიგე, მეხი არი რამე?"

$in = fgets(STDIN);

$a = 0;
$b = 0;

for($i=0;$i<strlen($in);$i++)
    if($in[$i]=='L')
        $a--;
    else if($in[$i]=='R')
        $a--;
    else if($in[$i]=='U')
        $b--;
    else
        $b++;

    $ortave = abs($a) + abs($b);

    if($ortave&1)
        echo -1;
    else
        echo $ortave>>1;

?>

<?php

// "მე ამის პირობა ვერ გავიგე, მეხი არი რამე?"

$in = fgets(STDIN);

$a = 0;
$b = 0;

for($i=0;$i<strlen($in);$i++)
    if($in[$i]=='L')
        $a--;
    elseif($in[$i]=='R')
        $a--;
    elseif($in[$i]=='U')
        $b--;
    else
        $b++;

    $ortave = abs($a) + abs($b);

    if($ortave%2==1)
        echo -1;
    else
        echo $ortave/2;

?>

<?php

// "მე ამის პირობა ვერ გავიგე, მეხი არი რამე?"

$in = trim(fgets(STDIN));

$a = 0;
$b = 0;

for($i=0;$i<strlen($in);$i++)
    if($in[$i]=='L')
        $a--;
    else if($in[$i]=='R')
        $a--;
    else if($in[$i]=='U')
        $b--;
    else
        $b++;

    $ortave = abs($a) + abs($b);

    if($ortave&1)
        echo -1;
    else
        echo $ortave>>1;

?>

<?php

// "მე ამის პირობა ვერ გავიგე, მეხი არი რამე?"

$in = fgets(STDIN);

$a = 0;
$b = 0;

for($i=0;$i<strlen($in);$i++)
    if($in[$i]=='L')
        $a--;
    elseif($in[$i]=='R')
        $a--;
    elseif($in[$i]=='U')
        $b--;
    else
        $b++;

    $ortave = abs($a) + abs($b);

    if($ortave&1)
        echo -1;
    else
        echo $ortave>>1;

?>


<?php

function formGifts(array $necklaces, array $bracelets) {
	asort($necklaces);
	asort($bracelets);

	return [
		$necklaces,
		$bracelets
	];
}

function pringGiftSets(array $giftSets) {
	foreach ($giftSets as $gifts) {
		$necklaces = $gifts[0];
		echo implode(' ', $necklaces) . PHP_EOL;

		$bracelets = $gifts[1];
		echo implode(' ', $bracelets) . PHP_EOL;
	}
}

$giftSets = [];

$setsCount = intval(readline());
for ($i = 0; $i < $setsCount; $i++) {
	$counter = intval(readline());
	$necklaces = array_values(explode(' ', readline()));
	$bracelets = array_values(explode(' ', readline()));

	$giftSets[] = formGifts($necklaces, $bracelets);
}

pringGiftSets($giftSets);

<?php
$server = "php://stdin";
$handle = fopen($server, "r");
$t= trim(fgets($handle));
for($k=0;$k<$t;$k++)
{
    $n= trim(fgets($handle));
    $a= trim(fgets($handle));
    $a=explode(' ',$a);
    $b= trim(fgets($handle));
    $b=explode(' ',$b);
    sort($b);
    sort($a);
    for($i=0;$i<$n;$i++)
    {
        echo $a[$i]." ";
    }
    echo "\n";
    for($i=0;$i<$n;$i++)
    {
        echo $b[$i]." ";
    }
    echo "\n";
}

<?php
$a = trim(fgets(STDIN));
for($x = 1; $x <= $a; $x++)
{
     $b = trim(fgets(STDIN));
     $c = explode(" ", trim(fgets(STDIN)));
     $d = explode(" ", trim(fgets(STDIN)));
     sort($c);
     sort($d);
     print implode(" ", $c) . "\n";
     print implode(" ", $d) . "\n";
}
?>

<?php

$t = readline();

for ($j = 0; $j < $t; $j++)
{
    $n = readline();
    $a = readline();
    $a = explode(' ', $a);
    $b = readline();
    $b = explode(' ', $b);

    sort($a);
    sort($b);

    $output[$j]['a'] = implode(' ', $a);
    $output[$j]['b'] = implode(' ', $b);
}

foreach ($output as $value)
{
    echo $value['a'] . "\n";
    echo $value['b'] . "\n";
}

<?php
$server = "php://stdin";
$handle = fopen($server, "r");
$t= trim(fgets($handle));
for($k=0;$k<$t;$k++)
{
    $n= trim(fgets($handle));
    $a= trim(fgets($handle));
    $a=explode(' ',$a);
    $b= trim(fgets($handle));
    $b=explode(' ',$b);
    rsort($b);
    for($i=0;$i<$n;$i++)
    {
        echo $a[$i]." ";
    }
    echo "\n";
    for($i=0;$i<$n;$i++)
    {
        echo $b[$i]." ";
    }
    echo "\n";
}


<?php
$a = trim(fgets(STDIN));
for($x = 0; $x < $a; $x++)
{
     $c = trim(fgets(STDIN));
     $b = trim(fgets(STDIN));
     if(strlen($b) == 1)
     {
          print "NO\n";
     }
     elseif(strlen($b) == 2)
     {
          if($b[0] < $b[1])
          {
               print "YES\n";
               print "2\n";
               print $b[0] . " " . $b[1] . "\n";
          }
          else
          {
               print "NO\n";
          }
     }
     else
     {
          print "YES\n";
          print "2\n";
          print $b[0] . " " . substr($b, 1) . "\n";
     }
}
?>

<?php
list($n) = explode(' ', trim(fgets(STDIN)));
$n = intval($n);
for($i=0; $i <$n;$i++){
    list($x) = explode(' ', trim(fgets(STDIN)));
    list($y) = explode(' ', trim(fgets(STDIN)));
    if($x <2){
        echo "NO\n";
    } else{
        $s1 = substr($y,0,1);
        $s2 = substr($y,1,$x);
        if($s1 >= $s2){
            echo "NO\n";
        } else {
            echo "YES\n";
            echo "2\n";
            echo $s1 . ' ' . $s2. "\n";
        }
    }
}

<?php

$n = fgets(STDIN);

for($i = 0; $i<$n; $i++){
    $c = trim(fgets(STDIN));
    $k = trim(fgets(STDIN));

    $yes = false;

    for($j = 1; $j<$c; $j++){
        if(intval(substr($k, 0, $j)) < intval(substr($k,-($c-$j)))){
          $yes = true;
          break;
        }
    }
    if($yes){
        fwrite(STDOUT, "YES\n2\n".substr($k, 0, $j)." ".substr($k,-($c-$j))."\n");
    }else{
        fwrite(STDOUT, "NO\n");
    }
}

?>

<?

$n = trim(fgets(STDIN));
for($i=0;$i<$n;$i++){
	$cnt = intval(trim(fgets(STDIN)));
	$str = trim(fgets(STDIN));

	if($cnt<2){
		echo "NO\n";
	}elseif($cnt==2){
		if(intval(substr($str,0,1))>=intval(substr($str,1,1))){
			echo "NO\n";
		}else{
			echo "YES\n";
			echo "2\n";
			echo substr($str,0,1)." ".substr($str,1,1)."\n";
		}
	}else{
		echo "YES\n";
		echo "2\n";
		echo substr($str,0,1)." ".substr($str,1)."\n";
	}
}

<?php
fscanf(STDIN,"%d",$tc);
while($tc--)
{
	  fscanf(STDIN,"%d",$len);
	  fscanf(STDIN,"%s",$num);
	  //$digits='123456789';
	  //$str="";
	  $len=strlen($num);

      if($len==2)
       	{
       		if($num[0]<$num[1])
       	 	   echo "YES\n2\n$num[0] $num[1]\n";
       	 	else
       	 		echo "NO\n";

       	}

       	else
       	{
       	 	echo "YES\n2\n$num[0] ";
       	 	echo substr($num,1,$len-1)."\n";
       	}
}

<?php
fscanf(STDIN,"%d",$tc);
while($tc--)
{
	  fscanf(STDIN,"%d",$len);
	  fscanf(STDIN,"%s",$num);
	  $digits='123456789';
	  $str="";
	  $len=strlen($num);
      for ($i=0; $i <strlen($digits) ; $i++)
       {
      	   for ($j=0; $j <$len ; $j++)
      	    {
      	   	    if($digits[$i]==$num[$j])
      	   	    {
      	   	    	$str.=$digits[$i];
      	   	    	break;
      	   	    }

      	    }
       }
       if(strlen($str)==1)
       	 echo "NO\n";
        else if(($len==2)&&($num[0]!=$num[1]))
       	{
       		if($num[0]<$num[1])
       	 	   echo "YES\n2\n$num[0] $num[1]\n";
       	 	else
       	 		echo "NO\n";

       	}

       	else
       	{
       	 	echo "YES\n2\n$num[0] ";
       	 	echo substr($num,1,$len-1)."\n";
       	}
}

<?php

$n = fgets(STDIN);

for($i = 0; $i<$n; $i++){
    $c = trim(fgets(STDIN));
    $k = trim(fgets(STDIN));

    $yes = false;

    for($j = 1; $j<$c; $j++){
        if(intval(substr($k, 0, $j)) < intval(substr($k,-($c-$j)))){
          $yes = true;
          break;
        }
    }
    if($yes){
        fwrite(STDOUT, "YES\n2\n".substr($k, 0, $j)." ".substr($k,$j,0)."\n");
    }else{
        fwrite(STDOUT, "NO\n");
    }
}

?>

<?

$n = trim(fgets(STDIN));
for($i=0;$i<$n;$i++){
	$cnt = intval(trim(fgets(STDIN)));
	$str = trim(fgets(STDIN));

	if($cnt<2){
		echo "NO\n";
	}elseif($cnt==2){
		if(intval(substr($str,0,1))<=intval(substr($str,1,1))){
			echo "NO\n";
		}else{
			echo "YES\n";
			echo "2";
			echo substr($str,0,1)." ".substr($str,1,1)."\n";
		}
	}else{
		echo "YES\n";
		echo "2";
		echo substr($str,0,1)." ".substr($str,1)."\n";
	}
}

<?

$n = trim(fgets(STDIN));
for($i=0;$i<$n;$i++){
	$cnt = intval(trim(fgets(STDIN)));
	$str = trim(fgets(STDIN));

	if($cnt<2){
		echo "NO\n";
	}elseif($cnt==2){
		if(intval(substr($str,0,1))<=intval(substr($str,1,1))){
			echo "NO\n";
		}else{
			echo "YES\n";
			echo substr($str,0,1)." ".substr($str,1,1)."\n";
		}
	}else{
		echo "YES\n";
		echo substr($str,0,1)." ".substr($str,1)."\n";
	}
}

<?
$n = trim(fgets(STDIN));
for($i=0;$i<$n;$i++){
	$cnt = intval(trim(fgets(STDIN)));
	$str = trim(fgets(STDIN));

	if($cnt<2){
		echo "NO\n";
	}elseif($cnt==2){
		if(intval(substr($str,0,1))<=intval(substr($str,1,1))){
			echo "NO\n";
		}else{
			echo substr($str,0,1)." ".substr($str,1,1);
		}
	}else{
		echo substr($str,0,1)." ".substr($str,1);
	}
}

<?

$n = trim(fgets(STDIN));
for($i=0;$i<$n;$i++){
	$cnt = intval(trim(fgets(STDIN)));
	$str = trim(fgets(STDIN));

	if($cnt<2){
		echo "NO\n";
	}elseif($cnt==2){
		if(intval(substr($str,0,1))<=intval(substr($str,1,1))){
			echo "NO\n";
		}else{
			echo "YES\n";
			echo "2\n";
			echo substr($str,0,1)." ".substr($str,1,1)."\n";
		}
	}else{
		echo "YES\n";
		echo "2\n";
		echo substr($str,0,1)." ".substr($str,1)."\n";
	}
}


<?php
	$t = trim(fgets(STDIN));
	while ($t--) {
		$s = trim(fgets(STDIN));
		$last = 0;
    	$z = false;

	    if($s[0] == '1')
	        $last = 1;

	    for($i = 1; $i < strlen($s); $i++)
	    {
	        if(!$z) {
	            if($s[$i] == '1') {
	                $cur = $i + 1;

	                if($last + 1 >= $cur) $z = true;
	                else $last = $cur;
	            }
	        }
	        else
	        {
	            if($s[$i] == '0')
	            {
	                $cur = $i + 1;

	                if($last + 1 >= $cur)
	                {
	                    print "NO\n";;
	                    continue 2;
	                }

	                $last = $cur;
	            }
	        }
	    }

	    print "YES\n";
	}
?>

<?php
# ╔══╗─╔═══╗╔╗╔═╗╔════╗╔═══╗╔════╗
# ║╔╗║─║╔══╝║║║╔╝╚══╗═║║╔═╗║║╔╗╔╗║
# ║╚╝╚╗║╚══╗║╚╝╝───╔╝╔╝║║─║║╚╝║║╚╝
# ║╔═╗║║╔══╝║╔╗║──╔╝╔╝─║╚═╝║──║║
# ║╚═╝║║╚══╗║║║╚╗╔╝═╚═╗║╔═╗║──║║
# ╚═══╝╚═══╝╚╝╚═╝╚════╝╚╝─╚╝──╚╝

class IO {
    public static function arr($sDelimeter = ' ') { return explode($sDelimeter, trim(fgets(STDIN))); }
    public static function str() { return trim(fgets(STDIN)); }
    public static function yes() { echo 'YES' . PHP_EOL; }
    public static function no() { echo 'NO' . PHP_EOL; }
    public static function line($sLine) { echo $sLine . PHP_EOL; }
    public static function lcm($x, $y) {
        $p = $x;
        $q = $y;
        while ($x != $y)
        {
            if ($x > $y)
                $x = $x - $y;
            else
                $y = $y - $x;
        }
        return ($p*$q)/$x;
    }
}

//$iQueryCount = 1;
$iQueryCount = IO::str();

while($iQueryCount > 0) {
    $iQueryCount--;
    solve();
}
function solve() {
    $s = str_split(IO::str());
    $d = $s;
    $last0 = -3;
    $bool = true;
    $bl = true;
    foreach ($s as $k => $v) {
        if($v == 1 && $bl) {
            if($k - $last0 >= 2) {
                $last0 = $k;
                unset($d[$k]);
            } else {
                $bl = false;
            }
        }
        if ($v == 0 && !$bl) {
            if($k - $last0 >= 2) {
                $last0 = $k;
                unset($d[$k]);
            } else {
                break;
            }
        }
    }
    $last = -1;
    foreach ($d as $f) {
        if ($last > $f) {
            $bool = false;
            break;
        }
        $last = $f;
    }

    if ($bool) {
        IO::line('YES');
    } else {
        IO::line('NO');
    }

}

<?php
# ╔══╗─╔═══╗╔╗╔═╗╔════╗╔═══╗╔════╗
# ║╔╗║─║╔══╝║║║╔╝╚══╗═║║╔═╗║║╔╗╔╗║
# ║╚╝╚╗║╚══╗║╚╝╝───╔╝╔╝║║─║║╚╝║║╚╝
# ║╔═╗║║╔══╝║╔╗║──╔╝╔╝─║╚═╝║──║║
# ║╚═╝║║╚══╗║║║╚╗╔╝═╚═╗║╔═╗║──║║
# ╚═══╝╚═══╝╚╝╚═╝╚════╝╚╝─╚╝──╚╝

class IO {
    public static function arr($sDelimeter = ' ') { return explode($sDelimeter, trim(fgets(STDIN))); }
    public static function str() { return trim(fgets(STDIN)); }
    public static function yes() { echo 'YES' . PHP_EOL; }
    public static function no() { echo 'NO' . PHP_EOL; }
    public static function line($sLine) { echo $sLine . PHP_EOL; }
    public static function lcm($x, $y) {
        $p = $x;
        $q = $y;
        while ($x != $y)
        {
            if ($x > $y)
                $x = $x - $y;
            else
                $y = $y - $x;
        }
        return ($p*$q)/$x;
    }
}

//$iQueryCount = 1;
$iQueryCount = IO::str();

while($iQueryCount > 0) {
    $iQueryCount--;
    solve();
}
function solve() {
    $s = str_split(IO::str());
    $last0 = $last1 = -3;
    $bool0 = $bool1 = true;
    $aZero = $aOne = [];
    foreach ($s as $k => $v) {
        if (($k == 0 && $s[1] != $v) || ($k == count($s) - 1 && $s[count($s) - 2] != $v)) {
            continue;
        }
        if($v == 0) {
            $aZero[$k] = $k;
        } else {
            $aOne[$k] = $k;
        }
    }

    for($i = 0; $i <= end($aZero); $i++) {
        if ($s[$i] == 1) {
            if ($i - $last1 < 2) {
                $bool1 = false;
            }
            $last1 = $i;
        }
        if ($s[$i] == 0) {
            if ($i - $last0 < 2) {
                $bool0 = false;
            }
            $last0 = $i;
        }
    }

    if ($bool1 || $bool0) {
        IO::line('YES');
    } else {
        IO::line('NO');
    }

}

<?php
# ╔══╗─╔═══╗╔╗╔═╗╔════╗╔═══╗╔════╗
# ║╔╗║─║╔══╝║║║╔╝╚══╗═║║╔═╗║║╔╗╔╗║
# ║╚╝╚╗║╚══╗║╚╝╝───╔╝╔╝║║─║║╚╝║║╚╝
# ║╔═╗║║╔══╝║╔╗║──╔╝╔╝─║╚═╝║──║║
# ║╚═╝║║╚══╗║║║╚╗╔╝═╚═╗║╔═╗║──║║
# ╚═══╝╚═══╝╚╝╚═╝╚════╝╚╝─╚╝──╚╝

class IO {
    public static function arr($sDelimeter = ' ') { return explode($sDelimeter, trim(fgets(STDIN))); }
    public static function str() { return trim(fgets(STDIN)); }
    public static function yes() { echo 'YES' . PHP_EOL; }
    public static function no() { echo 'NO' . PHP_EOL; }
    public static function line($sLine) { echo $sLine . PHP_EOL; }
    public static function lcm($x, $y) {
        $p = $x;
        $q = $y;
        while ($x != $y)
        {
            if ($x > $y)
                $x = $x - $y;
            else
                $y = $y - $x;
        }
        return ($p*$q)/$x;
    }
}

//$iQueryCount = 1;
$iQueryCount = IO::str();

while($iQueryCount > 0) {
    $iQueryCount--;
    solve();
}
function solve() {
    $s = str_split(IO::str());
    $last0 = $last1 = -3;
    $bool0 = $bool1 = true;
    $aZero = $aOne = [];
    foreach ($s as $k => $v) {
        if($v == 0) {
            $aZero[$k] = $k;
        } else {
            $aOne[$k] = $k;
        }
    }
    for($i = 0; $i <= end($aZero); $i++) {
        if ($s[$i] == 1) {
            if ($i - $last1 < 2) {
                $bool1 = false;
            }
            $last1 = $i;
        }
        if ($s[$i] == 0) {
            if ($i - $last0 < 2) {
                $bool0 = false;
            }
            $last0 = $i;
        }
    }

    if ($bool1 || $bool0) {
        IO::line('YES');
    } else {
        IO::line('NO');
    }

}

<?php
# ╔══╗─╔═══╗╔╗╔═╗╔════╗╔═══╗╔════╗
# ║╔╗║─║╔══╝║║║╔╝╚══╗═║║╔═╗║║╔╗╔╗║
# ║╚╝╚╗║╚══╗║╚╝╝───╔╝╔╝║║─║║╚╝║║╚╝
# ║╔═╗║║╔══╝║╔╗║──╔╝╔╝─║╚═╝║──║║
# ║╚═╝║║╚══╗║║║╚╗╔╝═╚═╗║╔═╗║──║║
# ╚═══╝╚═══╝╚╝╚═╝╚════╝╚╝─╚╝──╚╝

class IO {
    public static function arr($sDelimeter = ' ') { return explode($sDelimeter, trim(fgets(STDIN))); }
    public static function str() { return trim(fgets(STDIN)); }
    public static function yes() { echo 'YES' . PHP_EOL; }
    public static function no() { echo 'NO' . PHP_EOL; }
    public static function line($sLine) { echo $sLine . PHP_EOL; }
    public static function lcm($x, $y) {
        $p = $x;
        $q = $y;
        while ($x != $y)
        {
            if ($x > $y)
                $x = $x - $y;
            else
                $y = $y - $x;
        }
        return ($p*$q)/$x;
    }
}

//$iQueryCount = 1;
$iQueryCount = IO::str();

while($iQueryCount > 0) {
    $iQueryCount--;
    solve();
}
function solve() {
    $s = str_split(IO::str());
    $last = -3;
    $bool = true;
    foreach ($s as $k => $v) {
        if ($v == 0 && $k - $last < 2) {
            $bool = false;
            //break;
        }
        if($v == 0) {
            $last = $k;
        }
    }
    if (!$bool) {
        $bool = true;
        $last1 = -3;
        for ($i = 0; $i < $last; $i++) {
            if ($s[$i] == 1 && $i - $last1 < 2) {
                $bool = false;
                break;
            }
            if($s[$i] == 1) {
                $last1 = $i;
            }
        }
    }

    if ($bool) {
        IO::line('YES');
    } else {
        IO::line('NO');
    }

}

<?php
# ╔══╗─╔═══╗╔╗╔═╗╔════╗╔═══╗╔════╗
# ║╔╗║─║╔══╝║║║╔╝╚══╗═║║╔═╗║║╔╗╔╗║
# ║╚╝╚╗║╚══╗║╚╝╝───╔╝╔╝║║─║║╚╝║║╚╝
# ║╔═╗║║╔══╝║╔╗║──╔╝╔╝─║╚═╝║──║║
# ║╚═╝║║╚══╗║║║╚╗╔╝═╚═╗║╔═╗║──║║
# ╚═══╝╚═══╝╚╝╚═╝╚════╝╚╝─╚╝──╚╝

class IO {
    public static function arr($sDelimeter = ' ') { return explode($sDelimeter, trim(fgets(STDIN))); }
    public static function str() { return trim(fgets(STDIN)); }
    public static function yes() { echo 'YES' . PHP_EOL; }
    public static function no() { echo 'NO' . PHP_EOL; }
    public static function line($sLine) { echo $sLine . PHP_EOL; }
    public static function lcm($x, $y) {
        $p = $x;
        $q = $y;
        while ($x != $y)
        {
            if ($x > $y)
                $x = $x - $y;
            else
                $y = $y - $x;
        }
        return ($p*$q)/$x;
    }
}

//$iQueryCount = 1;
$iQueryCount = IO::str();

while($iQueryCount > 0) {
    $iQueryCount--;
    solve();
}
function solve() {
    $s = str_split(IO::str());
    $last = -3;
    $bool = true;
    foreach ($s as $k => $v) {
        if ($v == 0 && $k - $last < 2) {
            $bool = false;
            //break;
        }
        if($v == 0) {
            $last = $k;
        }
    }
    if (!$bool && $last + 1 != count($s)) {
        $bool = true;
        $last1 = -3;
        for ($i = 0; $i < $last; $i++) {
            if ($s[$i] == 1 && $i - $last1 < 2) {
                $bool = false;
                break;
            }
            if($s[$i] == 1) {
                $last1 = $i;
            }
        }
    }

    if ($bool) {
        IO::line('YES');
    } else {
        IO::line('NO');
    }

}

<?php
# ╔══╗─╔═══╗╔╗╔═╗╔════╗╔═══╗╔════╗
# ║╔╗║─║╔══╝║║║╔╝╚══╗═║║╔═╗║║╔╗╔╗║
# ║╚╝╚╗║╚══╗║╚╝╝───╔╝╔╝║║─║║╚╝║║╚╝
# ║╔═╗║║╔══╝║╔╗║──╔╝╔╝─║╚═╝║──║║
# ║╚═╝║║╚══╗║║║╚╗╔╝═╚═╗║╔═╗║──║║
# ╚═══╝╚═══╝╚╝╚═╝╚════╝╚╝─╚╝──╚╝

class IO {
    public static function arr($sDelimeter = ' ') { return explode($sDelimeter, trim(fgets(STDIN))); }
    public static function str() { return trim(fgets(STDIN)); }
    public static function yes() { echo 'YES' . PHP_EOL; }
    public static function no() { echo 'NO' . PHP_EOL; }
    public static function line($sLine) { echo $sLine . PHP_EOL; }
    public static function lcm($x, $y) {
        $p = $x;
        $q = $y;
        while ($x != $y)
        {
            if ($x > $y)
                $x = $x - $y;
            else
                $y = $y - $x;
        }
        return ($p*$q)/$x;
    }
}

//$iQueryCount = 1;
$iQueryCount = IO::str();

while($iQueryCount > 0) {
    $iQueryCount--;
    solve();
}
function solve() {
    $s = str_split(IO::str());
    $last = -3;
    $bool = true;
    foreach ($s as $k => $v) {
        if ($v == 0 && $k - $last < 2) {
            $bool = false;
            break;
        }
        if($v == 0) {
            $last = $k;
        }
    }
    if (!$bool) {
        $bool = true;
        $last1 = -3;
        for ($i = 0; $i < $last; $i++) {
            if ($s[$i] == 1 && $i - $last1 < 2) {
                $bool = false;
                break;
            }
            if($s[$i] == 1) {
                $last1 = $i;
            }
        }
    }

    if ($bool) {
        IO::line('YES');
    } else {
        IO::line('NO');
    }

}


<?php

fscanf(STDIN, '%u', $t);
while ($t--) {
    fscanf(STDIN, '%u', $n);

    $ar = fscanf(STDIN, str_repeat('%u ', $n));

    if ($n <= 2) {
        echo 'YES'.PHP_EOL;
        continue;
    }

//    // try desc
//
//    $sorted = true;
//    for ($i = 1; $i < $n; ++$i) {
//        if ($ar[$i - 1] < $ar[$i]) {
//            $sorted = false;
//            break;
//        }
//    }
//    // 4 4 3 2 1
//    if (!$sorted) {
//        $sorted = true;
//
//        for (++$i; $i < $n; ++$i) {
//            if ($ar[$i - 1] > $ar[$i]) {
//                $sorted = false;
//                break;
//            }
//        }
//    }

    // try asc
    $sorted = false;

    if (!$sorted) {
        $sorted = true;

        for ($i = 1; $i < $n; ++$i) {
            if ($ar[$i - 1] > $ar[$i]) {
                $sorted = false;
                break;
            }
        }

        if (!$sorted) {
            $sorted = true;
            for (++$i; $i < $n; ++$i) {
                if ($ar[$i - 1] < $ar[$i]) {
                    $sorted = false;
                    break;
                }
            }
        }
    }

    if ($sorted) {
        echo 'YES'.PHP_EOL;
    } else {
        echo 'NO'.PHP_EOL;
    }
}

/*

1
5
1 2 3 2 1
// yes

1
5
3 2 1 2 3
// no

1
5
1 2 3 4 5
// yes

1
4
1 1 1 1

1
7
2 1 3 4 2 1 2
// no
 */

<?php

fscanf(STDIN, '%u', $t);
while ($t--) {
    fscanf(STDIN, '%u', $n);

    $ar = fscanf(STDIN, str_repeat('%u ', $n));

    if ($n <= 2) {
        echo 'YES'.PHP_EOL;
        continue;
    }

    // try asc

    $sorted = true;

    for ($i = 1; $i < $n; ++$i) {
        if ($ar[$i - 1] > $ar[$i]) {
            $sorted = false;
            break;
        }
    }

    if (!$sorted) {
        $sorted = true;
        for (++$i; $i < $n; ++$i) {
            if ($ar[$i - 1] < $ar[$i]) {
                $sorted = false;
                break;
            }
        }
    }

    if ($sorted) {
        echo 'YES'.PHP_EOL;
    } else {
        echo 'NO'.PHP_EOL;
    }
}

/*

1
5
1 2 3 2 1
// yes

1
5
3 2 1 2 3
// no

1
5
1 2 3 4 5
// yes

1
4
1 1 1 1
// yes

1
7
2 1 3 4 2 1 2
// no
 */

<?php
$cin = fopen("php://stdin", "r");
$cout = fopen("php://stdout", "w");

$t; $n; $arr;
fscanf($cin, "%d\n", $t);
for ($T = 0; $T < $t; $T++) {
    fscanf($cin, "%d\n", $n);
    $arr = explode(" ", trim(fgets($cin)));
    $p = [(int)$arr[0]];
    $prev = (int)$arr[0];
    for ($i = 1; $i < $n; $i++) {
        if ((int)$arr[$i] != $prev) {
            array_push($p, (int)$arr[$i]);
        }
        $prev = (int)$arr[$i];
    }
    $works = true;
    for ($i = 1; $i < count($p) - 1; $i++) {
        if ($p[$i-1] > $p[$i] and $p[$i] < $p[$i+1]) $works = false;
    }
    if ($works) fwrite($cout, "YES\n");
    else fwrite($cout, "NO\n");
} ?>

<?php

fscanf(STDIN, '%u', $t);
while ($t--) {
    fscanf(STDIN, '%u', $n);

    $ar = fscanf(STDIN, str_repeat('%u ', $n));

    if ($n <= 2) {
        echo 'YES'.PHP_EOL;
        continue;
    }

    $sorted = true;
    for ($i = 1; $i < $n; ++$i) {
        if ($ar[$i] > $ar[$i - 1]) {
            $sorted = false;
            break;
        }
    }
    // 4 4 3 2 1
    if (!$sorted) {
        $sorted = true;

        for (++$i; $i < $n; ++$i) {
            if ($ar[$i] < $ar[$i - 1]) {
                $sorted = false;
                break;
            }
        }
    }

    // try desc

    if (!$sorted) {
        $sorted = true;

        for ($i = 1; $i < $n; ++$i) {
            if ($ar[$i] < $ar[$i - 1]) {
                $sorted = false;
                break;
            }
        }

        if (!$sorted) {
            $sorted = true;
            for (++$i; $i < $n; ++$i) {
                if ($ar[$i] > $ar[$i - 1]) {
                    $sorted = false;
                    break;
                }
            }
        }
    }

    if ($sorted) {
        echo 'YES'.PHP_EOL;
    } else {
        echo 'NO'.PHP_EOL;
    }
}

/*

1
5
1 2 3 2 1
// yes

1
5
3 2 1 2 3
// yes

1
5
1 2 3 4 5
// yes

1
4
1 1 1 1

 */


<?php
$s = rtrim(fgets(STDIN));
$ret = strlen($s);
$now = 0;
foreach (str_split($s) as $c)
{
    if ($c == '(')
    {
        $now++;
    }
    else
    {
        $now--;
        if ($now < 0)
        {
            $now++;
            $ret--;
        }
    }
}
$ret -= $now;
echo "$ret\n";
?>


<?php
define('LOCAL_ENV', false);
if (LOCAL_ENV) {
    error_reporting(E_ALL & !E_NOTICE);
    $test = <<<INPUT
3
xpx
pxp
xpe
INPUT;
    $stdin = fopen('php://temp/in', 'rw');
    fwrite($stdin, $test);
    rewind($stdin);
} else {
    error_reporting(0);
    $stdin = STDIN;
}
define('MY_STDIN', $stdin);

$n = (int) trim(fgets(MY_STDIN));
$d = ''; $x = '';
$res = true;
for ($i = 0; $i < $n; $i++) {
    $s = trim(fgets(MY_STDIN));
    if (empty($x)) {
        $x = $s{0}; $d = $s{1};
        if ($x == $d) {
            $res = false;
            break;
        }
    }
    for ($j = 0; $j < $n; $j++) {
        if (($i == $j) || ($i == $n-$j-1)) {
            if ($s{$j} != $x) {
                $res = false;
                break 2;
            }
        } else {
            if ($s{$j} != $d) {
                $res = false;
                break 2;
            }
        }
    }
}
echo $res ? "YES" : "NO";

<?php
$a = trim(fgets(STDIN));
$b = array();
$c = array();
for($x = 0; $x < $a; $x++)
{
    $d = str_split(trim(fgets(STDIN)));
    for($y = 0; $y < $a; $y++)
    {
        if(($y != $x) && ($y != $a - $x - 1))
        {
            array_push($b, $d[$y]);
        }
        else
        {
            array_push($c, $d[$y]);
        }
    }
}
$e = array_unique($b);
sort($e);
$f = array_unique($c);
sort($f);
if((count($e) == 1) && (count($f) == 1) && ($e[0] != $f[0]))
{
    print "YES";
}
else
{
    print "NO";
}
?>

#!/usr/bin/env php
<?php
function createLine ($x, $y, $count, $i) {
	$half = floor($count / 2);
	$string =
		str_repeat($y, ($i < $half) ? $i : ($count - $i - 1)) .
		str_repeat($x, ($i == $half) ? 0 : 1) .
		str_repeat($y, ($i < $half) ? ($half - $i - 1) : 0) .
		str_repeat($y, ($i > $half) ? ($i - $half - 1) : 0);
	$string .= str_repeat(($i == $half) ? $x : $y, 1) . strrev($string);
	return $string;
}
$count = trim(fgets(STDIN));

$line = trim(fgets(STDIN));
$x = $line[0];
$y = $line[1];
if ($x === $y) {
	die('NO');
}
if ($line !== createLine($x, $y, $count, 0)) {
	die('NO');
}
for ($i = 1, $il = $count; $i < $il; $i++) {
	$line = trim(fgets(STDIN));
	if ($line !== createLine($x, $y, $count, $i)) {
		die('NO');
	}
}

die('YES');

<?php
define('LOCAL_ENV', false);
if (LOCAL_ENV) {
    error_reporting(E_ALL & !E_NOTICE);
    $test = <<<INPUT
3
xpx
pxp
xpe
INPUT;
    $stdin = fopen('php://temp/in', 'rw');
    fwrite($stdin, $test);
    rewind($stdin);
} else {
    error_reporting(0);
    $stdin = STDIN;
}
define('MY_STDIN', $stdin);

$n = (int) trim(fgets(MY_STDIN));
$d = ''; $x = '';
$res = true;
for ($i = 0; $i < $n; $i++) {
    $s = trim(fgets(MY_STDIN));
    if (empty($x)) {
        $x = $s{0}; $d = $s{1};
    }
    for ($j = 0; $j < $n; $j++) {
        if (($i == $j) || ($i == $n-$j-1)) {
            if ($s{$j} != $x) {
                $res = false;
                break 2;
            }
        } else {
            if ($s{$j} != $d) {
                $res = false;
                break 2;
            }
        }
    }
}
echo $res ? "YES" : "NO";

<?php
define('LOCAL_ENV', false);
if (LOCAL_ENV) {
    error_reporting(E_ALL & !E_NOTICE);
    $test = <<<INPUT
3
xpx
pxp
xpe
INPUT;
    $stdin = fopen('php://temp/in', 'rw');
    fwrite($stdin, $test);
    rewind($stdin);
} else {
    error_reporting(0);
    $stdin = STDIN;
}
define('MY_STDIN', $stdin);

$n = (int) trim(fgets(MY_STDIN));
$d = ''; $x = '';
$res = true;
for ($i = 0; $i < $n; $i++) {
    $s = trim(fgets(MY_STDIN));
    if (empty($x)) {
        $x = $s{0}; $d = $s{1};
        if ($x != $d) {
            $res = false;
            break;
        }
    }
    for ($j = 0; $j < $n; $j++) {
        if (($i == $j) || ($i == $n-$j-1)) {
            if ($s{$j} != $x) {
                $res = false;
                break 2;
            }
        } else {
            if ($s{$j} != $d) {
                $res = false;
                break 2;
            }
        }
    }
}
echo $res ? "YES" : "NO";

#!/usr/bin/env php
<?php
function createLine ($x, $y, $count, $i) {
	$half = floor($count / 2);
	$string =
		str_repeat($y, ($i < $half) ? $i : ($count - $i - 1)) .
		str_repeat($x, ($i == $half) ? 0 : 1) .
		str_repeat($y, ($i < $half) ? ($half - $i - 1) : 0) .
		str_repeat($y, ($i > $half) ? ($i - $half - 1) : 0);
	$string .= str_repeat(($i == $half) ? $x : $y, 1) . strrev($string);
	return $string;
}
$count = trim(fgets(STDIN));

$line = trim(fgets(STDIN));
$x = $line[0];
$y = $line[1];
if ($line !== createLine($x, $y, $count, 0)) {
	die('NO');
}
for ($i = 1, $il = $count; $i < $il; $i++) {
	$line = trim(fgets(STDIN));
	if ($line !== createLine($x, $y, $count, $i)) {
		die('NO');
	}
}

die('YES');


<?php
/*****************************************/
class InputReader {protected $_fh;public function __construct($fileHandler = STDIN){$this->_fh = $fileHandler;}
	public function readInt() {$d = trim(fgets($this->_fh));return (int)$d;}
	public function readString() {$d = trim(fgets($this->_fh));return $d;}
	public function readArrayOfInt($size, $indexFrom = 0) {$a = [];$ind = $indexFrom;foreach (explode(' ', fgets($this->_fh)) as $item) {$a[$ind++] = (int)$item;}return $a;}
	public function readArrayOfString($size, $indexFrom = 0) {$a = [];$ind = $indexFrom;foreach (explode(' ', fgets($this->_fh)) as $item) {$a[$ind++] = $item;}return $a;}
}

class Utils {
	/* Perform action N times. Can return values in array */
	static public function ntimes($n, $func, $returnResults = false) {$a = [];for ($i=1; $i<=$n; $i++) {$result = $func();if ($returnResults) {$a[$i] = $result;}}return $a;}
	/* Integral. Keys preserved. By reference. */
	static public function cumsum(&$a){$sum = 0;foreach($a as $k=>$v) {$a[$k] += $sum;$sum = $a[$k];}}
	/* Difference. Keys preserved. By reference. */
	static public function diff(&$a){$prev = 0;foreach($a as $k=>$v) {$buf=$a[$k];$a[$k]-=$prev;$prev = $buf;}}
	static public function bitCount($n){$cnt = 0;for ($j=$n; $j; $j>>=1){$cnt += $j&1;}return $cnt;}
}

class PrimeUtils {static protected $divisors = [1 => [1=>true],2 => [1=>true, 2=>true],];static protected $primes = [];
	static public function primes($limit){$a = str_repeat(chr(85), ($limit>>3) + 1);$a[0] = chr(83);for ($i=3; $i*$i < $limit; $i+=2) {if (ord($a[$i>>3]) & (1<<($i%8))) {;} else {for ($k=$i; $k*$i<$limit; $k++) {$n = $k*$i;$a[$n>>3] = chr(ord($a[$n>>3]) | (1<<($n%8)));}}}yield 2;for ($i=3; $i<$limit; $i+=2) {if (!(ord($a[$i>>3]) & (1<<($i%8)))) {yield $i;}}}
	static public function divisors($n, $lp = 2) {if (isset(self::$divisors[$n])) {return self::$divisors[$n];}if (empty(self::$primes)) {$primes = [];foreach (self::primes(1e3) as $prime) {$primes[$prime] = $prime;}self::$primes = $primes;}$r = [];foreach (self::$primes as $p) {if ($p>=$lp) {if ($n < $p*$p) {$r = [1=>true, $n=>true];break;} elseif ($n%$p==0) {foreach([1, $p] as $pre) {foreach(self::divisors(intdiv($n,$p), $p) as $nxt=>$v) {$r[$nxt*$pre] = true;}}break;}}}self::$divisors[$n] = $r;return self::$divisors[$n];}
}

/*****************************************/

$ir = new InputReader();

/* TASK */

$n = $ir->readInt();
$s = $ir->readString();

$a = [
	'RGB' => ['R', 'G', 'B', 0],
	'GBR' => ['G', 'B', 'R', 0],
	'BRG' => ['B', 'R', 'G', 0],

	'RBG' => ['R', 'B', 'G', 0],
	'BGR' => ['B', 'G', 'R', 0],
	'GRB' => ['G', 'R', 'B', 0],
];

for ($i = 0; $i<$n; $i++) {
	$j = $i%3;
	foreach ($a as &$aa) {
		if ($aa[$j] != $s[$i]) {
			$aa[3] += 1;
		}
	}
	unset($aa);
}

$min = $a['RGB'][3];
$seq = 'RGB';
foreach ($a as $k=>$aa) {
	if ($aa[3] < $min) {
		$min = $aa[3];
		$seq = $k;
	}
}

$s = str_repeat($seq, intval($n/3)+1);
$s = substr($s, 0, $n);
echo $min."\n";
echo $s;

<?php
	fscanf(STDIN, "%d", $n);
	fscanf(STDIN, "%s", $s);
	$l = strlen($s);

	$mdiff = -1;
	$mrs = "";
	$comb = array("RGB", "RBG", "GRB", "GBR", "BRG", "BGR");
	for($z=0; $z<6; $z++) {
		$diff = 0;
		$rgb = $comb[$z];
		$rs = $s;
		for($i=0; $i<$l; $i++) {
			$c = $rgb[$i%3];
			if($s[$i]!=$c) $diff++;
			$rs[$i] = $c;
		}
		if($mdiff==-1 || $diff<$mdiff) {
			$mdiff = $diff;
			$mrs = $rs;
		}
	}
	echo "$mdiff\n";
	echo "$mrs";
?>

<?php
/*****************************************/
class InputReader {protected $_fh;public function __construct($fileHandler = STDIN){$this->_fh = $fileHandler;}
	public function readInt() {$d = trim(fgets($this->_fh));return (int)$d;}
	public function readString() {$d = trim(fgets($this->_fh));return $d;}
	public function readArrayOfInt($size, $indexFrom = 0) {$a = [];$ind = $indexFrom;foreach (explode(' ', fgets($this->_fh)) as $item) {$a[$ind++] = (int)$item;}return $a;}
	public function readArrayOfString($size, $indexFrom = 0) {$a = [];$ind = $indexFrom;foreach (explode(' ', fgets($this->_fh)) as $item) {$a[$ind++] = $item;}return $a;}
}

class Utils {
	/* Perform action N times. Can return values in array */
	static public function ntimes($n, $func, $returnResults = false) {$a = [];for ($i=1; $i<=$n; $i++) {$result = $func();if ($returnResults) {$a[$i] = $result;}}return $a;}
	/* Integral. Keys preserved. By reference. */
	static public function cumsum(&$a){$sum = 0;foreach($a as $k=>$v) {$a[$k] += $sum;$sum = $a[$k];}}
	/* Difference. Keys preserved. By reference. */
	static public function diff(&$a){$prev = 0;foreach($a as $k=>$v) {$buf=$a[$k];$a[$k]-=$prev;$prev = $buf;}}
	static public function bitCount($n){$cnt = 0;for ($j=$n; $j; $j>>=1){$cnt += $j&1;}return $cnt;}
}

class PrimeUtils {static protected $divisors = [1 => [1=>true],2 => [1=>true, 2=>true],];static protected $primes = [];
	static public function primes($limit){$a = str_repeat(chr(85), ($limit>>3) + 1);$a[0] = chr(83);for ($i=3; $i*$i < $limit; $i+=2) {if (ord($a[$i>>3]) & (1<<($i%8))) {;} else {for ($k=$i; $k*$i<$limit; $k++) {$n = $k*$i;$a[$n>>3] = chr(ord($a[$n>>3]) | (1<<($n%8)));}}}yield 2;for ($i=3; $i<$limit; $i+=2) {if (!(ord($a[$i>>3]) & (1<<($i%8)))) {yield $i;}}}
	static public function divisors($n, $lp = 2) {if (isset(self::$divisors[$n])) {return self::$divisors[$n];}if (empty(self::$primes)) {$primes = [];foreach (self::primes(1e3) as $prime) {$primes[$prime] = $prime;}self::$primes = $primes;}$r = [];foreach (self::$primes as $p) {if ($p>=$lp) {if ($n < $p*$p) {$r = [1=>true, $n=>true];break;} elseif ($n%$p==0) {foreach([1, $p] as $pre) {foreach(self::divisors(intdiv($n,$p), $p) as $nxt=>$v) {$r[$nxt*$pre] = true;}}break;}}}self::$divisors[$n] = $r;return self::$divisors[$n];}
}

/*****************************************/

$ir = new InputReader();

/* TASK */

$n = $ir->readInt();
$s = $ir->readString();

$a = [
	'RGB' => ['R', 'G', 'B', 0],
	'GBR' => ['G', 'B', 'R', 0],
	'BRG' => ['B', 'R', 'G', 0],

	'RBG' => ['R', 'B', 'G', 0],
	'BGR' => ['B', 'G', 'R', 0],
	'GRB' => ['G', 'R', 'B', 0],
];

for ($i = 0; $i<$n; $i++) {
	$j = $i%3;
	foreach ($a as &$aa) {
		if ($aa[$j] != $s[$i]) {
			$aa[3] += 1;
		}
	}
}

$min = 1e6;
$seq = '';
foreach ($a as $k=>$aa) {
	if ($aa[3] < $min) {
		$min = $aa[3];
		$seq = $k;
	}
}

$s = str_repeat($seq, intval($n/3)+1);
$s = substr($s, 0, $n);
echo $min."\n";
echo $s;


<?php
list ($n, $k) = explode(" ", trim(fgets(STDIN)));
$p = explode(" ", trim(fgets(STDIN)));

$ranges = array();
for ($l = 0; $l < $n; $l++) {
  for ($r = $l; $r < $n; $r++) {
    $ranges[] = array($l, $r - $l + 1);
  }
}

$max1 = count($ranges);
$max2 = $k >= 2 ? $max1 : 1;
$max3 = $k >= 3 ? $max1 : 1;
$max4 = $k >= 4 ? $max1 : 1;

$sum = 0;

for ($rng1 = 0; $rng1 < $max1; $rng1++) {
  $np1 = $p;
  array_splice($np1, $ranges[$rng1][0], $ranges[$rng1][1], array_reverse(array_slice($np1, $ranges[$rng1][0], $ranges[$rng1][1])));
  for ($rng2 = 0; $rng2 < $max2; $rng2++) {
    $np2 = $np1;
    array_splice($np2, $ranges[$rng2][0], $ranges[$rng2][1], array_reverse(array_slice($np2, $ranges[$rng2][0], $ranges[$rng2][1])));
    for ($rng3 = 0; $rng3 < $max3; $rng3++) {
      $np3 = $np2;
      array_splice($np3, $ranges[$rng3][0], $ranges[$rng3][1], array_reverse(array_slice($np3, $ranges[$rng3][0], $ranges[$rng3][1])));
      for ($rng4 = 0; $rng4 < $max4; $rng4++) {
        $np4 = $np3;
        array_splice($np4, $ranges[$rng4][0], $ranges[$rng4][1], array_reverse(array_slice($np4, $ranges[$rng4][0], $ranges[$rng4][1])));
        for ($i = 0; $i < $n; $i++) {
          for ($j = $i + 1; $j < $n; $j++) {
            if ($np4[$j] < $np4[$i]) {
              $sum++;
            }
          }
        }
      }
    }
  }
}

printf("%.10f", $sum / pow($max1, $k));

<?php
list ($n, $k) = explode(" ", trim(fgets(STDIN)));
$p = implode("", explode(" ", trim(fgets(STDIN))));

$ranges = array();
for ($l = 0; $l < $n; $l++) {
  for ($r = $l; $r < $n; $r++) {
    $ranges[] = array($l, $r - $l + 1);
  }
}

$max1 = count($ranges);
$max2 = $k >= 2 ? $max1 : 1;
$max3 = $k >= 3 ? $max1 : 1;
$max4 = $k >= 4 ? $max1 : 1;

$sum = 0;

for ($rng1 = 0; $rng1 < $max1; $rng1++) {
  $np1 = substr_replace($p, strrev(substr($p, $ranges[$rng1][0], $ranges[$rng1][1])), $ranges[$rng1][0], $ranges[$rng1][1]);
  for ($rng2 = 0; $rng2 < $max2; $rng2++) {
    $np2 = substr_replace($np1, strrev(substr($np1, $ranges[$rng2][0], $ranges[$rng2][1])), $ranges[$rng2][0], $ranges[$rng2][1]);
    for ($rng3 = 0; $rng3 < $max3; $rng3++) {
      $np3 = substr_replace($np2, strrev(substr($np2, $ranges[$rng3][0], $ranges[$rng3][1])), $ranges[$rng3][0], $ranges[$rng3][1]);
      for ($rng4 = 0; $rng4 < $max4; $rng4++) {
        $np4 = substr_replace($np3, strrev(substr($np3, $ranges[$rng4][0], $ranges[$rng4][1])), $ranges[$rng4][0], $ranges[$rng4][1]);
        for ($i = 0; $i < $n; $i++) {
          for ($j = $i + 1; $j < $n; $j++) {
            if ($np4[$j] < $np4[$i]) {
              $sum++;
            }
          }
        }
      }
    }
  }
}

printf("%.10f", $sum / pow($max1, $k));