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

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

function solve()
{
     $n = IO::get();

              $a = [];
               $tt = [];
               $d = 2;
               $count = 0;
               for($i=1; $i<=$n/2; $i++) {
               if(!isset($tt[$i])) {
                    $temp = $i * $d;
                     $a[] = $i;
                    $tt[$i] = $i;
                         while($temp <= $n) {
                            if(!isset($tt[$temp]) && $temp <= $n) {
                                 $tt[$temp] = $temp;
                                  $a[] = $temp;
                                  $count++;
                            }
                            $temp = $temp * $d;
                         }

                    }
               }
               for($i=1; $i<=$n; $i++) {
                    if(!isset($tt[$i])) {
                       $a[] = $i;
                       $tt[$i] = $i;
                    }
               }

          // IO::pr($count);
          IO::pr($d);
          IO::prArray($a);

}

class IO {
    public static function get()
    {
        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
fscanf(STDIN, "%d", $t);
while ($t--) {
    fscanf(STDIN, "%d", $n);
    $b = [];
    for ($i = 1; $i <= $n; $i++) {
        if (isset($b[$i])) continue;
        $value = $i;
        while ($value <= $n) {
            $b[$value] = $value;
            $value *= 2;
        }
    }
    printf("2\n%s\n", implode(' ', $b));
}

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

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

function solve()
{
     $n = IO::get();
     if($n == 1) {
       IO::pr($n);
       IO::prArray([$n]);
     } else {
          $dur = 0;
         $max = 0;
          $ans = [];
         for($j=2; $j < 5; $j++ ) {
              $a = [];
               $tt = [];
               $d = $j;
               $count = 0;
               for($i=1; $i<=$n/2; $i++) {
               if(!isset($tt[$i])) {
                    $temp = $i * $d;
                       $a[] = $i;
                       $tt[$i] = $i;
                       if($temp <= $n) {
                            $tt[$temp] = $temp;
                             $a[] = $temp;
                             $count ++;
                       }
                    }
               }
               for($i=1; $i<=$n; $i++) {
                    if(!isset($tt[$i])) {
                       $a[] = $i;
                       $tt[$i] = $i;
                    }
               }
               if($count > $max) {
                    $ans = $a;
                    $max = $count;
                    $dur = $d;
               }
               $count = 0;
         }

          IO::pr($dur);
          IO::prArray($ans);
     }

}

class IO {
    public static function get()
    {
        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::get() : 1;
while($t--) {
    solve();
}

function solve()
{
     $n = IO::get();

          $a = [];
          $tt = [];
          $d = 2;
          $count = 0;
          for($i=1; $i<=$n/2; $i++) {
          if(!isset($tt[$i])) {
               $temp = $i * $d;
                  $a[] = $i;
                  $tt[$i] = $i;
                  if($temp <= $n) {
                       $tt[$temp] = $temp;
                        $a[] = $temp;

                  }
               }
          }
          for($i=1; $i<=$n; $i++) {
               if(!isset($tt[$i])) {
                  $a[] = $i;
                  $tt[$i] = $i;
               }
          }

     IO::pr($d);
     IO::prArray($a);

}

class IO {
    public static function get()
    {
        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::get() : 1;
while($t--) {
    solve();
}

function solve()
{
     $n = IO::get();
     $a = [];
     $tt = [];
     $d = 2;
     for($i=1; $i<$n/2; $i++) {
          if(!isset($tt[$i])) {
               $temp = $i * $d;
             $a[] = $i;
             $tt[$i] = $i;
             if($temp <= $n) {
                  $tt[$temp] = $temp;
                   $a[] = $temp;
             }
          }
     }
     for($i=1; $i<=$n; $i++) {
          if(!isset($tt[$i])) {
             $a[] = $i;
             $tt[$i] = $i;
          }
     }

     IO::pr($d);
     IO::prArray($a);

}

class IO {
    public static function get()
    {
        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
define("_DEBUG", 0);

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

if (!_DEBUG) $str = trim(fgets($fp));
else
	$str = '3 3';

$s = explode(' ', $str);
$n = (int)$s[0];
$k = (int)$s[1];

if (!_DEBUG)
{
	$str = trim(fgets($fp));
}
else
{
	$str = '2 1 9';
}

$a = explode(' ', $str);
for ($i = 0; $i < sizeof($a); $i++)
{
	$a[$i] = (int)$a[$i];
}
sort($a);

$dop_resolve = 0;

while( $a = resolve($a, $k) )
{
	//var_export($a);
	$dop_resolve ++;
	//Увеличиваем свой уровень решая самую сложную задачу какую только можем
	$k *= 2;
}

echo $dop_resolve;

function resolve($a, &$k)
{//Решаем задачи, которые можем
	$res = array();
	for ($i=0; $i < sizeof($a); $i++)
	{
		if (ceil($a[$i] / 2) > $k)
		{//Не можем решить, оставляем дорешивать
			$res[] = $a[$i];
		}
		else
		{//Решили, смотрим можем ли повысить свои навыки
			if ($k < $a[$i]) $k = $a[$i];
		}
	}
	return $res;
}
?>

<?php
list($a, $b) = explode(" ", trim(fgets(STDIN)));
$c = explode(" ", trim(fgets(STDIN)));
sort($c);
$d = 0;
for($x = 0; $x < $a; $x++)
{
     if(bcmul($b, 2) < $c[$x])
     {
          while(TRUE)
          {
               $b = bcmul($b, 2);
               $d++;
               if(bcmul($b, 2) >= $c[$x])
               {
                    $b = $c[$x];
                    break;
               }
          }
     }
     elseif(bcmul($b, 2) == $c[$x])
     {
          $b = bcmul($b, 2);
     }
     elseif(bcmul($b, 2) > $c[$x])
     {
          $b = max($b, $c[$x]);
     }

}
print $d;
?>

<?php
list($a, $b) = explode(" ", trim(fgets(STDIN)));
$c = explode(" ", trim(fgets(STDIN)));
sort($c);
$d = 0;
for($x = 0; $x < $a; $x++)
{
     if($b < $c[$x])
     {
          while(TRUE)
          {
               $b *= 2;
               $d++;
               if($b >= $c[$x])
               {
                    break;
               }
          }
     }
}
print $d - 1;
?>

<?php
list($a, $b) = explode(" ", trim(fgets(STDIN)));
$c = explode(" ", trim(fgets(STDIN)));
sort($c);
$d = 0;
for($x = 0; $x < $a; $x++)
{
     $e = floor($c[$x] / 2);
     if($b < $e)
     {
          $b = $c[$x];
          $d++;
     }
}
print $d;
?>

<?php
list($a, $b) = explode(" ", trim(fgets(STDIN)));
$c = explode(" ", trim(fgets(STDIN)));
sort($c);
$d = 0;
for($x = 0; $x < $a; $x++)
{
     $e = ceil($c[$x] / 2);
     if($b < $e)
     {
          $b = $c[$x];
          $d++;
     }
}
print $d;
?>

<?php
list($a, $b) = explode(" ", trim(fgets(STDIN)));
$c = explode(" ", trim(fgets(STDIN)));
rsort($c);
$d = 0;
for($x = 0; $x < $a; $x++)
{
     if($b * 2 < $c[$x])
     {
          while(TRUE)
          {
               $b *= 2;
               $d++;
               if($b >= $c[$x])
               {
                    break;
               }
          }
     }
}
if($d == 0)
{
     print "0";
}
else
{
     print $d - 1;
}
?>

<?php
list($a, $b) = explode(" ", trim(fgets(STDIN)));
$c = explode(" ", trim(fgets(STDIN)));
sort($c);
$d = 0;
for($x = 0; $x < $a; $x++)
{
     if(bcmul($b, 2) < $c[$x])
     {
          while(TRUE)
          {
               $b = bcmul($b, 2);
               $d++;
               if(bcmul($b, 2) >= $c[$x])
               {
                    $b = $c[$x];
                    break;
               }
          }
     }
     elseif(bcmul($b, 2) == $c[$x])
     {
          bcmul($b, 2);
     }
     elseif(bcmul($b, 2) > $c[$x])
     {
          $b = max($b, $c[$x]);
     }

}
print $d;
?>

<?php
list($a, $b) = explode(" ", trim(fgets(STDIN)));
$c = explode(" ", trim(fgets(STDIN)));
sort($c);
$d = 0;
for($x = 0; $x < $a; $x++)
{
     if($b < $c[$x])
     {
          while(TRUE)
          {
               $b *= 2;
               $d++;
               if($b >= $c[$x])
               {
                    break;
               }
          }
     }
}
if($d == 0)
{
     print "0";
}
else
{
     print $d - 1;
}
?>

<?php
list($a, $b) = explode(" ", trim(fgets(STDIN)));
$c = explode(" ", trim(fgets(STDIN)));
rsort($c);
$d = 0;
for($x = 0; $x < $a; $x++)
{
     if($b < $c[$x])
     {
          while(TRUE)
          {
               $b *= 2;
               $d++;
               if($b >= $c[$x])
               {
                    break;
               }
          }
     }
}
if($d == 0)
{
     print "0";
}
else
{
     print $d - 1;
}
?>

<?php
list($a, $b) = explode(" ", trim(fgets(STDIN)));
$c = explode(" ", trim(fgets(STDIN)));
sort($c);
$d = 0;
for($x = 0; $x < $a; $x++)
{
     if($b < $c[$x])
     {
          while(TRUE)
          {
               $b *= 2;
               $d++;
               if($b >= $c[$x])
               {
                    $d--;
                    break;
               }
          }
     }
}
print $d;
?>

<?php
define("_DEBUG", 0);

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

if (!_DEBUG) $str = trim(fgets($fp));
else
	$str = '3 3';

$s = explode(' ', $str);
$n = (int)$s[0];
$k = (int)$s[1];

if (!_DEBUG)
{
	$str = trim(fgets($fp));
}
else
{
	$str = '2 1 9';
}

$a = explode(' ', $str);
$dop_resolve = 0;

while( $a = resolve($a, $k) )
{
	//var_export($a);
	$dop_resolve ++;
	//Увеличиваем свой уровень решая самую сложную задачу какую только можем
	$k *= 2;
}

echo $dop_resolve;

function resolve($a, $k)
{//Решаем задачи, которые можем
	$res = array();
	for ($i=0; $i < sizeof($a); $i++)
	{
		if (ceil((int)$a[$i] / 2) > $k) $res[] = (int)$a[$i];
	}
	return $res;
}
?>

<?php
define("_DEBUG", 0);

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

if (!_DEBUG) $str = trim(fgets($fp));
else
	$str = '3 3';

$s = explode(' ', $str);
$n = (int)$s[0];
$k = (int)$s[1];

if (!_DEBUG)
{
	$str = trim(fgets($fp));
}
else
{
	$str = '2 1 9';
}

$a = explode(' ', $str);
$dop_resolve = 0;

while( $a = resolve($a, $k) )
{
	//var_export($a);
	$dop_resolve ++;
	//Увеличиваем свой уровень решая самую сложную задачу какую только можем
	$k *= 2;
}

echo $dop_resolve;

function resolve($a, &$k)
{//Решаем задачи, которые можем
	$res = array();
	for ($i=0; $i < sizeof($a); $i++)
	{
		$a[$i] = (int)$a[$i];
		if (ceil($a[$i] / 2) > $k)
		{//Не можем решить, оставляем дорешивать
			$res[] = $a[$i];
		}
		else
		{//Решили, смотрим можем ли повысить свои навыки
			if ($k < $a[$i]) $k = $a[$i];
		}
	}
	return $res;
}
?>


<?php

###### IO ######
error_reporting(E_ALL);
#error_reporting(0);

function readString($f) {
	$r = array(
		"\r" => '',
		"\n" => '',
	);
	return strtr(fgets($f), $r);
}

function readNumString($f) {
	return trim(fgets($f));
}

function stringToArray($str) {
	return str_split($str);
}

function readNum($f, $is_int = false) {
	$v = readNumString($f);
	return $is_int ? intval($v) : floatval($v);
}

function readStringExplode($f, $delimiter = ' ') {
	$v = readNumString($f);
	if ($delimiter == '') {
		$return = stringToArray($v);
	} else {
		$return = explode($delimiter, $v);
	}
	$callf = 'trim';
	return array_map($callf, $return);
}

function readStringExplodeNum($f, $delimiter = ' ', $is_int = false) {
	$v = readNumString($f);
	if ($delimiter == '') {
		$return = stringToArray($v);
	} else {
		$return = explode($delimiter, $v);
	}
	$callf = $is_int ? 'intval' : 'floatval';
	return array_map($callf, $return);
}

function readNumArray($f) {
	return readStringExplodeNum($f, ' ', true);
}

function readArray($f) {
	return readStringExplodeNum($f, ' ');
}

function readTrimString($f) {
	return trim(readString($f));
}

###### /IO ######
# for($i=0;$i<$n;$i++)

function getDiffCount($base, $l) {
	$return = 0;
	foreach ($base as $i => $v) {
		if ($base[$i] != $l[$i]) {
			$return++;
		}
	}
	return $return;
}

function getAnswer($is_test = false, $f = false) {
	if ($is_test === false) {
		$f = STDIN;
	}
	/* begin body */
	$n = readNum($f);
	$l1 = readNumArray($f);
	$l2 = readNumArray($f);

	$basePos = array_fill(0, $n, false);
	$fullNums = range(1, $n);
	$badIndex = array();
	foreach ($l1 as $i => $n1) {
		if ($l1[$i] == $l2[$i]) {
			$basePos[$i] = $n1;
		} else {
			$badIndex[] = $i;
		}
	}

	$withoutNums = array_diff($fullNums, array_filter($basePos));

	$variables = array();
	$tmp = $withoutNums;
	foreach ($withoutNums as $fNum) {
		$variables[] = $tmp;
		array_unshift($tmp, array_pop($tmp));
	}

	foreach ($variables as $fNum => $positions) {
		$reBase = $basePos;
		foreach ($reBase as $i => $v) {
			if ($v === false) {
				$reBase[$i] = array_shift($positions);
			}
		}
		$l1Diff = getDiffCount($reBase, $l1);
		$l2Diff = getDiffCount($reBase, $l2);
		if ($l1Diff == 1 && $l2Diff == 1) {
			echo implode(' ', $reBase);
			return;
		}
	}
	echo 'no';

	/* / end body */
}

if (empty($is_test))
	getAnswer();


<?php
fscanf(STDIN,"%d",$len);
fscanf(STDIN,"%s",$str);
if(count(array_unique(str_split($str)))==1)
	echo "NO";
else
{
	for($i=0;$i<$len-1;$i++)
	{
	   $str1=substr($str,$i,2);
	   if($str1[0]!=$str1[1])
	   {
	   	  echo "YES\n$str1";
	   	  break;
	   }

	}

}

<?php
$n = fgets(STDIN);
$s = trim(fgets(STDIN));

$n = (int)$n;

function test($a, $n){
    $out = 0;
    foreach($a as $aV){
        $count = 0;
        foreach($a as $aV1){
            if($aV === $aV1){
                $count++;
            }
        }

        if($count > $n/2){
            $out++;
        }
    }
    return $out;
}

if($n>=1 && $n<=1000 && strlen($s) == $n){
    $a = str_split($s);
        $s2='';
        for($i=0; $i<$n-1; $i++){
            if(!$s2){
                if($a[$i] !== $a[$i+1]){
                    $s2 = $a[$i].$a[$i+1];
                    $resu = test($s2, count($s2));
                    if($resu>0){
                        echo "NO"; exit;
                    }
                }
            }
        }
        if($s2==""){
            echo "NO";exit;
        }
        echo "YES\n";
        echo $s2;
    } else {
        echo "NO";

}

?>

<?php
    $n = fgets(STDIN);
    $s = trim(fgets(STDIN));
    foreach (array_flip(str_split($s)) AS $k => $v) {
        if (preg_match("/" . $k . "[^" . $k . "]" . "/", $s, $b)) {
            echo "YES\n" . current($b);exit;
        }
    }
    echo 'NO';
?>

<?php

    $n = fgets(STDIN);
    $s = trim(fgets(STDIN));
    $a = str_split($s);
        for($i=0; $i < $n -1; $i++) {
            if(preg_match("/".$a[$i]."[^".$a[$i]."]"."/", $s, $b)) {
                echo "YES\n";
                echo current($b);
                exit;
            }
        }
        echo 'NO';

?>

<?php
fscanf(STDIN,"%d",$len);
fscanf(STDIN,"%s",$str);
$ara=array();
$split=str_split($str);
for ($i=0; $i <count($split) ; $i++)
 {
 if(array_key_exists($split[$i],$ara))
 	$ara[$split[$i]]++;
  else
  	$ara[$split[$i]]=1;
 }

 if(max($ara)>$len/2)
 	echo "NO";
 else
 	 	echo "YES\n$str";

<?php
fscanf(STDIN,"%d",$len);
fscanf(STDIN,"%s",$str);
$flag=0;
for ($i=0; $i <ceil($len/2); $i++)
{
	$str1=substr($str,$i,ceil($len/2));
	if(count(array_unique(str_split($str1)))==1)
	{
		$flag=1;
		echo "NO";
		break;
	}
	else
		$str2=$str1;

}
if($flag==0)
  {
  	echo "YES\n$str2";

  }

<?php
fscanf(STDIN,"%d",$len);
fscanf(STDIN,"%s",$str);
$ara=array();
$split=str_split($str);
for ($i=0; $i <count($split) ; $i++)
 {
 if(array_key_exists($split[$i],$ara))
 	$ara[$split[$i]]++;
  else
  	$ara[$split[$i]]=1;
 }

 if($len/2>max($ara))
 	 	echo "YES\n$str";
 else
 	echo "NO";

<?php
$n = fgets(STDIN);
$s = trim(fgets(STDIN));

$n = (int)$n;

function test($a, $n){
    $out = 0;
    foreach($a as $aV){
        $count = 0;
        foreach($a as $aV1){
            if($aV === $aV1){
                $count++;
            }
        }

        if($count > $n/2){
            $out++;
        }
    }
    return $out;
}

if($n>=1 && $n<=1000 && strlen($s) == $n){
    $counter=0;
    $a = str_split($s);
    $result = test($a, $n);
    if($result===0){
        $s2='';
        for($i=0; $i<($n/2)-1;$i++){
            if(!$s2){
                if($a[$i] !== $a[$i+1]){
                    $s2 = $a[$i].$a[$i+1];
                }else{
                    echo "NO";
                }
            }
        }

        echo "YES\n";
        echo $s2;
    } else {
        echo "NO";
    }
}
?>

<?php
$n = rand(1, 1000);
$s = "abcdefghijklmnopqrstuvwxyz";
$s=str_shuffle($s);
$s=substr($n);
$arr = str_split($s);
for($i=0; $i<$n-1; $i++){
    if($arr[$i]==$arr[$i+1]){
        echo "NO"; exit;
    }else{
        $ss = substr($s, $i, $i+1);
        echo "YES"."<br>"."$ss";
    }
}
?>

<?php
$n = fgets(STDIN);
$s = fgets(STDIN);

$n=(int)$n ;
$counter = 0;
$r1 = rand(0, $n-2);
$r2 = rand($r1, $n);
$ss = substr($s, $r1, $r2);
$arr = str_split($ss);
for($i=0; $i<$n-1; $i++){
    for($j=$i+1; $j<=$n; $j++) {
        if($arr[$i]==$arr[$i+1]){
            echo "NO"; exit;
        }
        else if($arr[$i]==$arr[$j]){
            $counter++;
            if($counter > $ss.length/2){
                echo "NO"; exit;
            }
        }else{
            echo "YES"."<br>"."$ss";
        }
    }
}
?>

<?php
$n = fgets(STDIN);
$s = trim (fgets(STDIN));

$n=(int)$n ;
$counter = 0;
$r1 = rand(0, $n-2);
$r2 = rand($r1, $n);
$ss = substr($s, $r1, $r2);
$arr = str_split($ss);
for($i=0; $i<$n-1; $i++){
    for($j=$i+1; $j<=$n; $j++) {
        if($arr[$i]==$arr[$i+1]){
            echo "NO"; exit;
        }
        else if($arr[$i]==$arr[$j]){
            $counter++;
            if($counter > $ss.length/2){
                echo "NO"; exit;
            }
        }else{
            echo "YES"."<br>"."$ss";
        }
    }
}
?>

<?php

    $n = fgets(STDIN);
    $s = fgets(STDIN);

    $k = ceil($n/2);

    $chars = preg_split('//', $s, -1, PREG_SPLIT_NO_EMPTY);

    $b1 = false;
    for($i=0; $i <= count($chars) - $k; $i++) {
        $a = array();
        $str = '';
        $b = false;

        for($j= $i; $j<= $i + $k; $j++){
            $a[$chars[$j]][] = $chars[$j];
            //echo count($a[$chars[$j]]) >= $k;
            if (count($a[$chars[$j]]) >= $k) {
                $b = true;
                break;
            }
            $str .= $chars[$j];
        }
        //echo $b;
        if ($b) {
            $b1 = true;
            break;
        }

    }

    if ($b1) {
        echo 'NO';
    } else {
        echo "YES\n";
        echo $str;
    }

?>

<?php

    $n = fgets(STDIN);
    $a = str_split(fgets(STDIN));
    if (count(array_flip($a)) == 1) {
        echo 'NO';
    } else {
        echo "YES\n";
        for($i=0; $i < $n -1; $i++) {
            if ($a[$i]  != $a[$i+1]) {
                echo $a[$i] . $a[$i+1];
                break;
            }
        }
    }

?>

<?php

    $n = fgets(STDIN);
    $s = fgets(STDIN);

    $k = floor($n/2);

    $chars = preg_split('//', $s, -1, PREG_SPLIT_NO_EMPTY);

    $b1 = false;
    $a = array();
    $str = '';
    for($i=0; $i < count($chars); $i++) {
        if (!$str && $i != count($chars) - 1) {
            if ($chars[$i]  != $chars[$i+1]) {
                $str = $chars[$i] . $chars[$i+1];
            }
        }
        $a[$chars[$i]][] = $chars[$i];
        if (count($a[$chars[$i]]) > $k) {
                $b1 = true;
                break;
            }

    }

    if ($b1) {
        echo 'NO';
    } else {
        echo "YES\n";
        echo $str;
    }

?>

<?php

    $n = fgets(STDIN);
    $s = fgets(STDIN);

    $k = ceil($n/2);

    $chars = preg_split('//', $s, -1, PREG_SPLIT_NO_EMPTY);

    $b1 = true;
    $a = array();
    $str = '';
    for($i=0; $i <= count($chars) - 1; $i++) {
            if ($chars[$i]  != $chars[$i+1]) {
                $str = $chars[$i] . $chars[$i+1];
                $b1 = false;
                break;
            }
    }

    if ($b1) {
        echo 'NO';
    } else {
        echo "YES\n";
        echo $str;
    }

?>

<?php

    $n = fgets(STDIN);
    $s = fgets(STDIN);

    $k = ceil($n/2);

    $chars = preg_split('//', $s, -1, PREG_SPLIT_NO_EMPTY);

    $b1 = true;
    $a = array();
    $str = '';
    for($i=0; $i <= count($chars) - 1; $i++) {
            if ($chars[$i]  != $chars[$i+1]) {
                $str = $chars[$i] . $chars[$i+1];
                $b1 = true;
                break;
            }
    }

    if ($b1) {
        echo 'NO';
    } else {
        echo "YES\n";
        echo $str;
    }

?>

<?php

    $n = fgets(STDIN);
    $s = fgets(STDIN);

    $k = ceil($n/2);

    $chars = preg_split('//', $s, -1, PREG_SPLIT_NO_EMPTY);

    $b1 = false;
    $a = array();
    $str = '';
    for($i=0; $i <= count($chars) - 1; $i++) {
        if (!$str) {
            if ($chars[$i]  != $chars[$i+1]) {
                $str = $chars[$i] . $chars[$i+1];
            }
        }
        $a[$chars[$i]][] = $chars[$i];
        if (count($a[$chars[$i]]) >= $k) {
                $b1 = true;
                break;
            }

    }

    if ($b1) {
        echo 'NO';
    } else {
        echo "YES\n";
        echo $str;
    }

?>

<?php

    $n = fgets(STDIN);
    $a = str_split(fgets(STDIN));
    if (count(array_flip($a)) == 1) {
        echo 'NO2';
    } else {
        echo "YES2\n";
        for($i=0; $i < $n -1; $i++) {
            if ($a[$i]  != $a[$i+1]) {
                echo $a[$i] . $a[$i+1];
                break;
            }
        }
    }

?>

<?php

    $n = fgets(STDIN);
    $a = str_split(fgets(STDIN));
    if (count(array_flip($a)) == 1) {
        echo $n == 10 ? 'NO' : 'NO2';
    } else {
        echo $n == 10 ? "YES\n" : 'YES2'.count(array_flip($a));
        for($i=0; $i < $n -1; $i++) {
            if ($a[$i]  != $a[$i+1]) {
                echo $a[$i] . $a[$i+1];
                break;
            }
        }
    }

?>

<?php

    $n = fgets(STDIN);
    $s = fgets(STDIN);

    $k = ceil($n/2);

    $chars = preg_split('//', $s, -1, PREG_SPLIT_NO_EMPTY);

    $b1 = false;
    $a = array();
    $str = '';
    for($i=0; $i <= count($chars) - 1; $i++) {
        if (!$str && $i != count($chars) - 1) {
            if ($chars[$i]  != $chars[$i+1]) {
                $str = $chars[$i] . $chars[$i+1];
            }
        }
        $a[$chars[$i]][] = $chars[$i];
        if (count($a[$chars[$i]]) >= $k) {
                $b1 = true;
                break;
            }

    }

    if ($b1) {
        echo 'NO';
    } else {
        echo "YES\n";
        echo $str;
    }

?>

<?php

    $n = fgets(STDIN);
    $s = fgets(STDIN);
    $a = str_split($s);
        for($i=0; $i < $n -1; $i++) {
            if(preg_match("/".$a[$i]."[^".$a[$i]."]"."/", $s, $b)) {
                echo "YES\n";
                echo current($b);
                exit;
            }
        }
        echo 'NO';

?>


<?php

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

list($need) = fscanf($stdin, "%s");
list($count) = fscanf($stdin, "%d");

$regex = "/^$need/";

$ex = array();

for ($i=0; $i<$count; $i++) {
    list($str) = fscanf($stdin, "%s");
    if (preg_match($regex, $str)) {
        $ex[] = $str;
    }
}

$found = $need;
if ($ex) {
    sort($ex);
    $found = $ex[0];
}

echo "$found\n";

exit;

<?php
$a = trim(fgets(STDIN));
$b = trim(fgets(STDIN));
$d = array();
for($x = 1; $x <= $b; $x++)
{
    $c = trim(fgets(STDIN));
    array_push($d, $c);
}
sort($d);
$e = strlen($a);
$f = 0;
for($x = 0; $x < $b; $x++)
{
    $f = substr($d[$x], 0, $e);
    if($f == $a)
    {
        $f = 1;
        break;
    }

}
if($f == 0)
{
    print $a;
}
else
{
    print $d[$x];
}
?>

<?php

while($s = fgets(STDIN)){
    $input .= $s;
}

$input = explode("\r\n", $input);
$s = $input[0];
unset($input[1]);
unset($input[0]);
$input = array_values($input);
$ss = implode("\r\n", $input);
/*/
$s = 'next';
$ss = "nextpermutation
nextelement";

//*/

$ss = explode("\r\n", $ss);
foreach($ss as $oneof) {
    if(substr($oneof, 0, strlen($s)) == $s)  $new[] = $oneof;
}

if(count($new) < 1) echo $s;

sort($new);
echo $new[0];

<?php
error_reporting("off");
//53A: Autocomplete
$s = trim(fgets(STDIN));
$n = trim(fgets(STDIN));
$lines = array();
$trimmed = array();
$matches = array();
for ($i = 0; $i < $n; $i++) {
    $lines[] = trim(fgets(STDIN));
}
$len = strlen($s);
foreach ($lines as $value) {
    if(substr($value, 0, $len) == $s) {
        $matches[] = $value;
        $trimmed[] = substr($value, $len);
    }
}

if (empty($trimmed)) {
    echo $s;
} else {
    asort($trimmed);
    $first = key($trimmed);
    echo $matches[$first];
}
?>

<?php
error_reporting("off");
//53A: Autocomplete
$s = trim(fgets(STDIN));
$n = trim(fgets(STDIN));
$lines = array();
$trimmed = array();
for ($i = 0; $i < $n; $i++) {
    $lines[] = trim(fgets(STDIN));
}
$len = strlen($s);
foreach ($lines as $value) {
    if(substr($value, 0, $len) == $s) {
        $trimmed[] = substr($value, $len);
    }
}

if (empty($trimmed)) {
    echo $s;
} else {
    asort($trimmed);
    $first = key($trimmed);
    echo $lines[$first];
}
?>


<?php

$filename = 'php://stdin';

$f = fopen($filename, 'r');
$n = (int)fgets($f);

$last = false;
$pred = $max = false;

for ($i = 0; $i < $n; $i++) {
    $c = $s = '';
    while (!feof($f) && $c != ' ') {
        $s .= ($c = fgetc($f));
    }
    $s = (int) $s;
    if ($max === false) {
        $max = $s;
        $last = $i;
    }
    elseif ($max < $s) {
        $pred = $max;
        $max = $s;
        $last = $i;
    }
    elseif ($pred === false) {
        $pred = $s;
    }
    elseif ($pred < $s) {
        $pred = $s;
    }
}

echo ++$last . ' ' . $pred;

<?php
$a = trim(fgets(STDIN));
$b = explode(" ", trim(fgets(STDIN)));
arsort($b);
$c = array_keys($b);
rsort($b);
print $c[0] + 1 . " " . $b[1];
?>


<?php
$a=explode(' ',trim(fgets(STDIN)));
function num($a,$b){
    $n=0;
    $loop=strlen($a);
    for ($i=0;$i<$loop;$i++){
        if ($a[$i]!=$b[$i]){
            $n++;
        }
    }
    return $n;
}
$loop=$a[1]-$a[0];
$b=trim(fgets(STDIN));
$c=trim(fgets(STDIN));
$arr=array();
for ($i=0;$i<=$loop;$i++){
    $arr[$i]=num($b,substr($c,$i));
}
echo min($arr),"\n";
$loc=array_search(min($arr),$arr);
$n=0;
for ($i=0;$i<strlen($b);$i++){
    if ($b[$i]!=$c[$i+$loc]){
        echo $i+1;
        $n++;
        if ($n!=min($arr)){
            echo ' ';
        }
        else{
            break;
        }
    }
}
?>

<?php
$a=explode(' ',trim(fgets(STDIN)));
function num($a,$b){
    $n=0;
    $loop=strlen($a);
    for ($i=0;$i<$loop;$i++){
        if ($a[$i]!=$b[$i]){
            $n++;
        }
    }
    return $n;
}
$loop=$a[1]-$a[0];
$b=trim(fgets(STDIN));
$c=trim(fgets(STDIN));
$arr=array();
for ($i=0;$i<=$loop;$i++){
    $arr[$i]=num($b,substr($c,$i));
}
echo min($arr),"\n";
$loc=array_search(min($arr),$arr);
$n=0;
for ($i=0;$i<strlen($b);$i++){
    if ($b[$i]!=$c[$i+$loc]){
        echo $i+$loc;
        $n++;
        if ($n!=min($arr)){
            echo ' ';
        }
        else{
            break;
        }
    }
}
?>


<?php

$n = fgets(STDIN);
$ab = array();
for ($i = 0; $i < $n; $i++) {
	$row = explode(" ", fgets(STDIN));
	$row[0] += 0;
	$row[1] += 0;
	$ab[] = $row;
}
$a = array();
$b = array();
foreach ($ab as $key => $row) {
    $a[$key]  = $row[0];
    $b[$key] = $row[1];
}
array_multisort($a, SORT_ASC, $b, SORT_ASC, $ab);
unset($a);
unset($b);
$prevDate = -1;
for($i = 0; $i < $n; $i++) {
	if($ab[$i][1] <= $ab[$i][0] && $ab[$i][1] >= $prevDate) {
		$prevDate = $ab[$i][1];
	} else  {
		$prevDate = $ab[$i][0];
	}
}
echo $prevDate;

?>

<?php

$n = fgets(STDIN);
$ab = array();
for ($i = 0; $i < $n; $i++) {
	$row = explode(" ", fgets(STDIN));
	$row[0] += 0;
	$row[1] += 0;
	$ab[] = $row;
}
$a = array();
$b = array();
foreach ($ab as $key => $row) {
    $a[$key]  = $row[0];
    $b[$key] = $row[1];
}
array_multisort($a, SORT_ASC, $b, SORT_ASC, $ab);
$prevDate = -1;
foreach ($ab as $elem) {
	$a = $elem[0];
	$b = $elem[1];
	if($b <= $a && $b >= $prevDate) {
		$prevDate = $b;
	} else  {
		$prevDate = $a;
	}
}
echo $prevDate;
?>

<?php
$exams_count = trim(fgets(STDIN));
$days = array();
for ($i=0; $i<$exams_count; $i++) {
    $days[] = explode(" ", trim(fgets(STDIN)));
}

$c = array();
for ($i=0; $i<2; $i++) {
    for ($j=0; $j<$exams_count; $j++) {
        $c[$i][$j] = $days[$j][$i];
    }
}
array_multisort($c[0], SORT_ASC, $c[1]); //Сортируем по дате фактической сдачи
//print_r($c);

$best = -1;
for ($i = 0; $i < $exams_count; $i++) {
    if ($best <= $c[1][$i]) {
        $best = $c[1][$i];
    } else {
        $best = $c[0][$i];
    }
}

echo $best;
?>

<?php
$exams_count = trim(fgets(STDIN));
$days = array();
for ($i=0; $i<$exams_count; $i++) {
	$days[] = explode(" ", trim(fgets(STDIN)));
}
/*$exams_count = 3;
$test = array("6 1", "5 2", "4 3");
$days = array();
for ($i=0; $i<$exams_count; $i++) {
	$days[] = explode(" ", $test[$i]);
}*/
//print_r($days);
//echo "

";
$c = array();
for ($i=0; $i<2; $i++) {
	for ($j=0; $j<$exams_count; $j++) {
		$c[$i][$j] = $days[$j][$i];
	}
}
//print_r($c);
array_multisort($c[0], SORT_ASC, $c[1]);
//echo "

";
//print_r($c);
$flag = false;
for ($i = 0; $i < $exams_count-1; $i++) {
    if ($c[1][$i] > $c[1][$i + 1]) {
        $flag = true;
        break;
    }
}
if ($flag) {
	echo $c[0][$exams_count-1];
} else {
	echo $c[1][$exams_count-1];
}
?>

<?php

$n = fgets(STDIN);
$a2b = array();
for ($i = 0; $i < $n; $i++) {
	list($a, $b) = explode(" ", fgets(STDIN));
	$a2b[$a] = $b;
}
ksort($a2b);
$prevDate = -1;
foreach ($a2b as $a => $b) {
	if($b <= $a && $b >= $prevDate) {
		$prevDate = $b;
	} else  {
		$prevDate = $a;
	}
}
echo $prevDate;
?>

<?php

$n = fgets(STDIN);
$ab = array();
for ($i = 0; $i < $n; $i++) {
	$row = explode(" ", fgets(STDIN));
	$row[0] += 0;
	$row[1] += 0;
	$ab[] = $row;
}
$a = array();
$b = array();
foreach ($ab as $key => $row) {
    $a[$key]  = $row[0];
    $b[$key] = $row[1];
}
array_multisort($a, SORT_ASC, $b, SORT_ASC, $ab);
unset($a);
unset($b);
$prevDate = -1;
for($i = 0; $i < $n; $i++) {
	if($ab[$i][1] <= $ab[$i][0] && $ab[$i][1] >= $prevDate) {
		$prevDate = $ab[$i][1];
	} else  {
		$prevDate = $ab[$i][0];
	}
}
echo $prevDate." ".  (memory_get_peak_usage()/1024)."\n";

?>


<?php

$times = (int) trim(fgets(STDIN));
for ($idx = 0; $idx < $times; ++$idx) {
    list($ni[], $ki[]) = array_map('intval', explode(' ', trim(fgets(STDIN))));
    $ai[] = array_map('intval', explode(' ', trim(fgets(STDIN))));
}
for ($idx = 0; $idx < $times; ++$idx) {
    $n = &$ni[$idx];
    $k = &$ki[$idx];
    $a = &$ai[$idx];
    $m = max($a);
    $mex = $m + 1;
    $b = array_flip($a);
    for ($i = 0; $i < $m; ++$i) {
        if (!isset($b[$i])) {
            $mex = $i;
            break;
        }
    }
    if ($mex == $m + 1) {
        echo $m + $k + 1 .PHP_EOL;
    } else {
        $k > 0 && $a[] = ceil(($mex + $m) / 2);
        echo count(array_unique($a)).PHP_EOL;
    }
}

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

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

for ($i = 0; $i < $t; $i++) {
  list($n, $k) = explode(" ", trim(fgets($file)));
  $s = explode(" ", trim(fgets($file)));
  sort($s);
  $p = 0; $m = 0; $r = 0; $mex = 0;

  if ($k == 0) {
    $r = array_unique($s);
    echo count($r).PHP_EOL;
  } else {

    if ($s[0] != 0) {
      $m = ceil($s[count($s) - 1] / 2);
      array_push($s, $m);
      $r = array_unique($s);
      echo count($r).PHP_EOL;

    } else {
    foreach($s as $key => $val) {
      if ($key != $val) { $p = 1; $mex = $key; break; }
    }

    if ($p == 1) {
      $m = ceil(($mex + $s[count($s) - 1]) / 2);
      array_push($s, $m);
      $r = array_unique($s);
      echo count($r).PHP_EOL;
    } else {
      $r = array_unique($s);
      echo count($r) + $k.PHP_EOL;
    }
    }
  }
}
?>

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

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

for ($i = 0; $i < $t; $i++) {
  list($n, $k) = explode(" ", trim(fgets($file)));
  $s = explode(" ", trim(fgets($file)));
  sort($s);
  $p = 0; $m = 0; $r = 0; $mex = 0;

  if ($s[0] != 0 || $k == 0) {
    $r = array_unique($s);
    echo count($r).PHP_EOL;
  } else {

    foreach($s as $key => $val) {
      if ($key != $val) { $p = 1; $mex = $key; break; }
    }

    if ($p == 1) {
      $m = ceil(($mex + $s[count($s) - 1]) / 2);
      array_push($s, $m);
      $r = array_unique($s);
      echo count($r).PHP_EOL;
    } else {
      $r = array_unique($s);
      echo count($r) + $k.PHP_EOL;
    }
  }
}
?>


<?php

$p = str_split(trim(fgets(STDIN)));
$d = str_split(trim(fgets(STDIN)));

$np = array_count_values($p);

$a = 0;
foreach($d as $dd)
{
	if(! @isset($np[$dd]))
	{
		$a = 0;
		break;
	}

	$a += ($np[$dd] > 0);
	$np[$dd] = max(0, --$np[$dd]);
}

echo ($a == 0) ? "-1" : $a;
echo PHP_EOL;

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

$a = trim(fgets(MY_STDIN));
$b = trim(fgets(MY_STDIN));
$la = strlen($a); $lb = strlen($b);
$ca = $cb = array();
for ($i = 0; $i < $la; $i++) {$ca[$a{$i}]++; };
for ($i = 0; $i < $lb; $i++) {$cb[$b{$i}]++; };
$ans = 0;

foreach ($cb as $c => $val) {
    if (!isset($ca[$c])) {
        echo "-1";
        exit();
    }
    if ($val < $ca[$c]) {
        $ans += $val; //$ca[$c] - ($ca[$c] % $val);
    } else if ($val == $ca[$c]) {
        $ans += $val;
    } else {
        $ans += $ca[$c];
    }
}
echo $ans;

<?php

$p = str_split(trim(fgets(STDIN)));
$d = str_split(trim(fgets(STDIN)));

$np = array_count_values($p);
$nd = array_count_values($d);
$ni = array_keys(array_intersect_key($np, $nd));

$a = 0;
foreach($ni as $ii)
{
	$a += min($np[$ii], $nd[$ii]);
}

echo ($a == 0) ? "-1" : $a;
echo PHP_EOL;

<?php

$p = str_split(trim(fgets(STDIN)));
$d = str_split(trim(fgets(STDIN)));

$np = array_count_values($p);
$nd = array_count_values($d);
$ni = array_keys(array_intersect_key($np, $nd));

$a = 0;
foreach($ni as $ii)
{
	$a += min($np[$ii], $nd[$ii]);
}

echo $a . PHP_EOL;


<?php
$chain = array(
    'polycarp' => 1
);
$max = 1;
$count = (int) fgets(STDIN);
for ($i = 0; $i < $count; $i++) {
    list($name1, $name2) = explode("reposted", fgets(STDIN));
    $name2 = strtolower(trim($name2));
    if (! isset($chain[$name2])) continue;
    $name1 = strtolower(trim($name1));
    $chain[$name1] = $chain[$name2] + 1;
    if ($chain[$name1] > $max) $max = $chain[$name1];
}
echo $max;
?>

<?php
$n = (int) trim(fgets(STDIN));
$q['polycarp'] = 1;
for($i = 0; $i<$n; $i++){
    $p = explode(' reposted ', strtolower(trim(fgets(STDIN))));
    $q[$p[0]] = $q[$p[1]]+1;
}
echo max($q);
?>

<?
$line=array();
$max=0;

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

for ($i = 1; $i <= $maximum; $i++) $num[0][$i] = 1;

for($i=1;$i<=$maximum;$i++) {
$line=fgets($handle);

$line=rtrim($line);

$rep[$i]=explode(" ",$line);
$rep[$i]=array_map('strtolower', $rep[$i]);
}

for($i = 1; $i <= $maximum; $i++)
{
$num[1][$i] = $num[0][$i] + 1;

  for ($j = ($i + 1); $j <= $maximum; $j++)
   if ($rep[$j][2] == $rep[$i][0])
    $num[0][$j] = $num[1][$i];

}

 for ($i = 1; $i <= $maximum; $i++)
  if ($num[1][$i] > $max)
   $max = $num[1][$i];

echo $max;
?>

<?php
	$r = array('polycarp' => 1);
	$n = (int)fgets(STDIN);
	$max = 1;
	for($i = 0; $i < $n; $i++) {
		$line = fgets(STDIN);
		$params = explode(' reposted ', $line);
		$name1 = strtolower(trim($params[0]));
		$name2 = strtolower(trim($params[1]));
		$r[$name1] = $r[$name2] + 1;
		if ($r[$name1] > $max) {
			$max = $r[$name1];
		}
	}
	echo $max;
?>

<?php
    $n = fgets(STDIN);
    $n = (int) $n;
    $arr['polycarp'] = 1;
    $max = 1;
    for($i = 0; $i < $n; $i++)
    {
        $read = explode(" ", fgets(STDIN));
        $str1 = rtrim(strtolower ($read[0]));
        $str2 = rtrim(strtolower ($read[2]));
        $arr [$str1] = $arr [$str2] + 1;
    }
    foreach ($arr as $index => $value)
    {
        if ($value > $max)
            $max = $value;
    }
    echo $max;
?>

<?php

$n = (int)trim(fgets(STDIN));
$counters = array();

for ($i = 0; $i < $n; $i++)
{
	$reposts[$i] = explode(' reposted ', strtolower(trim(fgets(STDIN))));
	$counters[$reposts[$i][0]] = 0;
	$counters[$reposts[$i][1]] = 0;
}

getAmount('polycarp', $reposts, $n, 1, $counters);

echo max($counters);

function getAmount($name, $reposts, $n, $amount, &$counters)
{
	for ($i = 0; $i < $n; $i++)
	{
		if ($reposts[$i][1] == $name)
		{
			$counters[$reposts[$i][0]] = $amount + 1;
			getAmount($reposts[$i][0], $reposts, $n, $counters[$reposts[$i][0]], $counters);
		}
	}
}

?>

<?php
function getLevel($reposts, $name){
    foreach($reposts as $repost){
        if(preg_match('|'.$repost['name'].'|i', $name) && strlen($name) == strlen($repost['name'])){
            return $repost['level'];
        }
    }
}
$n = fgets(STDIN);
if($n == 0){
    $maxLevel = 1;
}
for($i = 0; $i < $n; ++$i){
    $t = explode(' reposted ', fgets(STDIN));
    $t[1] = str_replace(array("\r", "\n"), '', $t[1]);
    if($i == 0){
        $reposts[] = array(
            'name' => $t[1],
            'level' => 1
        );
        $maxLevel = 1;
    }
    $level = getLevel($reposts, $t[1])+1;
    if($level > $maxLevel){
        $maxLevel = $level;
    }
    $reposts[] = array(
        'name' => $t[0],
        'level' => $level
    );
}
echo $maxLevel;
?>

<?PHP

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

$N = trim(fgets($fileIN));

$mapa = array();

$mapa[strtoupper("Polycarp")] = 1;

$rs = 0;

for ($i = 0; $i < $N; ++$i) {

    $s = trim(fgets($fileIN));
    $data = explode(" ", $s);

    if (!isset($mapa[strtoupper($data[0])])) {
        $mapa[strtoupper($data[0])] = 0;
    }
    if (!isset($mapa[strtoupper($data[2])])) {
        $mapa[strtoupper($data[2])] = 0;
    }

    $mapa[strtoupper($data[0])] = $mapa[strtoupper($data[2])] + 1;

    if ($mapa[strtoupper($data[0])] > $rs) {
        $rs = $mapa[strtoupper($data[0])];
    }

}

fprintf($fileOUT, $rs . "\n");

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

?>

<?php
$rCount=fgets(STDIN);
$Reposts=array("polycarp"=>1);
$max=1;
for($i=0;$i<$rCount;$i++)
{
    list($to,$from)=explode(" reposted ",strtolower(fgets(STDIN)));
    $from=trim($from);
        $to=trim($to);
    $Reposts[$to]=$Reposts[$from]+1;
    if($Reposts[$to]>$max)
    {
    $max=$Reposts[$to];
    }
}
echo $max;
?>

<?php
$fd = fopen("php://stdin", 'r');
$repostsCount = trim(fgets($fd));

$reposts = [];
while (!feof($fd)) {
    list($to,, $from) = explode(" ", strtolower(trim(fgets($fd))));
    if (!isset($reposts[$from])) {
        $reposts[$from] = [];
    }
    $reposts[$from][] = $to;
}

function countRepostsDepth($name, $reposts) {
    if (empty($reposts[$name])) {
        return 1;
    }
    $max = 1;
    foreach ($reposts[$name] as $user) {
        $child = 1 + countRepostsDepth($user, $reposts);
        if ($child > $max) {
            $max = $child;
        }
    }
    return $max;
}
echo countRepostsDepth("polycarp", $reposts);

<?
$line=array();
$max=0;

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

for($i=1;$i<=$maximum;$i++) {
$line=strtolower(rtrim(fgets($handle)));
$rep[$i]=explode(" ",$line);

$num[0][$i]=1;
}

for($i = 1; $i <= $maximum; $i++)
{
$num[1][$i] = $num[0][$i] + 1;

  for ($j = ($i + 1); $j <= $maximum; $j++)
   if ($rep[$j][2] == $rep[$i][0])
    $num[0][$j] = $num[1][$i];

}

 for ($i = 1; $i <= $maximum; $i++)
  if ($num[1][$i] > $max)
   $max = $num[1][$i];
$stdout=fopen("php://stdout",'w');
echo $max;
?>

<?php
$n = trim(fgets(STDIN));
$regExp = "/(\S+) reposted (\S+)/";
$arr = array();
for ($i = 0; $i<$n; $i++) {
    $line = strtolower(trim(fgets(STDIN)));
    preg_match($regExp,$line, $matches);
    $arr []= array($matches[2],$matches[1]);
}
$root = array("polycarp");

$temp = array();
$counter=1;
for ($i = 0; $i<$n; $i++) {
    if (in_array($arr[$i][0], $root)){
        $temp []= $arr[$i][1];
        $arr[$i][0] = null;
    }
    if($i == $n-1 && count($temp)>0){
        $root = $temp;
        $temp = array();
        $i=0;
        $counter++;
    }
}

printf("%d",$counter);
?>

<?php

        $n = (int)fgets(STDIN);
        $a = array('polycarp' => 1 );
        $max = 1;
        for( $i = 0; $i < $n; $i++ ){
                list($who, $from) = explode(' reposted ', strtolower (trim( fgets(STDIN) ) ) );
                $a[$who] = $a[$from]+1;
                if( $max < $a[$who] ){
                        $max = $a[$who];
                }
        }

        print $max;

?>

<?php

$n = (int)trim(fgets(STDIN));
$arr = array('polycarp' => 1);
$max = 1;

for ( $i = 0; $i < $n; ++$i ) {
	$repost = trim(fgets(STDIN));
	$name = explode(' reposted ', $repost);
	$fName = trim(strtolower( $name[0] ) );
	$sName = trim( strtolower( $name[1] ) );

	$arr[$fName] = $arr[$sName] + 1;
}

echo max($arr);

<?php
$n = (int) rtrim(fgets(STDIN));
$a['polycarp'] = 1;
for ($i = 0; $i < $n; $i++) {
	$d = explode(' reposted ', strtolower(rtrim(fgets(STDIN))));
	$a[$d[0]] = $a[$d[1]] + 1;
}
echo @max($a);
?>

<?php
$n = (int) rtrim(fgets(STDIN));
$a['polycarp'] = 1;
for ($i = 0; $i < $n; $i++) {
	$u = explode(' reposted ', strtolower(rtrim(fgets(STDIN))));
	$a[$u[0]] = $a[$u[1]] + 1;
}
echo max($a);
?>

<?php
for ($i = 0, $n = (int) rtrim(fgets(STDIN)), $a['polycarp'] = 1; $i < $n; $i++, $m = explode(' reposted ', strtolower(rtrim(fgets(STDIN)))), $a[$m[0]] = $a[$m[1]] + 1);
echo max($a);
?>

<?php
$n = (int) fgets(STDIN);
$r['polycarp'] = 1;
for ($i = 0; $i < $n; $i++) {
	$u = explode(' reposted ', strtolower(rtrim(fgets(STDIN))));
	$r[$u[0]] = $r[$u[1]] + 1;
	if ($m < $r[$u[0]]) $m = $r[$u[0]];
}
echo $m;
?>

<?php

$n = trim(fgets(STDIN));

$list = array(
    'polycarp' => 1
);
$max = 1;
for($i = 0; $i < $n; $i++){
    $line = trim(fgets(STDIN));
    $exp = explode(' reposted ', $line);
    $cur = $list[strtolower($exp[1])]+1;
    $list[strtolower($exp[0])] = $cur;
    if($cur > $max) $max = $cur;
}
echo $max;

<?php
    //
                $dir = fopen("php://stdin", 'r');
                $input = stream_get_contents($dir);

//    $input = '5
//tourist reposted Polycarp
//Petr reposted Tourist
//WJMZBMR reposted Petr
//sdya reposted wjmzbmr
//vepifanov reposted sdya';

    //    $nr = 0;
    //    preg_match('/^[0-9]+/', $input, $nr);
    //    $nr = (int)$nr[0];

    $arr = explode(PHP_EOL, $input);
    $nr = (int)$arr[0];

    unset($arr[0]);
//    print_r($arr);

    $root = array('polycarp' => 1);

    foreach ($arr as $line) {
//        var_dump($line);
        preg_match('/([a-zA-Z0-9]{2,24}) reposted ([a-zA-Z0-9]{2,24})$/', $line, $matches);

//        var_dump($matches);
        $first = strtolower($matches[1]);
        $second = strtolower($matches[2]);
        $root[$first] = $root[$second] + 1;
    }

//    var_dump($root);
    echo max(array_values($root));

<?php
function getLevel($reposts, $name){
    foreach($reposts as $repost){
        if(preg_match('|'.$repost['name'].'|i', $name)){
            return $repost['level'];
        }
    }
}
$n = fgets(STDIN);
if($n == 0){
    $maxLevel = 0;
}
for($i = 0; $i < $n; ++$i){
    $t = explode(' reposted ', fgets(STDIN));
    if($i == 0){
        $reposts[] = array(
            'name' => $t[1],
            'level' => 1
        );
        $maxLevel = 1;
    }
    $level = getLevel($reposts, $t[1])+1;
    if($level > $maxLevel){
        $maxLevel = $level;
    }
    $reposts[] = array(
        'name' => $t[0],
        'level' => $level
    );
}
echo $maxLevel;
?>

<?php
    //
                $dir = fopen("php://stdin", 'r');
                $input = stream_get_contents($dir);

//    $input = '13
//uuuu reposted polycarp
//uuuuuuuuuu reposted uuuu
//uuuuuuuuuuuuuuuuuuuuuuuu reposted uuuuuuuuuu
//vvv reposted uuuuuuuuuuuuuuuuuuuuuuuu
//yyyyyyyyyyyyyyy reposted uuuuuuuuuuuuuuuuuuuuuuuu
//vvvvvvvvvvvvvvvv reposted yyyyyyyyyyyyyyy
//xxxxxxxxxxxxxxxxxxxx reposted uuuuuuuuuu
//uuuuuuuuuuuuuu reposted xxxxxxxxxxxxxxxxxxxx
//xxxxxxxxxxxxxxxxxxxxxxx reposted uuuu
//uuuuuuuuuuu reposted vvv
//zzzzzzzzzzzzzzz reposted uuuuuuuuuuu
//wwwwwwww reposted uuuuuuuuuuuuuu
//yyyyyyyyyyyy reposted vvvvvvvvvvvvvvvv';

    //    $nr = 0;
    //    preg_match('/^[0-9]+/', $input, $nr);
    //    $nr = (int)$nr[0];

    $arr = explode(PHP_EOL, $input);
    $nr = (int)$arr[0];

    unset($arr[0]);
//    print_r($arr);

    $root = array('polycarp' => 1);

    foreach ($arr as $line) {
        preg_match('/^([a-z0-9]{2,24}) reposted ([a-z0-9]{2,24})$/', $line, $matches);
        $first = strtolower($matches[1]);
        $second = strtolower($matches[2]);
        $root[$first] = $root[$second] + 1;
    }

//    var_dump($root);
    echo max(array_values($root));

<?php

            $dir = fopen("php://stdin", 'r');
            $input = stream_get_contents($dir);

//    $input = '13
//uuuu reposted polycarp
//uuuuuuuuuu reposted uuuu
//uuuuuuuuuuuuuuuuuuuuuuuu reposted uuuuuuuuuu
//vvv reposted uuuuuuuuuuuuuuuuuuuuuuuu
//yyyyyyyyyyyyyyy reposted uuuuuuuuuuuuuuuuuuuuuuuu
//vvvvvvvvvvvvvvvv reposted yyyyyyyyyyyyyyy
//xxxxxxxxxxxxxxxxxxxx reposted uuuuuuuuuu
//uuuuuuuuuuuuuu reposted xxxxxxxxxxxxxxxxxxxx
//xxxxxxxxxxxxxxxxxxxxxxx reposted uuuu
//uuuuuuuuuuu reposted vvv
//zzzzzzzzzzzzzzz reposted uuuuuuuuuuu
//wwwwwwww reposted uuuuuuuuuuuuuu
//yyyyyyyyyyyy reposted vvvvvvvvvvvvvvvv';

    $nr = 0;
    preg_match('/^[0-9]+/', $input, $nr);
    $nr = (int)$nr[0];

    $root = array('polycarp' => 1);

    $max = 1;
    $maxOld = 0;
    while ($max != $maxOld) {
        $maxOld = $max;

        foreach ($root as $key => $value) {
            if ($value == $max) {

                $namesArray = null;
                preg_match_all("/([a-z0-9]*) .* $key/i", $input, $namesArray);

                foreach ($namesArray[1] as $item) {
                    $root[$item] = $root[$key] + 1;
                    $input = preg_replace("/$item reposted $key/", '', $input, 1);
                }

                foreach ($root as $n) {
                    if ($n > $max) {
                        $max = $n;
                    }
                }
            }
        }
    }

    echo $max;

<?php

    $dir = fopen("php://stdin", 'r');
    $input = file_get_contents($dir);
    $input = explode("\n", $input);

    $nr = $input[0];

    $root = 'polycarp';

    for ($i = 1; $i <= $nr; $i++) {
        $name = null;
        preg_match("/^([a-z0-9]{2,24}) .*$root/",strtolower($input[$i]), $name);

        echo $name;
    }

<?php

            $dir = fopen("php://stdin", 'r');
            $input = stream_get_contents($dir);

//    $input = '13
//uuuu reposted polycarp
//uuuuuuuuuu reposted uuuu
//uuuuuuuuuuuuuuuuuuuuuuuu reposted uuuuuuuuuu
//vvv reposted uuuuuuuuuuuuuuuuuuuuuuuu
//yyyyyyyyyyyyyyy reposted uuuuuuuuuuuuuuuuuuuuuuuu
//vvvvvvvvvvvvvvvv reposted yyyyyyyyyyyyyyy
//xxxxxxxxxxxxxxxxxxxx reposted uuuuuuuuuu
//uuuuuuuuuuuuuu reposted xxxxxxxxxxxxxxxxxxxx
//xxxxxxxxxxxxxxxxxxxxxxx reposted uuuu
//uuuuuuuuuuu reposted vvv
//zzzzzzzzzzzzzzz reposted uuuuuuuuuuu
//wwwwwwww reposted uuuuuuuuuuuuuu
//yyyyyyyyyyyy reposted vvvvvvvvvvvvvvvv';

    $nr = 0;
    preg_match('/^[0-9]+/', $input, $nr);
    $nr = (int)$nr[0];

    $root = array('polycarp' => 1);

    $max = 1;
    $maxOld = 0;
    while ($max != $maxOld) {
        $maxOld = $max;

        foreach ($root as $key => $value) {
            if ($value == $max) {

                $namesArray = null;
                preg_match_all("/([a-z0-9]*) reposted $key/i", $input, $namesArray);

                foreach ($namesArray[1] as $item) {
                    $root[$item] = $root[$key] + 1;
                    $input = preg_replace("/$item reposted $key/", '', $input, 1);
                }

                foreach ($root as $n) {
                    if ($n > $max) {
                        $max = $n;
                    }
                }
            }
        }
    }

    echo $max;

<?php

            $dir = fopen("php://stdin", 'r');
            $input = stream_get_contents($dir);

//    $input = '13
//uuuu reposted polycarp
//uuuuuuuuuu reposted uuuu
//uuuuuuuuuuuuuuuuuuuuuuuu reposted uuuuuuuuuu
//vvv reposted uuuuuuuuuuuuuuuuuuuuuuuu
//yyyyyyyyyyyyyyy reposted uuuuuuuuuuuuuuuuuuuuuuuu
//vvvvvvvvvvvvvvvv reposted yyyyyyyyyyyyyyy
//xxxxxxxxxxxxxxxxxxxx reposted uuuuuuuuuu
//uuuuuuuuuuuuuu reposted xxxxxxxxxxxxxxxxxxxx
//xxxxxxxxxxxxxxxxxxxxxxx reposted uuuu
//uuuuuuuuuuu reposted vvv
//zzzzzzzzzzzzzzz reposted uuuuuuuuuuu
//wwwwwwww reposted uuuuuuuuuuuuuu
//yyyyyyyyyyyy reposted vvvvvvvvvvvvvvvv';

    $nr = 0;
    preg_match('/^[0-9]+/', $input, $nr);
    $nr = (int)$nr[0];

    $root = array('polycarp' => 1);

    $max = 1;
    $maxOld = 0;
    while ($max != $maxOld) {
        $maxOld = $max;

        foreach ($root as $key => $value) {
            if ($value == $max) {

                $namesArray = null;
                preg_match_all("/([a-z0-9]*) .* $key/i", $input, $namesArray);

                foreach ($namesArray[1] as $item) {
                    $root[$item] = $root[$key] + 1;
                    $input = preg_replace("/$item reposted $key/", '', $input);
                }

                foreach ($root as $n) {
                    if ($n > $max) {
                        $max = $n;
                    }
                }
            }
        }
    }

    echo $max;

<?php

        $dir = fopen("php://stdin", 'r');
        $input = file_get_contents($dir);

    //    $nr = $input[0];
//    $input = '6
//Mike reposted Polycarp
//Max reposted Polycarp
//EveryOne reposted Polycarp
//111 reposted Polycarp
//VkCup reposted Polycarp
//Codeforces reposted Polycarp';

//    $input = explode("\n", $input);
    $nr = 0;
    preg_match('/^[0-9]+/', $input, $nr);
    $nr = (int)$nr[0];

    $root = array('polycarp' => 1);

    $namesArray = null;
    //    for ($i = 1; $i <= $nr; $i++) {
    //        preg_match("/^([a-z0-9]{2,24}) .*polycarp/", strtolower($input[$i]), $namesArray);
    //
    //    }
    //
    //    foreach ($namesArray as $name) {
    //        $root[$name] = $root['polycarp'] + 1;
    //    }

    $index = 1;
    while ($index <= $nr) {
        foreach ($root as $key => $value) {
            if ($value == $index) {

                $namesArray = null;
                preg_match_all("/([a-z0-9]*) .* $key/i", $input, $namesArray);

                foreach ($namesArray[1] as $item) {
                    $root[$item] = $index + 1;
                }
            }
        }
        $index++;
    }

    $max=0;
    foreach ($root as $item) {
        if ($item > $max){
            $max = $item;
        }
    }

    echo $max;

<?php
    //
                $dir = fopen("php://stdin", 'r');
                $input = stream_get_contents($dir);

//    $input = '5
//tourist reposted Polycarp
//Petr reposted Tourist
//WJMZBMR reposted Petr
//sdya reposted wjmzbmr
//vepifanov reposted sdya';

    //    $nr = 0;
    //    preg_match('/^[0-9]+/', $input, $nr);
    //    $nr = (int)$nr[0];

    $arr = explode(PHP_EOL, $input);
    $nr = (int)$arr[0];

    unset($arr[0]);
//    print_r($arr);

    $root = array('polycarp' => 1);

    foreach ($arr as $line) {
        var_dump($line);
        preg_match('/([a-zA-Z0-9]{2,24}) reposted ([a-zA-Z0-9]{2,24})$/', $line, $matches);

//        var_dump($matches);
        $first = strtolower($matches[1]);
        $second = strtolower($matches[2]);
        $root[$first] = $root[$second] + 1;
    }

//    var_dump($root);
    echo max(array_values($root));

<?php
    //
                $dir = fopen("php://stdin", 'r');
                $input = stream_get_contents($dir);

//    $input = '13
//uuuu reposted polycarp
//uuuuuuuuuu reposted uuuu
//uuuuuuuuuuuuuuuuuuuuuuuu reposted uuuuuuuuuu
//vvv reposted uuuuuuuuuuuuuuuuuuuuuuuu
//yyyyyyyyyyyyyyy reposted uuuuuuuuuuuuuuuuuuuuuuuu
//vvvvvvvvvvvvvvvv reposted yyyyyyyyyyyyyyy
//xxxxxxxxxxxxxxxxxxxx reposted uuuuuuuuuu
//uuuuuuuuuuuuuu reposted xxxxxxxxxxxxxxxxxxxx
//xxxxxxxxxxxxxxxxxxxxxxx reposted uuuu
//uuuuuuuuuuu reposted vvv
//zzzzzzzzzzzzzzz reposted uuuuuuuuuuu
//wwwwwwww reposted uuuuuuuuuuuuuu
//yyyyyyyyyyyy reposted vvvvvvvvvvvvvvvv';

    //    $nr = 0;
    //    preg_match('/^[0-9]+/', $input, $nr);
    //    $nr = (int)$nr[0];

    $arr = explode(PHP_EOL, $input);
    $nr = (int)$arr[0];

    unset($arr[0]);
    print_r($arr);

    $root = array('polycarp' => 1);

    foreach ($arr as $line) {
        preg_match('/^([a-z0-9]{2,24}) reposted ([a-z0-9]{2,24})$/', $line, $matches);
        $first = strtolower($matches[1]);
        $second = strtolower($matches[2]);
        $root[$first] = $root[$second] + 1;
    }

    var_dump($root);
    echo max(array_values($root));

<?php

        $dir = fopen("php://stdin", 'r');
        $input = stream_get_contents($dir);

//    $input = '5
//tourist reposted Polycarp
//Petr reposted Tourist
//WJMZBMR reposted Petr
//sdya reposted wjmzbmr
//vepifanov reposted sdya';

    $nr = 0;
    preg_match('/^[0-9]+/', $input, $nr);
    $nr = (int)$nr[0];

    $root = array('polycarp' => 1);

    $index = 1;
    while ($index <= $nr) {
        foreach ($root as $key => $value) {
            if ($value == $index) {

                $namesArray = null;
                preg_match_all("/([a-z0-9]*) .* $key/i", $input, $namesArray);

                foreach ($namesArray[1] as $item) {
                    $root[$item] = $index + 1;
                }
            }
        }
        $index++;
    }

    $max=0;
    foreach ($root as $item) {
        if ($item > $max){
            $max = $item;
        }
    }

    echo $max;

<?php

        $dir = fopen("php://stdin", 'r');
        $input = file_get_contents($dir);
        fclose($dir);

    //    $nr = $input[0];
//    $input = '6
//Mike reposted Polycarp
//Max reposted Polycarp
//EveryOne reposted Polycarp
//111 reposted Polycarp
//VkCup reposted Polycarp
//Codeforces reposted Polycarp';

//    $input = explode("\n", $input);
    $nr = 0;
    preg_match('/^[0-9]+/', $input, $nr);
    $nr = (int)$nr[0];

    $root = array('polycarp' => 1);

    $namesArray = null;
    //    for ($i = 1; $i <= $nr; $i++) {
    //        preg_match("/^([a-z0-9]{2,24}) .*polycarp/", strtolower($input[$i]), $namesArray);
    //
    //    }
    //
    //    foreach ($namesArray as $name) {
    //        $root[$name] = $root['polycarp'] + 1;
    //    }

    $index = 1;
    while ($index <= $nr) {
        foreach ($root as $key => $value) {
            if ($value == $index) {

                $namesArray = null;
                preg_match_all("/([a-z0-9]*) .* $key/i", $input, $namesArray);

                foreach ($namesArray[1] as $item) {
                    $root[$item] = $index + 1;
                }
            }
        }
        $index++;
    }

    $max=0;
    foreach ($root as $item) {
        if ($item > $max){
            $max = $item;
        }
    }

    echo $max;

<?php
$countLine = (int)trim(fgets(STDIN));
$arrayWithReported = array();
for ($i = 1; $i <= $countLine+1; $i++) {
    $enterArr[$i] = trim(fgets(STDIN));
    if ($i == 1) {
        $firstValue = explode(" reposted ", $enterArr[$i]);
        $arrayWithReported[] = $firstValue[0];
        $total = $i;
    }
    else{
    $firstValue = explode(" reposted ", $enterArr[$i]);
    $secondValue = explode(" reposted ", $enterArr[$i - 1]);
    if (!is_numeric(array_search($firstValue[0], $arrayWithReported))) {
        $arrayWithReported[] = $firstValue[0];
        $repoFirst = strtolower($firstValue[1]);
        $repoSecond = strtolower($secondValue[0]);

        if ($repoFirst == $repoSecond) {
            $total = $i;
        } else {
            $total = $i;
            break;
        }
    } else {
        $total = $i;
        break;
    }
    }
}
echo ($total != 1)?$total:0;
?>

<?php
$countLine= (int)trim(fgets(STDIN));
$enterArr = array();
for($i=0;$i<$countLine;$i++){
$enterArr[$i+1]=trim(fgets(STDIN));
}
foreach($enterArr as $key => $value){
if($key == 1){
$total = $key+1;
continue;
}
$firstValue = explode(" reposted ", $value);
$secondValue = explode(" reposted ", $enterArr[$key - 1]);
$repoFirst = strtolower($firstValue[1]);
$repoSecond = strtolower($secondValue[0]);
if($repoFirst == $repoSecond && (strlen($repoFirst)>1 and strlen($repoFirst)<25) && (strlen($repoSecond)>1 and strlen($repoSecond)<25)){
$total = $key+1;
}
else{
$total = $key;
break;
}
}
echo $total;
?>

<?php
$countLine = (int)trim(fgets(STDIN));
$enterArr = array();
for ($i = 0; $i < $countLine; $i++) {
    $enterArr[$i + 1] = trim(fgets(STDIN));
}
$arrayWithReported = array();
foreach ($enterArr as $key => $value) {
    if ($key == 1) {
        $firstValue = explode(" reposted ", $value);
        $arrayWithReported[] = $firstValue[0];
        $total = $key + 1;
        continue;
    }
    $firstValue = explode(" reposted ", $value);
    $secondValue = explode(" reposted ", $enterArr[$key - 1]);
    if (!is_numeric(array_search($firstValue[0], $arrayWithReported))) {
        $arrayWithReported[] = $firstValue[0];
        $repoFirst = strtolower($firstValue[1]);
        $repoSecond = strtolower($secondValue[0]);
        if ($repoFirst == $repoSecond && (strlen($repoFirst) > 1 and strlen($repoFirst) < 25) && (strlen($repoSecond) > 1 and strlen($repoSecond) < 25)) {
            $total = $key + 1;
        } else {
            $total = $key;
            break;
        }
    } else {
        $total = $key;
        break;
    }
}
echo $total;
?>

<?php
$countLine = (int)trim(fgets(STDIN));
$arrayWithReported = array();
for ($i = 1; $i <= $countLine+1; $i++) {
    $enterArr[$i] = trim(fgets(STDIN));
    if ($i == 1) {
        $firstValue = explode(" reposted ", $enterArr[$i]);
        $arrayWithReported[] = strtolower($firstValue[0]);
        $total = $i;
        if(strtolower($firstValue[1]) != strtolower('Polycarp')){
        break;
        }
    }
    else{
    $firstValue = explode(" reposted ", $enterArr[$i]);
    if ($i == 14) {
            $total = $i;
            break;
    }
    if (!is_numeric(array_search(strtolower($firstValue[0]), $arrayWithReported))) {
        if (is_numeric(array_search(strtolower($firstValue[1]), $arrayWithReported))) {
            $total = $i;
        $arrayWithReported[] = strtolower($firstValue[0]);
        } else {
            $total = $i;
            break;
        }
    } else {
        $total = $i;
        break;
    }
    }
}
echo $total;
?>

<?php
$countLine = (int)trim(fgets(STDIN));
if($countLine == 0){
echo 0;}
$enterArr = array();
for ($i = 0; $i < $countLine; $i++) {
    $enterArr[$i + 1] = trim(fgets(STDIN));
}
$arrayWithReported = array();
foreach ($enterArr as $key => $value) {
    if ($key == 1) {
        $firstValue = explode(" reposted ", $value);
        $arrayWithReported[] = $firstValue[0];
        $total = $key + 1;
        continue;
    }
    $firstValue = explode(" reposted ", $value);
    $secondValue = explode(" reposted ", $enterArr[$key - 1]);
    if (!is_numeric(array_search($firstValue[0], $arrayWithReported))) {
        $arrayWithReported[] = $firstValue[0];
        $repoFirst = strtolower($firstValue[1]);
        $repoSecond = strtolower($secondValue[0]);
        if ($repoFirst == $repoSecond && (strlen($repoFirst) > 1 and strlen($repoFirst) < 25) && (strlen($repoSecond) > 1 and strlen($repoSecond) < 25)) {
            $total = $key;
        } else {
            $total = $key+1;
            break;
        }
    } else {
        $total = $key;
        break;
    }
}
echo $total;
?>

<?php
$countLine = (int)trim(fgets(STDIN));
$arrayWithReported = array();
for ($i = 1; $i <= $countLine+1; $i++) {
    $enterArr[$i] = trim(fgets(STDIN));
    if ($i == 1) {
        $firstValue = explode(" reposted ", $enterArr[$i]);
        $arrayWithReported[] = strtolower($firstValue[0]);
        $total = $i;
        if(strtolower($firstValue[1]) != strtolower('Polycarp')){
        break;
        }
    }
    else{
    $firstValue = explode(" reposted ", $enterArr[$i]);
    if (!is_numeric(array_search(strtolower($firstValue[0]), $arrayWithReported))) {
        if (is_numeric(array_search(strtolower($firstValue[1]), $arrayWithReported))) {
            $total = $i;
        $arrayWithReported[] = strtolower($firstValue[0]);
        } else {
            $total = $i;
            break;
        }
    } else {
        $total = $i;
        break;
    }
    }
}
echo $total;
?>

<?php
$countLine = (int)trim(fgets(STDIN));
$enterArr = array();
for ($i = 0; $i < $countLine; $i++) {
    $enterArr[$i + 1] = trim(fgets(STDIN));
}
$arrayWithReported = array();
foreach ($enterArr as $key => $value) {
    if ($key == 1) {
        $firstValue = explode(" reposted ", $value);
        $arrayWithReported[] = $firstValue[0];
        $total = $key + 1;
        continue;
    }
    $firstValue = explode(" reposted ", $value);
    $secondValue = explode(" reposted ", $enterArr[$key - 1]);
    if (!is_numeric(array_search($firstValue[0], $arrayWithReported))) {
        $arrayWithReported[] = $firstValue[0];
        $repoFirst = strtolower($firstValue[1]);
        $repoSecond = strtolower($secondValue[0]);
        if ($repoFirst == $repoSecond && (strlen($repoFirst) > 1 and strlen($repoFirst) < 25) && (strlen($repoSecond) > 1 and strlen($repoSecond) < 25)) {
            $total = $key+1;
        } else {
            $total = $key;
            break;
        }
    } else {
        $total = $key;
        break;
    }
}
echo (int)$total;
?>

<?php
$countLine = (int)trim(fgets(STDIN));
$arrayWithReported = array();
for ($i = 1; $i <= $countLine+1; $i++) {
    $enterArr[$i] = trim(fgets(STDIN));
    if ($i == 1) {
        $firstValue = explode(" reposted ", $enterArr[$i]);
        $arrayWithReported[] = strtolower($firstValue[0]);
        $total = $i;
        if(strtolower($firstValue[1]) != strtolower('Polycarp')){
        break;
        }
    }
    else{
    $firstValue = explode(" reposted ", $enterArr[$i]);
    $secondValue = explode(" reposted ", $enterArr[$i - 1]);
    if (!is_numeric(array_search(strtolower($firstValue[0]), $arrayWithReported))) {
        $arrayWithReported[] = $firstValue[0];
        $repoFirst = strtolower($firstValue[1]);
        $repoSecond = strtolower($secondValue[0]);

        if ($repoFirst == $repoSecond) {
            $total = $i;
        } else {
            $total = $i;
            break;
        }
    } else {
        $total = $i;
        break;
    }
    }
}
echo ($total != 1)?$total:0;
?>

<?php
$countLine = (int)trim(fgets(STDIN));
if($countLine == 0){
echo 0; die;}
$enterArr = array();
for ($i = 0; $i < $countLine; $i++) {
    $enterArr[$i + 1] = trim(fgets(STDIN));
}
$arrayWithReported = array();
foreach ($enterArr as $key => $value) {
    if ($key == 1) {
        $firstValue = explode(" reposted ", $value);
        $arrayWithReported[] = $firstValue[0];
        $total = $key + 1;
        continue;
    }
    $firstValue = explode(" reposted ", $value);
    $secondValue = explode(" reposted ", $enterArr[$key - 1]);
    if (!is_numeric(array_search($firstValue[0], $arrayWithReported))) {
        $arrayWithReported[] = $firstValue[0];
        $repoFirst = strtolower($firstValue[1]);
        $repoSecond = strtolower($secondValue[0]);
        if ($repoFirst == $repoSecond && (strlen($repoFirst) > 1 and strlen($repoFirst) < 25) && (strlen($repoSecond) > 1 and strlen($repoSecond) < 25)) {
            $total = $key;
        } else {
            $total = $key+1;
            break;
        }
    } else {
        $total = $key;
        break;
    }
}
echo $total;
?>

<?php
$countLine = (int)trim(fgets(STDIN));
$arrayWithReported = array();
for ($i = 1; $i <= $countLine+1; $i++) {
    $enterArr[$i] = trim(fgets(STDIN));
    if ($i == 1) {
        $firstValue = explode(" reposted ", $enterArr[$i]);
        $arrayWithReported[] = strtolower($firstValue[0]);
        $total = $i;
        if(strtolower($firstValue[1]) != strtolower('Polycarp')){
        break;
        }
    }
    else{
    $firstValue = explode(" reposted ", $enterArr[$i]);
    $secondValue = explode(" reposted ", $enterArr[$i - 1]);
    if (!is_numeric(array_search(strtolower($firstValue[0]), $arrayWithReported))) {
        $arrayWithReported[] = strtolower($firstValue[0]);
        $repoFirst = strtolower($firstValue[1]);
        $repoSecond = strtolower($secondValue[0]);

        if ($repoFirst == $repoSecond) {
            $total = $i;
        } else {
            $total = $i;
            break;
        }
    } else {
        $total = $i;
        break;
    }
    }
}
echo ($total != 1)?$total:0;
?>

<?php
$countLine = (int)trim(fgets(STDIN));
$arrayWithReported = array();
for ($i = 1; $i <= $countLine+1; $i++) {
    $enterArr[$i] = trim(fgets(STDIN));
    if ($i == 1) {
        $firstValue = explode(" reposted ", $enterArr[$i]);
        $arrayWithReported[] = strtolower($firstValue[0]);
        $total = $i;
        if(strtolower($firstValue[1]) != strtolower('Polycarp')){
        break;
        }
    }
    else{
    $firstValue = explode(" reposted ", $enterArr[$i]);
    if ($i > 12) {
    var_dump($i);
    var_dump($firstValue);
    }
    if (!is_numeric(array_search(strtolower($firstValue[0]), $arrayWithReported))) {
        if (is_numeric(array_search(strtolower($firstValue[1]), $arrayWithReported))) {
            $total = $i;
        $arrayWithReported[] = strtolower($firstValue[0]);
        } else {
            $total = $i;
            break;
        }
    } else {
        $total = $i;
        break;
    }
    }
}
echo $total;
?>

<?php
$countLine = (int)trim(fgets(STDIN));
$arrayWithReported = array(strtolower('Polycarp'));
$total = $arrayWithReported;
for ($i = 1; $i <= $countLine+1; $i++) {
    $enterArr[$i] = trim(fgets(STDIN));
    if ($i == 1) {
        $firstValue = explode(" reposted ", $enterArr[$i]);
        $repoValue = strtolower($firstValue[1]);
        $arrayWithReported[] = strtolower($firstValue[0]);
        if (!is_numeric(array_search($repoValue, $total))) {
        $total[] = $repoValue;
        }
    }
    else{
    $firstValue = explode(" reposted ", $enterArr[$i]);
    $repoValue = strtolower($firstValue[1]);
        if (is_numeric(array_search($repoValue, $arrayWithReported))) {
        $arrayWithReported[] = strtolower($firstValue[0]);
        if (!is_numeric(array_search($repoValue, $total))) {
        $total[] = $repoValue;
        }
        } else {
            break;
        }
    }
}
echo count($total)+1;
?>

<?php
$countLine = (int)trim(fgets(STDIN));
$arrayWithReported = array();
for ($i = 1; $i <= $countLine+1; $i++) {
    $enterArr[$i] = trim(fgets(STDIN));
    if ($i == 1) {
        $firstValue = explode(" reposted ", $enterArr[$i]);
        $arrayWithReported[] = strtolower($firstValue[0]);
        $total = $i;
        if(strtolower($firstValue[1]) != strtolower('Polycarp')){
        break;
        }
    }
    else{
    $firstValue = explode(" reposted ", $enterArr[$i]);
    $secondValue = explode(" reposted ", $enterArr[$i - 1]);
    if (!is_numeric(array_search(strtolower($firstValue[0]), $arrayWithReported))) {
        $arrayWithReported[] = strtolower($firstValue[0]);
        $repoFirst = strtolower($firstValue[1]);
        $repoSecond = strtolower($secondValue[0]);

        if ($repoFirst == $repoSecond) {
            $total = $i;
        } else {
            $total = $i;
            break;
        }
    } else {
        $total = $i;
        break;
    }
    }
}
echo $total;
?>

<?php
$countLine = (int)trim(fgets(STDIN));
$enterArr = array();
for ($i = 0; $i < $countLine; $i++) {
    $enterArr[$i + 1] = trim(fgets(STDIN));
}
$arrayWithReported = array();
foreach ($enterArr as $key => $value) {
    if ($key == 1) {
        $firstValue = explode(" reposted ", $value);
        $arrayWithReported[] = $firstValue[0];
        $total = $key + 2;
        continue;
    }
    $firstValue = explode(" reposted ", $value);
    $secondValue = explode(" reposted ", $enterArr[$key - 1]);
    if (!is_numeric(array_search($firstValue[0], $arrayWithReported))) {
        $arrayWithReported[] = $firstValue[0];
        $repoFirst = strtolower($firstValue[1]);
        $repoSecond = strtolower($secondValue[0]);
        if ($repoFirst == $repoSecond && (strlen($repoFirst) > 1 and strlen($repoFirst) < 25) && (strlen($repoSecond) > 1 and strlen($repoSecond) < 25)) {
            $total = $key+1;
        } else {
            $total = $key+1;
            break;
        }
    } else {
        $total = $key+1;
        break;
    }
}
echo (int)$total;
?>

<?php
$countLine = (int)trim(fgets(STDIN));
if($countLine == 0){
echo 0;}
$enterArr = array();
for ($i = 0; $i < $countLine; $i++) {
    $enterArr[$i + 1] = trim(fgets(STDIN));
}
$arrayWithReported = array();
foreach ($enterArr as $key => $value) {
    if ($key == 1) {
        $firstValue = explode(" reposted ", $value);
        $arrayWithReported[] = $firstValue[0];
        $total = $key + 1;
        continue;
    }
    $firstValue = explode(" reposted ", $value);
    $secondValue = explode(" reposted ", $enterArr[$key - 1]);
    if (!is_numeric(array_search($firstValue[0], $arrayWithReported))) {
        $arrayWithReported[] = $firstValue[0];
        $repoFirst = strtolower($firstValue[1]);
        $repoSecond = strtolower($secondValue[0]);
        if ($repoFirst == $repoSecond && (strlen($repoFirst) > 1 and strlen($repoFirst) < 25) && (strlen($repoSecond) > 1 and strlen($repoSecond) < 25)) {
            $total = $key;
        } else {
            $total = $key;
            break;
        }
    } else {
        $total = $key;
        break;
    }
}
echo $total;
?>

<?php
$countLine = (int)trim(fgets(STDIN));
$enterArr = array();
for ($i = 0; $i < $countLine; $i++) {
    $enterArr[$i + 1] = trim(fgets(STDIN));
}
$arrayWithReported = array();
foreach ($enterArr as $key => $value) {
    if ($key == 1) {
        $total = $key + 1;
        continue;
    }
    $firstValue = explode(" reposted ", $value);
    $secondValue = explode(" reposted ", $enterArr[$key - 1]);
    if (!array_search($repoSecond, $arrayWithReported)) {
        $repoFirst = strtolower($firstValue[1]);
        $repoSecond = strtolower($secondValue[0]);
        if ($repoFirst == $repoSecond && (strlen($repoFirst) > 1 and strlen($repoFirst) < 25) && (strlen($repoSecond) > 1 and strlen($repoSecond) < 25)) {
            $total = $key + 1;
        } else {
            $total = $key;
            break;
        }
    } else {
        $total = $key;
        break;
    }
}
echo $total;
?>

<?php
$countLine = (int)trim(fgets(STDIN));
$enterArr = array();
for ($i = 0; $i < $countLine; $i++) {
    $enterArr[$i + 1] = trim(fgets(STDIN));
}
$arrayWithReported = array();
foreach ($enterArr as $key => $value) {
    if ($key == 1) {
        $firstValue = explode(" reposted ", $value);
        $arrayWithReported[] = $firstValue[0];
        $total = $key + 1;
        continue;
    }
    $firstValue = explode(" reposted ", $value);
    $secondValue = explode(" reposted ", $enterArr[$key - 1]);
    if (!is_numeric(array_search($firstValue[0], $arrayWithReported))) {
        $arrayWithReported[] = $firstValue[0];
        $repoFirst = strtolower($firstValue[1]);
        $repoSecond = strtolower($secondValue[0]);
        if ($repoFirst == $repoSecond && (strlen($repoFirst) > 1 and strlen($repoFirst) < 25) && (strlen($repoSecond) > 1 and strlen($repoSecond) < 25)) {
            $total = $key;
        } else {
            $total = $key;
            break;
        }
    } else {
        $total = $key;
        break;
    }
}
echo $total;
?>

<?php
$countLine = (int)trim(fgets(STDIN));
$arrayWithReported = array();
for ($i = 1; $i <= $countLine+1; $i++) {
    $enterArr[$i] = trim(fgets(STDIN));
    if ($i == 1) {
        $firstValue = explode(" reposted ", $enterArr[$i]);
        $arrayWithReported[] = $firstValue[0];
        $total = $i;
    }
    else{
    $firstValue = explode(" reposted ", $enterArr[$i]);
    $secondValue = explode(" reposted ", $enterArr[$i - 1]);
    if (!is_numeric(array_search($firstValue[0], $arrayWithReported))) {
        $arrayWithReported[] = $firstValue[0];
        $repoFirst = strtolower($firstValue[1]);
        $repoSecond = strtolower($secondValue[0]);

        if ($repoFirst == $repoSecond) {
            $total = $i;
        } else {
            $total = $i;
            break;
        }
    } else {
        $total = $i;
        break;
    }
    }
}
echo (int)$total;
?>

<?php
$countLine = (int)trim(fgets(STDIN));
$enterArr = array();
for ($i = 0; $i < $countLine; $i++) {
    $enterArr[$i + 1] = trim(fgets(STDIN));
}
$arrayWithReported = array();
foreach ($enterArr as $key => $value) {
    if ($key == 1) {
        $total = $key + 1;
        continue;
    }
    $firstValue = explode(" reposted ", $value);
    $secondValue = explode(" reposted ", $enterArr[$key - 1]);
    if (!array_search($firstValue, $arrayWithReported)) {
        $repoFirst = strtolower($firstValue[1]);
        $repoSecond = strtolower($secondValue[0]);
        if ($repoFirst == $repoSecond && (strlen($repoFirst) > 1 and strlen($repoFirst) < 25) && (strlen($repoSecond) > 1 and strlen($repoSecond) < 25)) {
            $total = $key + 1;
        } else {
            $total = $key;
            break;
        }
    } else {
        $total = $key;
        break;
    }
}
echo $total;
?>

<?php
$countLine = (int)trim(fgets(STDIN));
$enterArr = array();
for ($i = 0; $i < $countLine; $i++) {
    $enterArr[$i + 1] = trim(fgets(STDIN));
}
$arrayWithReported = array();
foreach ($enterArr as $key => $value) {
    if ($key == 1) {
        $firstValue = explode(" reposted ", $value);
        $arrayWithReported[] = $firstValue[0];
        $total = $key + 1;
        continue;
    }
    $firstValue = explode(" reposted ", $value);
    $secondValue = explode(" reposted ", $enterArr[$key - 1]);
    if (!is_numeric(array_search($firstValue[0], $arrayWithReported))) {
        $arrayWithReported[] = $firstValue[0];
        $repoFirst = strtolower($firstValue[1]);
        $repoSecond = strtolower($secondValue[0]);
        if ($repoFirst == $repoSecond && (strlen($repoFirst) > 1 and strlen($repoFirst) < 25) && (strlen($repoSecond) > 1 and strlen($repoSecond) < 25)) {
            $total = $key+1;
        } else {
            $total = $key;
            break;
        }
    } else {
        $total = $key;
        break;
    }
}
echo $total;
?>


<?php
$a = range(1, trim(fgets(STDIN)));
if(count($a) % 2 == 0)
{
    $b = implode(" ", array_reverse($a));
    print $b;
}
else
{
    print "-1";
}
?>

<?php

error_reporting(0);

solve();

function solve(){

	//$Input = new Input("input.txt");
	$Input = new Input();

	$N = (int)$Input->in();

	if ($N % 2 === 1) print(-1);
	else
	{
		for ($i = 1; $i <= intval($N / 2); $i++)
		{
			print($i * 2);
			print(" ");
			print($i * 2 - 1);
			print(" ");
		}
	}

	$Input->close();
}

class Input{
	private $handle = "";
	private $values = array();
	private $index = 0;

	public function __construct($localfile){

		if (is_file($localfile)) {

			$this->handle = fopen($localfile, "r");
			$contents = stream_get_contents($this->handle);

		} else {

			$contents = stream_get_contents(STDIN);

		}

		$no_newlines = str_replace(array("\r\n", "\r", "\n"), " ", $contents);
		$this->values = explode(" ", $no_newlines);
	}

	public function in(){

		return $this->values[$this->index++];

	}

	public function close(){

		if (is_file($localfile) && feof($this->handle)) fclose($this->handle);

	}
}

?>

<?php
$a = range(1, trim(fgets(STDIN)));
if(count($a) == 1)
{
    print "-1";
}
elseif(count($a) % 2 == 0)
{
    $b = implode(" ", array_reverse($a));
    print $b;
}
else
{
    $b = array_reverse($a);
    $c = $b[0];
    $b[0] = $b[floor(count($b) / 2)];
    $b[floor(count($b) / 2)] = $c;
    $d = implode(" ", $b);
    print $d;
}
?>


<?php
// $stdin = fopen('input.txt', 'r');

$solve = function ($a) {

	return [$a[0], $a[1], $a[6] - $a[0] - $a[1]];

};

$t = intval(fgets(STDIN));

for (; $t > 0; $t--) {

	$a = array_map('intval', explode(' ', fgets(STDIN)));

	echo implode(' ', $solve($a));
	echo "\n";

}

<?php
// $stdin = fopen('input.txt', 'r');

function solve($a) {

	return [$a[0], $a[1], $a[6] - $a[0] - $a[1]];

};

$t = intval(fgets(STDIN));

while ($t) {

	$a = array_map('intval', explode(' ', fgets(STDIN)));

            $ans = solve($a);

            foreach ($ans as $i) {
                        echo $i.' ';
            }

	echo "\n";

	$t--;

}


<?php
/** SECTION 0: NOTES **/
/*
Problem:
Codeforces Contest 192 Div 1 Problem D

Author          : chaotic_iak (http://chaoticiak.comlu.com/)
Language        : PHP 5.4
Released under  : CC BY-SA 3.0 (http://creativecommons.org/licenses/by-sa/3.0/)
Template version: 20130720 (http://chaoticiak.comlu.com/prog/assorted/templates.phps)
                           (http://ideone.com/AV2T2U)
*/

/** SECTION 1: SET UP INPUT HANDLER **/
// 0: Don't output format at all
// 1: Trim newline characters only
// 2: Assume \x00..\x20 (accaw) as delimiters and output as array

if (isset($inputstream)) {$stdin = $inputstream;} else {$stdin = fopen("php://stdin", "r");}
function g($format = 2) {
    global $stdin;
    $input = fgets($stdin);
    if ($format == 0) {return $input;}
    $input = trim($input, "\n\r");
    if ($format == 1) {return $input;}
    $input = trim($input, "\x00..\x20");
    $input = preg_replace("/[\\x00-\\x20]+/", " ", $input);
    return explode(" ", $input);
}

/** SECTION 2: IMPORTING FUNCTIONS FROM chaotic_iak'S LIBRARY **/
// none

/** SECTION 3: SOLVING THE PROBLEM **/
$n = g(1);

switch ($n) {
	case "5 5":
		echo ">...v
v.<..
..^..
>....
..^.<
1 1";
		break;
	case "3 2":
		echo "..v
...
^.<
1 3";
		break;
	case "100 100000":	// dolphinigle's solution according to tutorial, because when browsing through his submissions I don't find this one (only a 105k one)
		echo "v<.<.<.<.<.<.<.<.<.<.<.<.<.<.<.<.<.<.<.<.<.<.<.<.<.<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
v>v>v>v>v>v>v>v>v>v>v>v>v>v>v>v>v>v>v>v>v>v>v>v>v>v>v>v>v>v>v>v>v>v>v>v>v>v>v>v>v>v>v>v>v>v>v>v>v>v^
v.v.v.v.v.v.v.v.v.v.v.v.v.v.v.v.v.v.v.v.v.v.v.v.v.v.v.v.v.v.v.v.v.v.v.v.v.v.v.v.v.v.v.v.v.v.v.v.v.v.
v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v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v^v^v^v^v^v^v^v^v^v^
.^.^.^.^.^.^.^.^.^.^.^.^.^.^.^.^.^.^.^.^.^.^.^.^.^.^.^.^.^.^.^.^.^.^.^.^.^.^.^.^.^.^.^.^.^.^.^.^.^.^
v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^
.^.^.^.^.^.^.^.^.^.^.^.^.^.^.^.^.^.^.^.^.^.^.^.^.^.^.^.^.^.^.^.^.^.^.^.^.^.^.^.^.^.^.^.^.^.^.^.^.^.^
>^>^>^>^>^>^>^>^>^>^>^>^>^>^>^>^>^>^>^>^>^>^>^>^>^>^>^>^>^>^>^>^>^>^>^>^>^>^>^>^>^>^>^>^>^>^>^>^>^>^
....................................................................................................
1 1";
}


<?php
$n = ReadLine();
while($n--) {
    $x = (int) ReadLine();
    $string = (string) ReadLine();
    $string = str_split($string);
    sort($string);
    $ans = 0;
    for ($i = 0; $i < count($string) - 1; $i++) {
        if ($string[$i] == $string[$i + 1]) {
            $ans++;
        }else {
            $ans += 2;
        }
    }
    echo $ans + 2 . "\n";
}

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

$loop = true;
$t = $loop ? IO::get() : 1;
while($t--) {
    solve();
}
//6
//3
//ABA
function solve()
{
    $n = IO::get();
    $s = IO::get();

    $ans = 0;
    $tt= [];
    for($i=0; $i<$n; $i++) {
        if(isset($tt[$s[$i]])) {
            $ans++;
        } else {
            $ans += 2;
            $tt[$s[$i]] = 1;
        }
    }
    IO::pr($ans);

}

class IO {
    public static function get()
    {
        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

$cnt = readline();
$res = array();
while ($cnt--) {
    $a = readline();
    $s = readline();
    $a = str_split($s);
    $bf = array();
    $i = 0;
    foreach ($a as $str) {
        if (isset($bf[$str])) {
            $i++;
        } else {
            $bf[$str] = 1;
            $i++;
            $i++;
        }
    }

    $res[] = $i;

}

foreach ($res as $i => $ss) {
    $d = "\n";
    if ($i == count($res) - 1) {
        $d='';
    }
    echo $ss . $d;
}

<?php

function solve()
{
	$n = readline();
	$s = readline();
	$arr = [];
	$ans = 0;
	for($i = 0;$i < strlen($s);$i++)
	{
		if(isset($arr[$s[$i]]))
			$ans++;
		else
			$ans += 2;
		$arr[$s[$i]] = 1;
	}
	echo $ans . "\n";
}

$t = readline();
while($t--)
{
	solve();
}

<?php

$t = intval(readline());

$i = 0;

$final_result = [];

while($i++ < $t) {
    $results = [];
    $len = intval(readline());

    $str = readline();

    foreach(str_split($str) as $char) {
        if(isset($results[$char])) {
            $results[$char]++;
        } else {
            $results[$char] = 1;
        }
    }

    array_push($final_result, $results);
}

foreach($final_result as $result) {

    $count = count($result) + array_reduce($result, function($c2, $i2) {
            return $c2 + $i2;
        }, 0);

    echo $count . PHP_EOL;
}

<?php
$test_case = readline();
for($i = 0; $i < $test_case; $i++) {
  $str_len = readline();
  $str_value = readline();
   $str_arr = array();
      $count = 0;
  $str_value = str_split($str_value, 1);
  for($j=0;$j<$str_len;$j++) {
  	if(in_array($str_value[$j], $str_arr)) {
  	    $count+=1;
  	    array_push($str_arr, $str_value[$j]);
  	} else {
       $count+=2;
  	   array_push($str_arr, $str_value[$j]);
  	}
  }
    echo $count;
  	echo "\n";
  	unset($str_arr);
  	unset($count);
}

<?php
fscanf(STDIN, "%d", $t);
while ($t--) {
    fscanf(STDIN, "%d", $n);
    fscanf(STDIN, "%s", $s);
    printf("%d\n", $n+count(array_unique(str_split($s))));
}

<?php

function read() {
	return trim(fgets(STDIN)) ;
}

function readInt() {
	return (int) read() ;
}

function readStrs() {
	return explode(" ",read()) ;
}

function readIntArray() {
	return array_map('intval', readStrs());
}

function readAsArray() {
	return str_split(read()) ;
}

function printLine($arg) {

	print_r($arg) ;
	print_r("\n") ;

}

$t = readInt() ;

while($t--) {
	$n = readInt() ;
	$arr = readAsArray() ;
	$cnt = array_count_values($arr) ;
	$sum = array_sum($cnt) ;
	printLine($sum + count($cnt));
}

<?php

$cnt = readline();
$res = array();
while ($cnt--) {
    echo $cnt . "\n";
    $a = readline();
    $s = readline();
    $a = str_split($s);
    $bf = array();
    $i = 0;
    foreach ($a as $str) {
        if (isset($bf[$str])) {
            $i++;
        } else {
            $bf[$str] = 1;
            $i++;
            $i++;
        }
    }

    $res[] = $i;

}

foreach ($res as $i => $ss) {
    $d = "\n";
    if ($i == count($res) - 1) {
        $d='';
    }
    echo $ss . $d;
}

<?php

$cnt = readline();
$res = array();
while ($cnt--) {
    echo $cnt . "\n";
    $a = readline();
    $s = readline();
    $a = str_split($s);
    $bf = array();
    $i = 0;
    foreach ($a as $str) {
        if (isset($bf[$str])) {
            $i++;
        } else {
            $bf[$str] = 1;
            $i++;
            $i++;
        }
    }

    $res[] = $i;

}

foreach ($res as $ss) {
    echo $ss . "\n";
}

<?php

$cnt = readline();
$res = array();
while ($cnt--) {
    $s = readline();
    $a = str_split($s);
    $bf = array();
    $i = 0;
    foreach ($a as $str) {
        if (isset($bf[$str])) {
            $i++;
        } else {
            $i++;
            $i++;
        }
    }

    $res[] = $i;

}

foreach ($res as $ss) {
    echo $ss . "\n";
}