import java . util . * ; import java . io . * ;   public class Main { public static void main ( String [ ] args ) throws IOException { FastScanner in = new FastScanner ( System . in ) ; PrintWriter out = new PrintWriter ( System . out ) ; new Main ( ) . run ( in , out ) ; out . close ( ) ; }   public static long mod = 17352642619633L ;   void run ( FastScanner in , PrintWriter out ) {   long [ ] K = new long [ 3 ] ; long [ ] T = new long [ 3 ] ; K [ 0 ] = in . nextLong ( ) ; K [ 1 ] = in . nextLong ( ) ; K [ 2 ] = in . nextLong ( ) ;   T [ 0 ] = in . nextLong ( ) ; T [ 1 ] = in . nextLong ( ) ; T [ 2 ] = in . nextLong ( ) ;   int N = in . nextInt ( ) ; long [ ] c = new long [ N ] ;   for ( int i = 0 ; i < N ; i ++ ) c [ i ] = in . nextLong ( ) ;   long [ ] timeWaited = new long [ N ] ; long [ ] timePutInQueue = new long [ N ] ; PriorityQueue < Integer > [ ] pq = new PriorityQueue [ 3 ] ; for ( int i = 0 ; i < 3 ; i ++ ) { pq [ i ] = new PriorityQueue < > ( 10 , ( a , b ) -> { long ta = timeWaited [ a ] ; long tb = timeWaited [ b ] ;


import java . util . * ; public class P2 {   public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int h = sc . nextInt ( ) ; int m = sc . nextInt ( ) ; int sum = 0 ; int a [ ] = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { a [ i ] = 100 ; } for ( int i = 0 ; i < m ; i ++ ) { int l = sc . nextInt ( ) ; int r = sc . nextInt ( ) ; int x = sc . nextInt ( ) ; for ( int j = l - 1 ; j < r ; j ++ ) { a [ j ] = Math . min ( a [ j ] , x ) ; } } for ( int i = 0 ; i < n ; i ++ ) { if ( a [ i ] == 100 ) { sum += h * h ; } else { sum += a [ i ] * a [ i ] ; } } System . out . println ( sum ) ; } }

n , h , m = map ( int , input ( ) . split ( ) ) X = [ h ] * nfor i in range ( m ) : l , r , x = map ( int , input ( ) . split ( ) ) l , r = l - 1 , r - 1 for j in range ( l , r + 1 ) : X [ j ] = min ( X [ j ] , x ) ans = 0 for i in range ( n ) : ans += X [ i ] ** 2 print ( ans ) NEW_LINE


n , h , m = list ( map ( int , input ( ) . split ( ) ) ) doma = [ h ] * n   for _ in range ( m ) : l , r , x = list ( map ( int , input ( ) . split ( ) ) ) for i in range ( l , r + 1 ) : if doma [ i - 1 ] > x : doma [ i - 1 ] = x   summ = 0 for i in doma : summ += i ** 2   print ( summ ) NEW_LINE


n , h , m = map ( int , input ( ) . split ( ) ) l = [ h ] * nfor i in range ( 0 , m ) : p , r , x = map ( int , input ( ) . split ( ) ) for j in range ( p - 1 , r ) : if ( l [ j ] > x ) : l [ j ] = x else : passc = 0 for i in range ( n ) : c = c + l [ i ] * l [ i ] print ( c ) NEW_LINE


from collections import defaultdict as diccn , h , cases = map ( int , input ( ) . split ( ) )   dic = dicc ( )   while cases : cases -= 1 l , r , x = map ( int , input ( ) . split ( ) )   for i in range ( l , r + 1 ) : if i not in dic or dic [ i ] > x : dic [ i ] = x   profit = 0   for spot in range ( 1 , n + 1 ) : if spot not in dic : profit += h ** 2 else : profit += ( min ( h , dic [ spot ] ) ) ** 2   print ( profit ) NEW_LINE


import java . util . * ; import java . util . Arrays ; import java . util . Collections ; public class LineToCashier {   public static void main ( String [ ] args ) {

n = int ( input ( ) ) ks = [ int ( i ) for i in input ( ) . split ( ) ]   mi = 10 ** 9 for k in range ( n ) : mi = min ( mi , sum ( [ 5 * int ( i ) + 15 for i in input ( ) . split ( ) ] ) ) print ( mi ) NEW_LINE


import sysn = int ( input ( ) ) arr = list ( map ( int , input ( ) . split ( ) ) ) min1 = sys . maxsizefor i in range ( n ) : temp = list ( map ( int , input ( ) . split ( ) ) ) temp2 = 0 temp2 += sum ( temp ) * 5 + arr [ i ] * 15 if min1 > temp2 : min1 = temp2print ( min1 ) NEW_LINE


n = int ( input ( ) ) l = list ( map ( int , input ( ) . split ( ) ) ) ans = 10000000000000 for i in range ( n ) : l1 = list ( map ( int , input ( ) . split ( ) ) ) t = 0 for j in range ( len ( l1 ) ) : t = l1 [ j ] * 5 + t t = t + ( len ( l1 ) * 15 ) NEW_LINE


n = int ( input ( ) ) r = lambda : list ( map ( int , input ( ) . split ( ) ) ) arr = r ( ) ans = float ( ' inf ' ) for i in range ( n ) : x = r ( ) c = sum ( x ) * 5 + 15 * len ( x ) ans = min ( ans , c )     print ( ans )   NEW_LINE


n = int ( input ( ) ) fodac = input ( ) val = 100000 for i in range ( n ) : val = min ( val , sum ( int ( x ) * 5 + 15 for x in input ( ) . split ( ) ) ) print ( val ) NEW_LINE


import java . util . * ; public class LinetoCashier {   public static void main ( String [ ] args ) {


import java . util . Scanner ;   public class LineToCashier { public static void main ( String [ ] args ) {   Scanner in = new Scanner ( System . in ) ; int n = in . nextInt ( ) , i , j , a [ ] = new int [ n ] , b [ ] = new int [ n ] , m = Integer . MAX_VALUE ;   for ( i = 0 ; i < n ; i ++ ) { a [ i ] = in . nextInt ( ) ; b [ i ] = a [ i ] * 15 ; } for ( i = 0 ; i < n ; i ++ ) { for ( j = 0 ; j < a [ i ] ; j ++ ) { b [ i ] += in . nextInt ( ) * 5 ; } } in . close ( ) ; for ( i = 0 ; i < n ; i ++ ) m = Math . min ( m , b [ i ] ) ; System . out . println ( m ) ; } }


import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . util . * ; import java . util . StringTokenizer ; public class Main { static class FastReader { BufferedReader br ; StringTokenizer st ; public FastReader ( ) { br = new BufferedReader ( newInputStreamReader ( System . in ) ) ; } String next ( ) { while ( st == null || ! st . hasMoreElements ( ) ) { try { st = new StringTokenizer ( br . readLine ( ) ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } } return st . nextToken ( ) ; } int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; } long nextLong ( ) { return Long . parseLong ( next ( ) ) ; } double nextDouble ( ) { return Double . parseDouble ( next ( ) ) ; } String nextLine ( ) { String str = " " ; try { str = br . readLine ( ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } return str ; } }    public static void main ( String [ ] args ) { FastReader fs = new FastReader ( ) ; int n = fs . nextInt ( ) ;   int [ ] a = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { a [ i ] = fs . nextInt ( ) ; }   int min = Integer . MAX_VALUE ; for ( int i = 0 ; i < n ; i ++ ) { int cur = 0 ; for ( int j = 0 ; j < a [ i ] ; j ++ ) { cur += fs . nextInt ( ) * 5 ; } cur += a [ i ] * 15 ; min = Math . min ( cur , min ) ; }   System . out . println ( min ) ;    } }


import java . util . Scanner ;   public class Main {   public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int casher = sc . nextInt ( ) ; int peopleNumber [ ] = new int [ casher + 1 ] ;   for ( int i = 1 ; i <= casher ; i ++ ) { peopleNumber [ i ] = sc . nextInt ( ) ; }   int min = Integer . MAX_VALUE ; for ( int i = 1 ; i <= casher ; i ++ ) { int queueTime = 0 ; for ( int j = 1 ; j <= peopleNumber [ i ] ; j ++ ) { int temp = sc . nextInt ( ) ; queueTime += ( temp * 5 ) ; } queueTime += ( peopleNumber [ i ] * 15 ) ;


import java . util . Scanner ; public class Ishu { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n , m , i , j , k , l , a , b ; int sum = 0 , min = 0 , x = 0 ; int [ ] [ ] g = new int [ 50 ] [ 50 ] ; n = sc . nextInt ( ) ; m = sc . nextInt ( ) ; for ( i = 0 ; i < n ; ++ i ) for ( j = 0 ; j < m ; ++ j ) g [ i ] [ j ] = sc . nextInt ( ) ; a = sc . nextInt ( ) ; b = sc . nextInt ( ) ; for ( i = 0 ; i + a - 1 < n ; ++ i ) for ( j = 0 ; j + b - 1 < m ; ++ j ) { sum = 0 ; for ( l = i ; l <= i + a - 1 ; ++ l ) for ( k = j ; k <= j + b - 1 ; ++ k ) if ( g [ l ] [ k ] == 1 ) ++ sum ; if ( x == 0 ) { min = sum ; ++ x ; } else if ( sum < min ) min = sum ; } for ( i = 0 ; i + b - 1 < n ; ++ i ) for ( j = 0 ; j + a - 1 < m ; ++ j ) { sum = 0 ; for ( l = i ; l <= i + b - 1 ; ++ l ) for ( k = j ; k <= j + a - 1 ; ++ k ) if ( g [ l ] [ k ] == 1 ) ++ sum ; if ( x == 0 ) { min = sum ; ++ x ; } else if ( sum < min ) min = sum ; } System . out . println ( min ) ; } }

def calc_trees ( cont , start_row , start_col , a , b ) : counter = 0 for i in range ( start_row , start_row + a ) : for j in range ( start_col , start_col + b ) : counter += cont [ i ] [ j ] return counter     n , m = list ( map ( int , input ( ) . split ( " ▁ " ) ) )   cont = [ ] for i in range ( n ) : cont . append ( list ( map ( int , input ( ) . split ( " ▁ " ) ) ) )   a , b = list ( map ( int , input ( ) . split ( " ▁ " ) ) ) ans , helper = n * m , 0 for i in range ( n ) : for j in range ( m ) : if i + a <= n and j + b <= m : helper = calc_trees ( cont , i , j , a , b ) if helper < ans : ans = helper if i + b <= n and j + a <= m : helper = calc_trees ( cont , i , j , b , a ) if helper < ans : ans = helperprint ( ans ) NEW_LINE


I = lambda : map ( int , input ( ) . split ( ) )   n , m = I ( ) A = [ [ * I ( ) ] for _ in range ( n ) ] a , b = I ( )   print ( min ( sum ( A [ i ] [ j ] for i in range ( x , x + dx ) for j in range ( y , y + dy ) ) for dx , dy in ( ( a , b ) , ( b , a ) ) for x in range ( n - dx + 1 ) for y in range ( m - dy + 1 ) ) ) NEW_LINE


n , m = map ( int , input ( ) . split ( ) ) c = [ ] for i in range ( n ) : c . append ( [ ] ) for j in input ( ) . split ( ) : c [ i ] . append ( int ( j ) ) a , b = map ( int , input ( ) . split ( ) ) ans = n * mfor i in range ( n - a + 1 ) : for j in range ( m - b + 1 ) : s = 0 for k in range ( i , i + a ) : s += sum ( c [ k ] [ j : j + b ] ) ans = min ( s , ans ) for i in range ( n - b + 1 ) : for j in range ( m - a + 1 ) : s = 0 for k in range ( i , i + b ) : s += sum ( c [ k ] [ j : j + a ] ) ans = min ( s , ans ) print ( ans ) NEW_LINE


n , m = map ( int , input ( ) . split ( ) ) x = [ list ( map ( int , input ( ) . split ( ) ) ) for i in range ( n ) ] a , b = map ( int , input ( ) . split ( ) ) def solve ( n , m , x ) : y = [ [ 0 ] * ( m + 1 ) for i in range ( n + 1 ) ] for i in range ( n ) : for j in range ( m ) : y [ i + 1 ] [ j + 1 ] = y [ i + 1 ] [ j ] + x [ i ] [ j ] for j in range ( m ) : y [ i + 1 ] [ j + 1 ] += y [ i ] [ j + 1 ] ans = n * m for i in range ( a , n + 1 ) : for j in range ( b , m + 1 ) : ans = min ( ans , y [ i ] [ j ] - y [ i - a ] [ j ] - y [ i ] [ j - b ] + y [ i - a ] [ j - b ] ) return ansprint ( min ( solve ( n , m , x ) , solve ( m , n , list ( map ( list , zip ( * x ) ) ) ) ) ) NEW_LINE


n , m = map ( int , input ( ) . split ( ) )     t = [ ]   for j in range ( n ) : t . append ( list ( map ( int , input ( ) . split ( ) ) ) )       a , b = map ( int , input ( ) . split ( ) ) ans = 99999999   for i in range ( n - a + 1 ) : for j in range ( m - b + 1 ) : u = 0 for x in range ( i , i + a ) : for y in range ( j , j + b ) : u += t [ x ] [ y ]   ans = min ( ans , u )   f = [ ]   for j in range ( m ) : y = [ ] for k in range ( n ) : y . append ( t [ k ] [ j ] ) f . append ( y )   for i in range ( m - a + 1 ) : for j in range ( n - b + 1 ) : u = 0 for x in range ( i , i + a ) : for y in range ( j , j + b ) : u += f [ x ] [ y ]   ans = min ( ans , u )   print ( ans ) NEW_LINE


import java . nio . file . Paths ; import java . util . * ; import java . io . * ; public class Main {


import java . util . Scanner ; public class Ishu { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int n , m , i , j , k , l , a , b , sum = 0 , min = 0 , x = 0 ; int [ ] [ ] garden = new int [ 50 ] [ 50 ] ; n = scan . nextInt ( ) ; m = scan . nextInt ( ) ; for ( i = 0 ; i < n ; ++ i ) for ( j = 0 ; j < m ; ++ j ) garden [ i ] [ j ] = scan . nextInt ( ) ; a = scan . nextInt ( ) ; b = scan . nextInt ( ) ; for ( i = 0 ; i + a - 1 < n ; ++ i ) for ( j = 0 ; j + b - 1 < m ; ++ j ) { sum = 0 ; for ( l = i ; l <= i + a - 1 ; ++ l ) for ( k = j ; k <= j + b - 1 ; ++ k ) if ( garden [ l ] [ k ] == 1 ) ++ sum ; if ( x == 0 ) { min = sum ; ++ x ; } else if ( sum < min ) min = sum ; } for ( i = 0 ; i + b - 1 < n ; ++ i ) for ( j = 0 ; j + a - 1 < m ; ++ j ) { sum = 0 ; for ( l = i ; l <= i + b - 1 ; ++ l ) for ( k = j ; k <= j + a - 1 ; ++ k ) if ( garden [ l ] [ k ] == 1 ) ++ sum ; if ( x == 0 ) { min = sum ; ++ x ; } else if ( sum < min ) min = sum ; } System . out . println ( min ) ; } }


import java . lang . * ; import java . util . * ; import java . io . * ;   public class Codeforces {   public void solve ( ) throws IOException { FastScanner fs = new FastScanner ( ) ; StringBuilder print = new StringBuilder ( ) ; int n = fs . nextInt ( ) , m = fs . nextInt ( ) ; int [ ] [ ] mat = new int [ n ] [ m ] ; for ( int i = 0 ; i < n ; i ++ ) for ( int j = 0 ; j < m ; j ++ ) mat [ i ] [ j ] = fs . nextInt ( ) ;   int a = fs . nextInt ( ) , b = fs . nextInt ( ) ; int cnt = a * b ; for ( int i = 0 ; i < n ; i ++ ) { for ( int j = 0 ; j < m ; j ++ ) { int tmp = 0 , area = 0 ; for ( int k = i ; k < Math . min ( i + a , n ) ; k ++ ) { for ( int l = j ; l < Math . min ( j + b , m ) ; l ++ ) { area ++ ; if ( mat [ k ] [ l ] == 1 ) tmp ++ ; } } if ( area == a * b ) { cnt = Math . min ( tmp , cnt ) ; } area = 0 ; tmp = 0 ; for ( int k = i ; k < Math . min ( i + b , n ) ; k ++ ) { for ( int l = j ; l < Math . min ( j + a , m ) ; l ++ ) { area ++ ; if ( mat [ k ] [ l ] == 1 ) tmp ++ ; } } if ( area == a * b ) { cnt = Math . min ( tmp , cnt ) ; } } } System . out . println ( cnt ) ; }   public static void main ( String [ ] args ) throws IOException { try { new Codeforces ( ) . solve ( ) ; } catch ( Exception e ) {


import java . util . * ; import java . util . ArrayList ; import java . util . List ; import java . util . Scanner ;   public class ChatInGame {   public static void main ( String [ ] args ) {   List < String > inputs = new ArrayList ( ) ; int nroCharactersToEnd = 0 ; int nroRemainingCharacters = 0 ; StringBuilder result = new StringBuilder ( ) ; Scanner keyboard = new Scanner ( System . in ) ; while ( true ) { try { String text = keyboard . nextLine ( ) ; if ( text . isEmpty ( ) ) break ; else { inputs . add ( text ) ; } } catch ( Exception e ) { break ; } }   for ( String text : inputs ) { for ( int i = text . length ( ) - 1 ; i >= 0 ; i -- ) { if ( text . charAt ( i ) == ' ) ' ) { nroCharactersToEnd ++ ; } else { break ; } }   boolean containNumbers = text . contains ( "0" ) || text . contains ( "1" ) || text . contains ( "2" ) || text . contains ( "3" ) || text . contains ( "4" ) || text . contains ( "5" ) || text . contains ( "6" ) || text . contains ( "7" ) || text . contains ( "8" ) || text . contains ( "9" ) ;   if ( ! text . matches ( " [ + - ] ? \\ d * ( \\ . \\ d + ) ? " ) || ! containNumbers ) { if ( text . length ( ) / 2 >= nroCharactersToEnd ) { result . append ( " No \n " ) ; } else result . append ( " Yes \n " ) ; }   nroCharactersToEnd = 0 ;   }    System . out . println ( result ) ;   }   }

t = int ( input ( ) ) NEW_LINE for _ in range ( t ) : n = int ( input ( ) ) NEW_LINE


for _ in range ( int ( input ( ) ) ) : n = int ( input ( ) ) NEW_LINE s = input ( ) NEW_LINE b = - 1 NEW_LINE c = 0 NEW_LINE while b >= - n and s [ b ] == ' ) ' : c += 1 NEW_LINE b -= 1 NEW_LINE print ( " YES " if c > n - c else " NO " ) NEW_LINE


t = int ( input ( ) ) NEW_LINE for ti in range ( t ) : n = int ( input ( ) ) NEW_LINE str = input ( ) NEW_LINE i = n - 1 NEW_LINE c = 0 NEW_LINE while i >= 0 and str [ i ] == ' ) ' : i -= 1 NEW_LINE c += 1 NEW_LINE if c > n - c : NEW_LINE INDENT print ( ' Yes ' ) else : NEW_LINE print ( ' No ' ) NEW_LINE DEDENT


import java . util . Scanner ;   public class chat {   public static void main ( String [ ] args ) { Scanner userInput = new Scanner ( System . in ) ; int t = userInput . nextInt ( ) ; for ( int i = 0 ; i < t ; i ++ ) { int n = userInput . nextInt ( ) ; String S = userInput . next ( ) ; int count = 0 ; for ( int j = n - 1 ; j >= 0 ; j -- , count ++ ) { if ( S . charAt ( j ) != ' ) ' ) break ; } if ( 2 * count > n ) System . out . println ( " Yes " ) ; else System . out . println ( " No " ) ; } }   }


import java . util . Scanner ;   public class A1411 {   public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; int T = in . nextInt ( ) ; for ( int t = 0 ; t < T ; t ++ ) { in . nextInt ( ) ; String S = in . next ( ) ; int count = 0 ; for ( char c : S . toCharArray ( ) ) { if ( c == ' ) ' ) { count ++ ; } else { count = 0 ; } } boolean bad = count > ( S . length ( ) - count ) ; System . out . println ( bad ? " Yes " : " No " ) ; } }   }


import java . util . Scanner ;   public class Nk { public static void main ( String [ ] args ) { Scanner input = new Scanner ( System . in ) ;   int t = input . nextInt ( ) ;   while ( t -- > 0 ) {   int a = input . nextInt ( ) ; String s = input . next ( ) ; int n = 0 ;   for ( int i = s . length ( ) - 1 ; i > - 1 ; i -- ) {   char c = s . charAt ( i ) ;   if ( c == ' ) ' ) { n ++ ;   if ( n == s . length ( ) ) { System . out . println ( " Yes " ) ; } }   else {   if ( n > s . length ( ) - n ) { System . out . println ( " Yes " ) ; break ; }   else { System . out . println ( " No " ) ; break ; } } } } } }


import java . io . * ; import java . math . BigInteger ; import java . util . * ; import static java . lang . Math . PI ; import static java . lang . System . in ; import static java . lang . System . out ; import static java . lang . System . err ;   public class A { public static void main ( String [ ] args ) throws Exception { Foster sc = new Foster ( ) ; PrintWriter p = new PrintWriter ( out ) ; int t = sc . nextInt ( ) ; while ( t -- != 0 ) { int n = sc . nextInt ( ) ; char a [ ] = sc . next ( ) . toCharArray ( ) ; int count = 0 ; for ( int i = n - 1 ; i >= 0 ; i -- ) { if ( a [ i ] == ' ) ' ) count ++ ; else break ; } p . println ( count > n - count ? " Yes " : " No " ) ; } p . close ( ) ; } static long [ ] sort ( long a [ ] ) { ArrayList < Long > arr = new ArrayList < > ( ) ; for ( long i : a ) { arr . add ( i ) ; } Collections . sort ( arr ) ; for ( int i = 0 ; i < arr . size ( ) ; i ++ ) { a [ i ] = arr . get ( i ) ; } return a ; } static int [ ] sort ( int a [ ] ) { ArrayList < Integer > arr = new ArrayList < > ( ) ; for ( int i : a ) { arr . add ( i ) ; } Collections . sort ( arr ) ;


import java . util . * ; public class laptop {   public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; int n = in . nextInt ( ) ; int a [ ] [ ] = new int [ n ] [ 4 ] ; for ( int i = 0 ; i < n ; i ++ ) for ( int j = 0 ; j < 4 ; j ++ ) a [ i ] [ j ] = in . nextInt ( ) ; for ( int i = 0 ; i < n ; i ++ ) for ( int j = 0 ; j < n ; j ++ ) if ( a [ i ] [ 0 ] < a [ j ] [ 0 ] && a [ i ] [ 1 ] < a [ j ] [ 1 ] && a [ i ] [ 2 ] < a [ j ] [ 2 ] ) a [ i ] [ 3 ] = Integer . MAX_VALUE ; for ( int i = 0 ; i < n ; i ++ ) { int ctr = 0 ; for ( int j = 0 ; j < n ; j ++ ) if ( i != j && a [ i ] [ 3 ] < a [ j ] [ 3 ] ) ctr ++ ;   if ( ctr == n - 1 ) { System . out . println ( i + 1 ) ; break ; } }   }   }

from sys import * input = stdin . readlinet = int ( input ( ) ) l = [ ] cost = [ ] for i in range ( t ) : a , b , c , d = map ( int , input ( ) . split ( ) ) l . append ( [ a , b , c ] ) cost . append ( d ) for i in range ( t ) : for j in range ( t ) : if ( i != j ) : if ( l [ i ] [ 0 ] < l [ j ] [ 0 ] and l [ i ] [ 1 ] < l [ j ] [ 1 ] and l [ i ] [ 2 ] < l [ j ] [ 2 ] ) : cost [ i ] = 10000 breakprint ( cost . index ( min ( cost ) ) + 1 )   NEW_LINE


from itertools import compressarr = [ ] yo = lenfor i in range ( int ( input ( ) ) ) : NEW_LINE


a = int ( input ( ) ) l = [ ] for x in range ( a ) : b = list ( map ( int , input ( ) . split ( ) ) ) l . append ( b )   ma = 9999999999999 s = 0 t = - 1 for x in range ( a ) : for y in range ( a ) : if x == y : s += 1 continue   else : if l [ x ] [ 0 ] >= l [ y ] [ 0 ] or l [ x ] [ 1 ] >= l [ y ] [ 1 ] or l [ x ] [ 2 ] >= l [ y ] [ 2 ] : s += 1   if s == a : if ma > l [ x ] [ 3 ] : ma = l [ x ] [ 3 ] t = x + 1   s = 0 else : s = 0 continue   print ( t ) NEW_LINE


n = int ( input ( ) ) li = [ ] f = [ ] p = [ ] for i in range ( n ) : l1 = list ( map ( int , input ( ) . split ( ) ) ) li . append ( l1 )   pr = [ li [ i ] [ 3 ] for i in range ( n ) ]   for i in range ( n ) : for j in range ( n ) : if li [ i ] [ 0 ] < li [ j ] [ 0 ] and li [ i ] [ 1 ] < li [ j ] [ 1 ] and li [ i ] [ 2 ] < li [ j ] [ 2 ] : pr [ i ] = 0 break   for i in range ( n ) : if pr [ i ] > 0 : f . append ( i ) p . append ( pr [ i ] )   print ( f [ p . index ( min ( p ) ) ] + 1 ) NEW_LINE


n = int ( input ( ) ) a = 0 b = 0 c = 0 g = [ ] v = [ 0 ] * nfor _ in range ( n ) : l = list ( map ( int , input ( ) . split ( ) ) ) g . append ( l ) l = [ ] for i in range ( n ) : f = 0 for j in range ( n ) : if ( g [ i ] [ 1 ] < g [ j ] [ 1 ] and g [ i ] [ 2 ] < g [ j ] [ 2 ] and g [ i ] [ 0 ] < g [ j ] [ 0 ] ) : f = 1 break if ( f == 0 ) : l . append ( ( g [ i ] [ 3 ] , i + 1 ) ) l . sort ( key = lambda x : ( x [ 0 ] , x [ 1 ] ) )   print ( l [ 0 ] [ 1 ] ) NEW_LINE


import java . util . Arrays ; import java . util . Scanner ;   public class problemB { private static final Scanner in = new Scanner ( System . in ) ;   public static void main ( String [ ] args ) { int n = in . nextInt ( ) ; int a [ ] [ ] = new int [ n ] [ 4 ] , b [ ] = new int [ n ] , c [ ] = new int [ n ] ; Arrays . fill ( c , 0 ) ; for ( int i = 0 ; i < n ; ++ i ) { for ( int j = 0 ; j < 3 ; ++ j ) { a [ i ] [ j ] = in . nextInt ( ) ; } b [ i ] = in . nextInt ( ) ; }


import java . util . * ; import java . lang . * ; import java . io . * ; public class Vasya_and_choose_laptop {   public static void main ( String [ ] args ) throws java . lang . Exception { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; int n = Integer . parseInt ( br . readLine ( ) ) , a [ ] [ ] = new int [ n ] [ 4 ] ; for ( int i = 0 ; i < n ; i ++ ) { StringTokenizer st = new StringTokenizer ( br . readLine ( ) ) ; for ( int j = 0 ; j < 4 ; j ++ ) { a [ i ] [ j ] = Integer . parseInt ( st . nextToken ( ) ) ; } } int no = Integer . MAX_VALUE , po = 0 ; boolean b [ ] = new boolean [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { int s = a [ i ] [ 0 ] , r = a [ i ] [ 1 ] , hdd = a [ i ] [ 2 ] ; for ( int j = 0 ; j < n ; j ++ ) { if ( s < a [ j ] [ 0 ] && r < a [ j ] [ 1 ] && hdd < a [ j ] [ 2 ] && ! b [ i ] ) { b [ i ] = true ;


import java . util . * ;   public class Codeforces { static Scanner sc ; public static void main ( String [ ] args ) { sc = new Scanner ( System . in ) ; int t = 1 ;   while ( t -- > 0 ) { solve ( ) ; }   sc . close ( ) ; }   private static void solve ( ) {   int n = sc . nextInt ( ) ; int v = sc . nextInt ( ) ;   int [ ] arr = new int [ 3001 ] ; for ( int i = 0 ; i < n ; i ++ ) arr [ sc . nextInt ( ) ] += sc . nextInt ( ) ;   int op = helper ( arr , v ) ; System . out . println ( op ) ; }   private static int helper ( int [ ] arr , int v ) { int prev = 0 ; int count = 0 ; for ( int i = 1 ; i <= 3000 ; i ++ ) { int curr = v ; if ( prev >= v ) { count += curr ; prev = arr [ i ] ; } else { count += prev ; curr -= prev ; if ( arr [ i ] >= curr ) { count += curr ; prev = arr [ i ] - curr ; } else { count += arr [ i ] ; prev = 0 ; } } } if ( prev >= v ) { count += v ; } else { count += prev ; } return count ; }    public static void sort2dArray ( long [ ] [ ] arr ) { Arrays . sort ( arr , ( a , b ) -> { if ( a [ 1 ] == b [ 1 ] ) return ( int ) ( a [ 0 ] - b [ 0 ] ) ; return ( int ) ( a [ 1 ] - b [ 1 ] ) ; } ) ; }   }

n , v = [ int ( x ) for x in input ( ) . split ( ' ▁ ' ) ] a_dict = { } m = 0 p = 0 for tree in range ( n ) : a , b = [ int ( x ) for x in input ( ) . split ( ' ▁ ' ) ] m = max ( a , m ) if a in a_dict . keys ( ) : a_dict [ a ] += b else : a_dict [ a ] = b   for day in range ( m + 2 ) : if day not in a_dict . keys ( ) : a_dict [ day ] = 0     for day in range ( 1 , m + 2 ) :   y = min ( v , a_dict [ day - 1 ] ) a_dict [ day - 1 ] -= y z = min ( v - y , a_dict [ day ] ) a_dict [ day ] -= z   p += z + y   print ( p ) NEW_LINE


from sys import stdin , stdoutinput = stdin . readline import math , bisect   n , v = map ( int , input ( ) . split ( ) ) l = [ 0 ] * ( 3002 ) for i in range ( n ) : a , b = map ( int , input ( ) . split ( ) ) l [ a ] += b   ans = 0 rem = 0 for i in range ( 1 , 3002 ) : if l [ i ] + rem <= v : ans += ( l [ i ] + rem ) rem = 0 else : if rem >= v : ans += v rem = l [ i ] else : ans += rem if l [ i ] >= v - rem : ans += v - rem rem = l [ i ] - ( v - rem ) else : ans += l [ i ] rem = 0 print ( ans + min ( v , rem ) )   NEW_LINE


n , v = map ( int , input ( ) . split ( ) ) l = [ ] for j in range ( 3001 ) : l += [ 0 ] for k in range ( n ) : x , y = map ( int , input ( ) . split ( ) ) l [ x - 1 ] += ysum = 0 for kl in range ( 3001 ) : if kl == 0 : if v <= l [ kl ] : sum += v l [ kl ] -= v else : sum += l [ kl ] l [ kl ] = 0 else : v1 = v if v1 <= l [ kl - 1 ] : sum += v1 l [ kl - 1 ] -= v1 else : sum += l [ kl - 1 ] v1 -= l [ kl - 1 ] l [ kl - 1 ] = 0 if v1 > 0 : if v1 <= l [ kl ] : sum += v1 l [ kl ] -= v1 else : sum += l [ kl ] l [ kl ] = 0 print ( sum ) NEW_LINE


n , v = map ( int , input ( ) . split ( ) ) lst = [ 0 ] * 3002 for i in range ( n ) : a , b = map ( int , input ( ) . split ( ) ) lst [ a ] += b   ans = 0 prev = 0 for i in range ( 1 , len ( lst ) ) : available = min ( v , prev + lst [ i ] ) ans += available if prev >= v : prev = lst [ i ] else : prev = max ( 0 , lst [ i ] - ( v - prev ) )   print ( ans ) NEW_LINE


import java . util . * ; import java . util . Scanner ; import java . io . * ; import javax . lang . model . util . ElementScanner6 ; import static java . lang . System . out ;    public class B441M2 {   public static void main ( String args [ ] ) {   FastReader in = new FastReader ( ) ; PrintWriter pr = new PrintWriter ( new BufferedWriter ( new OutputStreamWriter ( System . out ) ) ) ; int tc = 1 ;


import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . math . BigInteger ; import java . util . * ;   import javafx . util . Pair ;   public class Main {


import java . io . * ; import java . util . StringTokenizer ;

from collections import defaultdict , deque , Counterfrom sys import stdin , stdoutfrom heapq import heappush , heappopimport mathimport ioimport osimport mathimport bisect   NEW_LINE


from collections import * from itertools import * from string import * from bisect import * from queue import * from heapq import * from math import * from sys import * from re import * def fast ( ) : return stdin . readline ( ) . strip ( ) def zzz ( ) : return [ int ( i ) for i in fast ( ) . split ( ) ]     z , zz = input , lambda : list ( map ( int , z ( ) . split ( ) ) ) szz , graph , mod , szzz = lambda : sorted ( zz ( ) ) , { } , 10 ** 9 + 7 , lambda : sorted ( zzz ( ) )     def lcd ( xnum1 , xnum2 ) : return ( xnum1 * xnum2 // gcd ( xnum1 , xnum2 ) ) def output ( answer ) : stdout . write ( str ( answer ) )     dx = [ - 1 , 1 , 0 , 0 , 1 , - 1 , 1 , - 1 ] dy = [ 0 , 0 , 1 , - 1 , 1 , - 1 , - 1 , 1 ]     NEW_LINE


n = int ( input ( ) ) a = list ( map ( int , input ( ) . split ( ) ) ) a . sort ( reverse = True ) b = [ ] idx = 0 cnt = 1 while idx < n : while idx + 1 < n and a [ idx ] == a [ idx + 1 ] : idx += 1 cnt += 1 b . append ( [ a [ idx ] , cnt ] ) cnt = 1 idx += 1 ans = 0 m = len ( b ) dp = [ 0 ] * mdp [ - 1 ] = b [ m - 1 ] [ 0 ] * b [ m - 1 ] [ 1 ] for i in range ( m - 1 ) [ : : - 1 ] : if b [ i ] [ 0 ] == b [ i + 1 ] [ 0 ] + 1 and i + 2 < m : dp [ i ] = max ( dp [ i + 1 ] , dp [ i + 2 ] + b [ i ] [ 0 ] * b [ i ] [ 1 ] ) elif b [ i ] [ 0 ] == b [ i + 1 ] [ 0 ] + 1 : dp [ i ] = max ( dp [ i + 1 ] , b [ i ] [ 0 ] * b [ i ] [ 1 ] ) else : dp [ i ] = dp [ i + 1 ] + b [ i ] [ 0 ] * b [ i ] [ 1 ] print ( max ( dp ) ) NEW_LINE


import sys , mathfrom itertools import permutations , combinationsfrom collections import defaultdict , dequeinput = sys . stdin . readline   n = int ( input ( ) ) l = list ( map ( int , input ( ) . split ( ) ) ) d = defaultdict ( int ) maxi = 0 for i in l : maxi = max ( maxi , i ) d [ i ] += 1 dp = [ 0 for i in range ( maxi + 1 ) ] dp [ 1 ] = d [ 1 ] for i in range ( 2 , maxi + 1 ) : dp [ i ] = max ( d [ i ] * i + dp [ i - 2 ] , dp [ i - 1 ] ) print ( dp [ - 1 ] ) NEW_LINE


import osimport sysfrom io import BytesIO , IOBaseimport mathimport itertoolsimport bisectimport heapq NEW_LINE


import java . io . * ; import java . util . * ;   public class Main { static int n ; static int [ ] arr ; static final int MAXN = ( int ) 1e5 + 7 ;


import java . util . * ; import java . io . * ;    public class C_Div1_A_Boredom { public static void main ( String args [ ] ) throws NumberFormatException , IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; int n = Integer . parseInt ( br . readLine ( ) ) ; String [ ] sarr = br . readLine ( ) . split ( " ▁ " ) ; long [ ] arr = new long [ 100001 ] ; for ( int i = 0 ; i < n ; i ++ ) { int val = Integer . parseInt ( sarr [ i ] ) ; arr [ val ] ++ ; } long [ ] dp = new long [ 100001 ] ; dp [ 1 ] = arr [ 1 ] ; for ( int i = 2 ; i < arr . length ; i ++ ) { dp [ i ] = Math . max ( dp [ i - 1 ] , dp [ i - 2 ] + i * arr [ i ] ) ; } System . out . println ( dp [ 100000 ] ) ; } }


import java . io . File ; import java . util . Arrays ; import java . util . Scanner ; import java . util . StringTokenizer ;   public class p023 { public static void main ( String args [ ] ) throws Exception { StringTokenizer stok = new StringTokenizer ( new Scanner ( System . in ) . useDelimiter ( " \\ A " ) . next ( ) ) ; StringBuilder sb = new StringBuilder ( ) ; int n = Integer . parseInt ( stok . nextToken ( ) ) ; long [ ] a = new long [ n + 2 ] ; for ( int i = 1 ; i <= n ; i ++ ) a [ i ] = Long . parseLong ( stok . nextToken ( ) ) ; long [ ] l = new long [ n + 2 ] ; long [ ] r = new long [ n + 2 ] ; for ( int i = 1 ; i <= n ; i ++ ) l [ i ] = Math . min ( l [ i - 1 ] + 1 , a [ i ] ) ; for ( int i = n ; i >= 1 ; i -- ) r [ i ] = Math . min ( r [ i + 1 ] + 1 , a [ i ] ) ; for ( int i = 1 ; i <= n ; i ++ ) l [ i ] = Math . min ( l [ i ] , r [ i ] ) ; System . out . println ( Arrays . stream ( l ) . max ( ) . getAsLong ( ) ) ; } }

from sys import stdin , stdoutnmbr = lambda : int ( stdin . readline ( ) ) lst = lambda : list ( map ( int , stdin . readline ( ) . split ( ) ) ) PI = float ( ' inf ' ) for _ in range ( 1 ) : NEW_LINE


from math import infn = int ( input ( ) ) l = [ int ( i ) for i in input ( ) . split ( ) ] l . append ( 0 ) l . insert ( 0 , 0 ) minus = [ v - i for i , v in enumerate ( l ) ] plus = [ v + i for i , v in enumerate ( l ) ]   lminus , rplus = [ minus [ 0 ] ] , [ plus [ - 1 ] ] for i in range ( 1 , n + 1 ) : lminus . append ( min ( lminus [ - 1 ] , minus [ i ] ) ) lminus . append ( inf )   for i in range ( n , 0 , - 1 ) : rplus . append ( min ( rplus [ - 1 ] , plus [ i ] ) ) rplus . append ( inf ) rplus . reverse ( ) m = 0   for i in range ( 1 , n + 1 ) : x = min ( lminus [ i ] + i , rplus [ i ] - i ) m = max ( m , x ) print ( m ) NEW_LINE


import sysfrom math import gcd , sqrt , ceil , log2from collections import defaultdict , Counter , dequefrom bisect import bisect_left , bisect_rightimport mathsys . setrecursionlimit ( 2 * 10 ** 5 + 10 ) import heapqfrom itertools import permutations   NEW_LINE


import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . util . StringTokenizer ; public class Solution { public static void main ( String [ ] args ) throws IOException { BufferedReader reader = new BufferedReader ( new InputStreamReader ( System . in ) ) ; int n = Integer . parseInt ( reader . readLine ( ) ) ; int [ ] array = new int [ n ] ; int [ ] farward = new int [ n ] ; StringTokenizer stoken = new StringTokenizer ( reader . readLine ( ) ) ; array [ 0 ] = Integer . parseInt ( stoken . nextToken ( ) ) ; farward [ 0 ] = 1 ; for ( int i = 1 ; i < n ; i ++ ) { array [ i ] = Integer . parseInt ( stoken . nextToken ( ) ) ; farward [ i ] = Math . min ( farward [ i - 1 ] + 1 , array [ i ] ) ; } int [ ] backward = new int [ n ] ; backward [ n - 1 ] = 1 ; int res = Math . min ( farward [ n - 1 ] , backward [ n - 1 ] ) ; for ( int i = n - 2 ; i > - 1 ; i -- ) { backward [ i ] = Math . min ( backward [ i + 1 ] + 1 , array [ i ] ) ; res = Math . max ( res , Math . min ( farward [ i ] , backward [ i ] ) ) ; } System . out . println ( res ) ; } }


import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . util . StringTokenizer ;   public class Solution { public static void main ( String [ ] args ) throws IOException { BufferedReader reader = new BufferedReader ( new InputStreamReader ( System . in ) ) ; int n = Integer . parseInt ( reader . readLine ( ) ) ; int [ ] array = new int [ n ] ; int [ ] farward = new int [ n ] ; StringTokenizer stoken = new StringTokenizer ( reader . readLine ( ) ) ; array [ 0 ] = Integer . parseInt ( stoken . nextToken ( ) ) ; farward [ 0 ] = 1 ; for ( int i = 1 ; i < n ; i ++ ) { array [ i ] = Integer . parseInt ( stoken . nextToken ( ) ) ; farward [ i ] = Math . min ( farward [ i - 1 ] + 1 , array [ i ] ) ; } int [ ] backward = new int [ n ] ; backward [ n - 1 ] = 1 ; int res = Math . min ( farward [ n - 1 ] , backward [ n - 1 ] ) ; for ( int i = n - 2 ; i > - 1 ; i -- ) { backward [ i ] = Math . min ( backward [ i + 1 ] + 1 , array [ i ] ) ; res = Math . max ( res , Math . min ( farward [ i ] , backward [ i ] ) ) ; } System . out . println ( res ) ; } }


import java . util . * ; import java . io . * ;   public class Yaroslav_and_Sequence {   static int mod = ( int ) ( 1e9 + 7 ) ;   public static void main ( String [ ] args ) throws java . lang . Exception { long start = System . nanoTime ( ) ;

n = int ( input ( ) ) a = list ( map ( int , input ( ) . split ( ) ) ) neg = 0   for i in range ( len ( a ) ) : if ( a [ i ] < 0 ) : neg += 1 a [ i ] = - a [ i ] if ( neg % 2 == 0 or n % 2 == 1 ) : print ( sum ( a ) ) else : print ( sum ( a ) - min ( a ) * 2 ) NEW_LINE


n = int ( input ( ) ) a = list ( map ( int , input ( ) . split ( ) ) ) t = 0 for i in range ( len ( a ) ) : if a [ i ] < 0 : t += 1 a [ i ] = - a [ i ] if t % 2 == 0 or n % 2 == 1 : print ( sum ( a ) ) else : print ( sum ( a ) - min ( a ) * 2 ) NEW_LINE


/ * Author - - Vishwas Agrawal * // * Author - - Vishwas Agrawal * / NEW_LINE


import static java . lang . System . out ;   import java . util . * ;   public class Test {   Test ( ) { Scanner in = new Scanner ( System . in ) ; int initNumber = in . nextInt ( ) ; List < Integer > numbers = new ArrayList < > ( ) ; boolean hasZero = false ; int minuses = 0 ; int sum = 0 ; for ( int index = 0 ; index < 2 * initNumber - 1 ; index ++ ) { int number = in . nextInt ( ) ; if ( number < 0 ) { minuses ++ ; number *= - 1 ; } else if ( number == 0 ) { hasZero = true ; } sum += number ; numbers . add ( number ) ; } if ( hasZero ) { out . println ( sum ) ; return ; } if ( initNumber % 2 == 1 ) { out . println ( sum ) ; return ; } if ( minuses % 2 == 0 ) { out . println ( sum ) ; return ; } Collections . sort ( numbers ) ; out . println ( sum - 2 * numbers . get ( 0 ) ) ; }   public static void main ( String [ ] args ) { new Test ( ) ; } }


import java . util . * ; import java . io . * ;   public class Main { public static void main ( String [ ] args ) throws IOException { FastScanner in = new FastScanner ( System . in ) ; PrintWriter out = new PrintWriter ( System . out ) ; new Main ( ) . run ( in , out ) ; out . close ( ) ; }   public static long mod = 17352642619633L ;   int N ; int [ ] a ; void run ( FastScanner in , PrintWriter out ) {


import java . util . Scanner ;   public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int scene = sc . nextInt ( ) ; for ( int k = 0 ; k < scene ; k ++ ) { int n = sc . nextInt ( ) ; int x = sc . nextInt ( ) ; int list1Cnt = 0 ; int list2Cnt = 0 ; for ( int i = 0 ; i < n ; i ++ ) { int temp = sc . nextInt ( ) ; if ( temp % 2 != 0 ) { list1Cnt ++ ; } else { list2Cnt ++ ; } }   boolean result = false ; if ( list2Cnt >= x - 1 ) { result = list1Cnt >= 1 ; } else { if ( ( x - list2Cnt ) % 2 == 1 ) { result = list1Cnt >= x - list2Cnt ; } else { if ( list2Cnt == 0 ) { result = false ; } else { result = list1Cnt >= x - list2Cnt + 1 ; } } } System . out . println ( result ? " YES " : " NO " ) ; } } }

t = int ( input ( ) )   for i in range ( t ) : n , x = map ( int , input ( ) . split ( ) ) a = list ( map ( int , input ( ) . split ( ) ) ) odd = 0 even = 0 for j in range ( n ) : if a [ j ] % 2 == 1 : odd += 1 else : even += 1 m = min ( even , x - 1 ) d = x - m   if d % 2 == 0 : d += 1 if odd >= d and d <= x : print ( " YES " ) else : print ( " NO " ) NEW_LINE


t = int ( input ( ) )   def odd_sum ( n , l ) : eve = 0 odd = 0 t = 0 for i in l : if i % 2 == 0 : eve += 1 else : odd += 1   m = min ( eve , n - 1 ) fill = n - m if fill % 2 == 0 : fill += 1 if odd >= fill and fill <= n : return ' Yes ' else : return ' No '     for i in range ( t ) : n , x = map ( int , input ( ) . split ( ) ) l = list ( map ( int , input ( ) . split ( ) ) ) print ( odd_sum ( x , l ) )             NEW_LINE


for _ in range ( int ( input ( ) ) ) : n , x = map ( int , input ( ) . split ( ) ) l = list ( map ( int , input ( ) . split ( ) ) ) e = 0 o = 0 for i in l : if i % 2 == 0 : e += 1 else : o += 1 if e + o == x : if o % 2 != 0 : print ( " Yes " ) else : print ( " No " ) else : if o >= x and x % 2 != 0 : print ( " Yes " ) elif o >= 1 and e >= 1 : print ( " YES " ) else : print ( " No " ) NEW_LINE


for _ in range ( int ( input ( ) ) ) : n , x = map ( int , input ( ) . split ( ) ) a = list ( map ( int , input ( ) . split ( ) ) )   ce = 0 co = 0 summ = 0 for i in a : if i % 2 == 0 : ce += 1 else : co += 1 summ += i if n == x : if summ % 2 == 0 : print ( " No " ) else : print ( " Yes " ) elif x % 2 == 0 : if ce > 0 and co > 0 : print ( " Yes " ) else : print ( " No " ) else : if co > 0 : print ( " Yes " ) else : print ( " No " ) NEW_LINE


for _ in range ( int ( input ( ) ) ) : n , x = map ( int , input ( ) . split ( ) ) l = list ( map ( int , input ( ) . split ( ) ) ) odd = 0 even = 0 for i in l : if ( i % 2 == 0 ) : even += 1 else : odd += 1 if ( odd == 0 ) : print ( " No " ) else : if ( odd % 2 == 0 ) : if ( x < odd ) : if ( x % 2 == 0 ) : rem = 1 else : rem = 0 else : rem = x - ( odd - 1 ) else : if ( x < odd ) : if ( x % 2 == 0 ) : rem = 1 else : rem = 0 else : rem = x - odd print ( ' Yes ' if even >= rem else ' No ' ) NEW_LINE


import java . lang . * ; import java . util . * ; import java . util . stream . Collectors ; import java . io . * ;   public class Bit_year { public static void main ( String [ ] args ) throws IOException { Scanner sc = new Scanner ( System . in ) ; int T = sc . nextInt ( ) ; while ( T -- > 0 ) { int n = sc . nextInt ( ) ; int k = sc . nextInt ( ) ; List < Integer > even = new ArrayList < Integer > ( ) ; List < Integer > odd = new ArrayList < Integer > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { int num = sc . nextInt ( ) ; if ( num % 2 == 0 ) even . add ( num ) ; else odd . add ( num ) ; } int sum = 0 ; if ( odd . size ( ) > 0 ) { sum += odd . get ( 0 ) ; odd . remove ( 0 ) ; k -- ; while ( k > 1 && odd . size ( ) > 1 ) { sum += odd . get ( 0 ) ; odd . remove ( 0 ) ; sum += odd . get ( 0 ) ; odd . remove ( 0 ) ; k -= 2 ; } while ( k > 0 && even . size ( ) > 0 ) { sum += even . get ( 0 ) ; even . remove ( 0 ) ; k -- ; } } System . out . println ( ( k > 0 || sum == 0 || sum % 2 == 0 ) ? " NO " : " YES " ) ; } } }


import java . util . * ; public class A51 { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; boolean [ ] table = new boolean [ 6667 ] ; int num = scan . nextInt ( ) , a , b , number , result = 1 , j = 0 ; a = scan . nextInt ( ) * 100 ; b = scan . nextInt ( ) ; number = b % 10 * 10 + ( b / 10 ) + a ; for ( int i = 0 ; i < 4 ; i ++ ) { number = rotate ( number ) ; table [ number ] = true ; } for ( int i = 1 ; i < num ; i ++ ) { scan . next ( ) ; a = scan . nextInt ( ) * 100 ; b = scan . nextInt ( ) ; number = b % 10 * 10 + ( b / 10 ) + a ; j = 0 ; if ( ! table [ number ] ) for ( j = 0 ; j < 4 ; j ++ ) { number = rotate ( number ) ; table [ number ] = true ; } if ( j != 0 ) result ++ ; } System . out . println ( result ) ; }   public static int rotate ( int number ) { int help = number % 10 * 1000 ; number /= 10 ; return number + help ; } }

def rotate ( item : str ) -> str : NEW_LINE


n = int ( input ( ) ) a = [ ] for i in range ( n ) : s = input ( ) s += input ( ) [ : : - 1 ] if i != n - 1 : input ( ) add = True for x in a : if s in x : add = False break if add : a . append ( s + s ) print ( len ( a ) ) NEW_LINE


d = dict ( ) ; o = int ( input ( ) ) for t in range ( o ) : x , y = input ( ) . replace ( ' ' , ' ▁ ' ) . split ( ) i , j = input ( ) . replace ( ' ' , ' ▁ ' ) . split ( ) if t != o - 1 : input ( ) if not ( ( x , y , i , j ) in d or ( y , j , x , i ) in d or ( j , i , y , x ) in d or ( i , x , j , y ) in d ) : d [ ( x , y , i , j ) ] = 1 print ( len ( d ) ) NEW_LINE


n = int ( input ( ) ) d = { } for i in range ( n ) : s = ' ' found = False s = input ( ) + input ( ) if i != n - 1 : input ( ) t = s [ 2 ] + s [ 0 ] + s [ 3 ] + s [ 1 ] p = s [ 3 ] + s [ 2 ] + s [ 1 ] + s [ 0 ] q = s [ 1 ] + s [ 3 ] + s [ 0 ] + s [ 2 ] for key in d . keys ( ) : for var in d [ key ] . keys ( ) : if s == var : found = True d [ key ] [ var ] += 1 if not found : d [ s ] = { } d [ s ] [ s ] = 1 d [ s ] [ t ] = 0 d [ s ] [ p ] = 0 d [ s ] [ q ] = 0 print ( len ( d ) ) NEW_LINE


nro_amu = int ( input ( ) )   amu = [ ] for i in range ( nro_amu ) : fila1 = list ( input ( ) ) fila2 = list ( input ( ) ) fila1 . extend ( fila2 ) amu . append ( fila1 ) if i + 1 != nro_amu : _ = input ( ) pilas = [ ] nro_pilas = 0   for a in amu : existe = False for i in range ( nro_pilas ) : for j in range ( 4 ) : if pilas [ i ] [ j ] == a : existe = True if not existe : pilas . append ( [ a , [ a [ 2 ] , a [ 0 ] , a [ 3 ] , a [ 1 ] ] , [ a [ 3 ] , a [ 2 ] , a [ 1 ] , a [ 0 ] ] , [ a [ 1 ] , a [ 3 ] , a [ 0 ] , a [ 2 ] ] ] ) nro_pilas = nro_pilas + 1 print ( nro_pilas ) NEW_LINE


import java . util . Arrays ; import java . util . Scanner ;   public class AA {   public static void main ( String [ ] args ) { int n , temp , min , x ; int c [ ] = new int [ 10 ] ; boolean w [ ] = new boolean [ 10010 ] ; Arrays . fill ( w , false ) ; Scanner in = new Scanner ( System . in ) ; n = in . nextInt ( ) ; for ( int i = 0 ; i < n ; i ++ ) { in . nextLine ( ) ; for ( int j = 0 ; j < 4 ; j += 2 ) { String a = in . nextLine ( ) ; c [ j ] = a . charAt ( 0 ) - '0' ; c [ j + 1 ] = a . charAt ( 1 ) - '0' ; } temp = c [ 2 ] ; c [ 2 ] = c [ 3 ] ; c [ 3 ] = temp ; min = 99999 ; for ( int j = 0 ; j < 4 ; j ++ ) c [ j + 4 ] = c [ j ] ; for ( int j = 0 ; j < 4 ; j ++ ) { x = 0 ; for ( int r = j ; r < j + 4 ; r ++ ) { x = x * 10 + c [ r ] ; } if ( x < min ) { min = x ; } } w [ min ] = true ;   } int ans = 0 ; for ( int i = 0 ; i <= 9999 ; i ++ ) { if ( w [ i ] ) ans ++ ; } System . out . println ( ans ) ;   }   }


import java . util . ArrayList ; import java . util . Scanner ;     public class ASD {   public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; int n = in . nextInt ( ) ; ArrayList < Domino > dominoes = new ArrayList < Domino > ( ) ;   while ( n > 0 ) { in . nextLine ( ) ; String a = in . nextLine ( ) ; String b = in . nextLine ( ) ; Domino B = new Domino ( ) ; B . a [ 0 ] = ( int ) ( a . charAt ( 0 ) - '0' ) ; B . a [ 1 ] = ( int ) ( a . charAt ( 1 ) - '0' ) ; B . a [ 2 ] = ( int ) ( b . charAt ( 1 ) - '0' ) ; B . a [ 3 ] = ( int ) ( b . charAt ( 0 ) - '0' ) ; dominoes . add ( B ) ;   for ( int i = 0 ; i < dominoes . size ( ) - 1 ; i ++ ) { if ( B . is_equal ( dominoes . get ( i ) ) ) { dominoes . remove ( i ) ; }   }   n -- ; } System . out . println ( dominoes . size ( ) ) ; }   }   class Domino { int [ ] a = new int [ 4 ] ;   boolean is_equal ( Domino A ) { for ( int i = 0 ; i < 4 ; i ++ ) { if ( this . a [ i ] == A . a [ 0 ] && this . a [ ( i + 1 ) % 4 ] == A . a [ 1 ] && this . a [ ( i + 2 ) % 4 ] == A . a [ 2 ] && this . a [ ( i + 3 ) % 4 ] == A . a [ 3 ] ) return true ; } return false ;   }   }


import java . util . * ; public class Sleuth {   public static void main ( String [ ] args ) {

if input ( ) . lower ( ) . strip ( ' ? ▁ ' ) [ - 1 ] in ' aeiouy ' : print ( " YES " ) else : print ( " NO " ) NEW_LINE


pregunta = input ( ) n = len ( pregunta ) vocales = [ ' A ' , ' E ' , ' I ' , ' O ' , ' U ' , ' Y ' , ' a ' , ' e ' , ' i ' , ' o ' , ' u ' , ' y ' ] rpta = ' '   i = 2 while i <= n and rpta == ' ' : if pregunta [ n - i ] != ' ▁ ' : for j in range ( len ( vocales ) ) : if pregunta [ n - i ] == vocales [ j ] : rpta = ' YES ' break if rpta == ' ' : rpta = ' NO ' i = i + 1 print ( rpta ) NEW_LINE


s = input ( ) v = " AEIOUYaeiouy " l = [ ] for i in s [ : : - 1 ] : if i != " ▁ " and i != " ? " : if i in v : print ( " YES " ) exit ( ) else : print ( " NO " ) exit ( ) NEW_LINE


str1 = list ( map ( str , input ( ) . split ( ) ) ) if ( str1 [ len ( str1 ) - 1 ] == ' ? ' ) : k = str1 [ len ( str1 ) - 2 ] k_len = len ( k ) m = k [ k_len - 1 ] if ( m == ' a ' or m == ' e ' or m == ' i ' or m == ' o ' or m == ' u ' or m == ' y ' or m == ' A ' or m == ' E ' or m == ' I ' or m == ' O ' or m == ' U ' or m == ' Y ' ) : print ( ' YES ' ) else : print ( ' NO ' ) else : k = str1 [ len ( str1 ) - 1 ] k_len = len ( k ) m = k [ k_len - 2 ] if ( m == ' a ' or m == ' e ' or m == ' i ' or m == ' o ' or m == ' u ' or m == ' y ' or m == ' A ' or m == ' E ' or m == ' I ' or m == ' O ' or m == ' U ' or m == ' Y ' ) : print ( ' YES ' ) else : print ( ' NO ' ) NEW_LINE


import java . util . * ;   public class questionCF {   public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . nextLine ( ) ; for ( int i = s . length ( ) - 1 ; i >= 0 ; i -- ) { char c = s . charAt ( i ) ; if ( c == ' ? ' || c == ' ▁ ' ) continue ; if ( c == ' A ' || c == ' E ' || c == ' I ' || c == ' O ' || c == ' U ' || c == ' Y ' || c == ' a ' || c == ' e ' || c == ' i ' || c == ' o ' || c == ' u ' || c == ' y ' ) { System . out . println ( " YES " ) ; return ; } else { System . out . println ( " NO " ) ; return ; } } } }


import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . util . * ;   public class Codeforces {   private static final Scanner sc = new Scanner ( System . in ) ; private static final BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; private static final long MOD = ( long ) ( 1e9 + 7 ) ;   public static int [ ] LPS ( String p ) { int [ ] lps = new int [ p . length ( ) ] ;   int i = 1 ; int j = 0 ; while ( i < p . length ( ) ) { if ( p . charAt ( i ) == p . charAt ( j ) ) { lps [ i ] = j + 1 ; i ++ ; j ++ ; } else { if ( j == 0 ) { lps [ i ] = 0 ; i ++ ; } else { j = lps [ j - 1 ] ; } } } return lps ; }   public static void KMP ( String text , String pattern ) { int [ ] lps = LPS ( pattern ) ; int i = 0 ; int j = 0 ; ArrayList < Integer > matches = new ArrayList < > ( ) ; while ( i < text . length ( ) ) { if ( text . charAt ( i ) == pattern . charAt ( j ) ) { i ++ ; j ++ ; } else { if ( j != 0 ) { j = lps [ j - 1 ] ; } else { i ++ ; } } if ( j == pattern . length ( ) ) { matches . add ( i - j ) ; j = lps [ j - 1 ] ; } } for ( int x : matches ) { System . out . println ( " Match ▁ at ▁ : ▁ " + x ) ; } }   private static class SegmentTree { private long [ ] st ; private int size ; private int n ; private long [ ] a ; SegmentTree ( long [ ] a , int n ) { this . size = 4 * n ; this . n = n ; this . a = a ; st = new long [ size ] ;


normal = '312831303130313130313031' leap = '312931303130313130313031' years_5 = normal * 2 + leap + normal * 2 n = int ( input ( ) ) A = [ a for a in input ( ) . split ( ) ] A = ' ' . join ( A ) if ( A in years_5 ) : print ( ' YES ' ) else : print ( ' NO ' ) NEW_LINE


import java . util . * ; public class contest10 { static Scanner scn = new Scanner ( System . in ) ; public static void main ( String [ ] args ) { int n = scn . nextInt ( ) ; int [ ] arr = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) arr [ i ] = scn . nextInt ( ) ; String input = " " ; for ( int val : arr ) input += " , " + val ; n = input . length ( ) ;


import java . io . * ; import java . util . * ;   public class Solution { public static void main ( String [ ] args ) throws Exception { int n = in . readInt ( ) ; int [ ] A = in . readA ( ) ; int [ ] days = { 31 , 28 , 31 , 30 , 31 , 30 , 31 , 31 , 30 , 31 , 30 , 31 } ; boolean l = false ;   for ( int i = 0 ; i < 12 ; i ++ ) { int j = 0 , leap = 0 ; for ( ; j < n ; j ++ ) { if ( days [ ( j + i ) % 12 ] != A [ j ] ) { if ( ( j + i ) % 12 == 1 && A [ j ] == 29 ) leap ++ ; else break ; } } if ( j == n && leap < 2 ) l = true ; }   if ( l ) System . out . println ( " Yes " ) ; else System . out . println ( " No " ) ;


import java . util . Scanner ;   public class App {   public static void main ( String [ ] args ) { Scanner inp = new Scanner ( System . in ) ; int n = inp . nextInt ( ) ; String a = "312831303130313130313031" ; String b = " " ; int t ; boolean lp = false ; for ( int i = 0 ; i < n ; i ++ ) { t = inp . nextInt ( ) ; if ( t == 29 ) { if ( lp ) { System . out . println ( " NO " ) ; inp . close ( ) ; return ; } b += 28 ; lp = true ; } else { b += t ; } } String tmp = a ; if ( tmp . contains ( b ) ) { System . out . println ( " YES " ) ; } else if ( ( tmp += a ) . contains ( b ) ) { System . out . println ( " YES " ) ; } else if ( ( tmp += a ) . contains ( b ) ) { System . out . println ( " YES " ) ; } else { System . out . println ( " NO " ) ; } inp . close ( ) ; }   }


import java . util . * ; import java . io . * ;   public class Main { public static void main ( String [ ] args ) throws IOException { FastScanner in = new FastScanner ( System . in ) ; PrintWriter out = new PrintWriter ( System . out ) ; new Main ( ) . run ( in , out ) ; out . close ( ) ; }   public static long mod = 17352642619633L ;   void run ( FastScanner in , PrintWriter out ) throws IOException { int N = in . nextInt ( ) ; char [ ] ca = in . br . readLine ( ) . toCharArray ( ) ;   int max = 0 ; for ( int i = 0 ; i < N ; ) { if ( ! alpha ( ca [ i ] ) ) { i ++ ; continue ; }   int vol = 0 ; while ( i < N && alpha ( ca [ i ] ) ) { if ( ca [ i ] >= ' A ' && ca [ i ] <= ' Z ' ) vol ++ ; i ++ ; } max = Math . max ( vol , max ) ; } out . println ( max ) ;   } boolean alpha ( char c ) { return ( c >= ' A ' && c <= ' Z ' ) || ( c >= ' a ' && c <= ' z ' ) ;   }   static class FastScanner { BufferedReader br ; StringTokenizer st ;   public FastScanner ( InputStream in ) { br = new BufferedReader ( new InputStreamReader ( in ) ) ; st = null ; }   String next ( ) { while ( st == null || ! st . hasMoreElements ( ) ) { try { st = new StringTokenizer ( br . readLine ( ) ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } } return st . nextToken ( ) ; }   int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; }   long nextLong ( ) { return Long . parseLong ( next ( ) ) ; } } }

n = input ( ) S = list ( map ( str , input ( ) . split ( ) ) ) Max = 0 for i in range ( len ( S ) ) : C = 0 for j in range ( len ( S [ i ] ) ) : if S [ i ] [ j ] . isupper ( ) : C += 1 if C > Max : Max = Cprint ( Max ) NEW_LINE


if __name__ == " _ _ main _ _ " : text_length = int ( input ( ) ) words = list ( input ( ) . split ( ) ) max_volume = 0 for word in words : max_volume = max ( max_volume , sum ( [ 1 for letter in word if str ( letter ) . isupper ( ) ] ) ) print ( max_volume ) NEW_LINE


num = input ( )   arr = input ( ) . split ( )   mx = 0 ct = 0 for word in arr : for char in word : if char . isupper ( ) : ct += 1 mx = max ( mx , ct ) ct = 0   print ( mx )   NEW_LINE


import string   uppercased_letters = string . ascii_uppercase   def find_volume ( word ) : volume = 0 for character in word : if character in uppercased_letters : volume += 1 return volume   _ = int ( input ( ) ) text = input ( )     volumes = [ ] words = text . split ( )     for word in words : volumes . append ( find_volume ( word ) )   volume_of_text = max ( volumes ) print ( volume_of_text ) NEW_LINE


n = int ( input ( ) ) s = input ( ) . split ( ) ans = 0 for i in s : now = 0 for j in i : now += j <= ' Z ' ans = max ( ans , now )   print ( ans ) NEW_LINE


import java . util . * ;   public class P3 { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; sc . nextLine ( ) ; String s = sc . nextLine ( ) ;   int c = 0 ; int max = 0 ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { if ( s . charAt ( i ) >= ' A ' && s . charAt ( i ) <= ' Z ' ) { c ++ ; max = Math . max ( c , max ) ; } if ( s . charAt ( i ) == ' ▁ ' ) { c = 0 ; } } System . out . println ( max ) ; } }


import java . io . * ; import java . util . * ;   public class A1008 { public static void main ( String [ ] args ) { InputStream inputReader = System . in ; OutputStream outputReader = System . out ; InputReader in = new InputReader ( inputReader ) ;


import java . io . FileInputStream ; import java . io . FileNotFoundException ; import java . io . IOException ; import java . io . PrintWriter ; import java . util . Arrays ; import java . util . Collection ; import java . util . List ; import java . util . Scanner ; import java . util . function . Function ; import java . util . stream . Collectors ; public class _p000837A { static public void main ( final String [ ] args ) throws IOException { p000837A . _main ( args ) ; }


import java . util . * ; public class test { public static void main ( String [ ] agrs ) { int n ; String s ; Scanner scan = new Scanner ( System . in ) ; n = scan . nextInt ( ) ; s = scan . nextLine ( ) ;


import java . io . OutputStream ; import java . io . IOException ; import java . io . InputStream ; import java . io . PrintWriter ; import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { InputStream inputStream = System . in ; OutputStream outputStream = System . out ; Scanner in = new Scanner ( inputStream ) ; PrintWriter out = new PrintWriter ( outputStream ) ; TaskA solver = new TaskA ( ) ; int testCount = Integer . parseInt ( in . next ( ) ) ; for ( int i = 1 ; i <= testCount ; i ++ ) solver . solve ( i , in , out ) ; out . close ( ) ; } static class TaskA { public void solve ( int testNumber , Scanner in , PrintWriter out ) { long n = in . nextLong ( ) ; long m = in . nextLong ( ) ; long x = in . nextLong ( ) ; long col = ( x / n ) ; if ( x % n > 0 ) col ++ ; long row = ( x - 1 ) % n ; out . println ( m * row + col ) ; } } }

from sys import stdin , setrecursionlimit , stdout NEW_LINE from math import sqrt , floor , ceil , log , log2 , log10 , pi , gcd , sin , cos , asin NEW_LINE def ii ( ) : return int ( stdin . readline ( ) ) NEW_LINE def fi ( ) : return float ( stdin . readline ( ) ) NEW_LINE def mi ( ) : return map ( int , stdin . readline ( ) . split ( ) ) NEW_LINE def fmi ( ) : return map ( float , stdin . readline ( ) . split ( ) ) NEW_LINE def li ( ) : return list ( mi ( ) ) NEW_LINE def si ( ) : return stdin . readline ( ) . rstrip ( ) NEW_LINE def lsi ( ) : return list ( si ( ) ) NEW_LINE mod = 1000000007 NEW_LINE res = [ ' NO ' , ' YES ' ] NEW_LINE test , test_case = 0 , 1 NEW_LINE test_case = ii ( ) NEW_LINE while test < test_case : NEW_LINE INDENT test += 1 NEW_LINE n , m , x = mi ( ) NEW_LINE c = ceil ( x / n ) NEW_LINE r = x % n NEW_LINE if not r : NEW_LINE INDENT r = n NEW_LINE DEDENT print ( m * ( r - 1 ) + c ) NEW_LINE DEDENT


import math NEW_LINE cases = int ( input ( ) ) NEW_LINE for c in range ( cases ) : NEW_LINE INDENT n , m , pos = map ( int , input ( ) . split ( ) ) NEW_LINE row = pos % n if pos % n != 0 else n NEW_LINE col = ( pos - 1 ) // n + 1 NEW_LINE answ = ( row - 1 ) * m + col NEW_LINE print ( answ ) NEW_LINE DEDENT


import math NEW_LINE def main ( ) : NEW_LINE INDENT t = int ( input ( ) ) NEW_LINE cases = [ ] NEW_LINE for i in range ( t ) : NEW_LINE INDENT cases . append ( list ( map ( int , input ( ) . split ( ) ) ) ) NEW_LINE DEDENT for case in cases : NEW_LINE INDENT if case [ 2 ] % case [ 0 ] == 0 : NEW_LINE INDENT row = case [ 0 ] NEW_LINE DEDENT else : NEW_LINE INDENT row = case [ 2 ] % case [ 0 ] NEW_LINE DEDENT col = math . ceil ( case [ 2 ] / case [ 0 ] ) NEW_LINE x = row * case [ 1 ] - ( case [ 1 ] - col ) NEW_LINE print ( x ) NEW_LINE DEDENT DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT main ( ) NEW_LINE DEDENT


import math as m NEW_LINE def findClosest ( arr , n , target ) : NEW_LINE INDENT if ( target <= arr [ 0 ] ) : NEW_LINE INDENT return arr [ 0 ] , 0 NEW_LINE DEDENT if ( target >= arr [ n - 1 ] ) : NEW_LINE INDENT return arr [ n - 1 ] , n - 1 NEW_LINE DEDENT i = 0 ; NEW_LINE j = n ; NEW_LINE mid = 0 NEW_LINE while ( i < j ) : NEW_LINE INDENT mid = ( i + j ) // 2 NEW_LINE if ( arr [ mid ] == target ) : NEW_LINE INDENT return arr [ mid ] , mid NEW_LINE DEDENT if ( target < arr [ mid ] ) : NEW_LINE INDENT if ( mid > 0 and target > arr [ mid - 1 ] ) : NEW_LINE INDENT return getClosest ( arr [ mid - 1 ] , arr [ mid ] , target ) , 0 NEW_LINE DEDENT j = mid NEW_LINE DEDENT else : NEW_LINE INDENT if ( mid < n - 1 and target < arr [ mid + 1 ] ) : NEW_LINE INDENT return getClosest ( arr [ mid ] , arr [ mid + 1 ] , target ) , 0 NEW_LINE DEDENT i = mid + 1 NEW_LINE DEDENT DEDENT return arr [ mid ] , mid NEW_LINE DEDENT def getClosest ( val1 , val2 , target ) : NEW_LINE INDENT if ( target - val1 <= val2 - target ) : NEW_LINE INDENT return val1 NEW_LINE DEDENT else : NEW_LINE INDENT return val2 NEW_LINE DEDENT DEDENT test_Cases = int ( input ( ) ) NEW_LINE for i in range ( 0 , test_Cases ) : NEW_LINE INDENT row , column , cell_by_column = input ( ) . split ( ) NEW_LINE row = int ( row ) NEW_LINE column = int ( column ) NEW_LINE cell_by_column = int ( cell_by_column ) NEW_LINE cell_by_column_temp = cell_by_column NEW_LINE count = 0 NEW_LINE r = cell_by_column_temp / row NEW_LINE if cell_by_column_temp % row != 0 : NEW_LINE INDENT r = r + 1 NEW_LINE DEDENT r = int ( r ) NEW_LINE count = row - ( r * row - cell_by_column ) NEW_LINE x_coordinate = r NEW_LINE y_coordinates = count NEW_LINE t1 = ( y_coordinates - 1 ) * column NEW_LINE t2 = x_coordinate NEW_LINE print ( t1 + t2 ) NEW_LINE DEDENT


for _ in range ( int ( input ( ) ) ) : NEW_LINE INDENT n , m , x = map ( int , input ( ) . split ( ) ) NEW_LINE if ( x % n == 0 ) : NEW_LINE INDENT column_x = x // n NEW_LINE DEDENT else : NEW_LINE INDENT column_x = x // n + 1 NEW_LINE DEDENT row_x = x - abs ( ( ( column_x - 1 ) * n ) ) NEW_LINE if ( row_x == 1 ) : NEW_LINE INDENT v = column_x NEW_LINE DEDENT else : NEW_LINE INDENT v = ( row_x - 1 ) * m + column_x NEW_LINE DEDENT print ( v ) NEW_LINE DEDENT


import java . util . Scanner ; public class StrangeTable { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int testCase = sc . nextInt ( ) ; while ( testCase > 0 ) { String input = sc . next ( ) ; input += sc . nextLine ( ) ; int i = 0 ; String [ ] split = input . split ( " ▁ " ) ; long m = Long . parseLong ( split [ i ++ ] ) ; long n = Long . parseLong ( split [ i ++ ] ) ; long x = Long . parseLong ( split [ i ] ) ; long p = x % m == 0 ? x / m : x / m + 1 ; long q = x % m == 0 ? m : x % m ; long y = ( q - 1 ) * n + p ; System . out . println ( y ) ; testCase -- ; } } }


import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int t = sc . nextInt ( ) ; while ( t -- > 0 ) { long n = sc . nextLong ( ) ; long m = sc . nextLong ( ) ; long x = sc . nextLong ( ) ; solve ( n , m , x ) ; } } public static void solve ( long n , long m , long x ) { x -- ; long row = x % n ; long col = x / n ; System . out . println ( row * m + col + 1 ) ; } }


import java . io . IOException ; import java . util . * ; public class Main5 { static int [ ] t ; public static void main ( String [ ] args ) throws IOException { Scanner sc = new Scanner ( System . in ) ; int t = sc . nextInt ( ) ; while ( t -- > 0 ) { int n = sc . nextInt ( ) ; int m = sc . nextInt ( ) ; long x = sc . nextLong ( ) ; long col = x / n ; long row = x % n ; if ( row == 0 ) { col -- ; row = n - 1 ; } else { row -- ; } long val = row * m + col + 1 ; System . out . println ( val ) ; } } }


import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int t = scan . nextInt ( ) ; while ( t > 0 ) { long n = scan . nextLong ( ) ; long m = scan . nextLong ( ) ; long x = scan . nextLong ( ) ; long row = ( x - 1 ) % n + 1 ; long col = ( x - 1 ) / n + 1 ; System . out . println ( ( row - 1 ) * m + col ) ; t -- ; } } }


import java . util . Scanner ; public class JavaApplication1 { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long a = sc . nextInt ( ) ; long b = sc . nextInt ( ) ; if ( a == b ) { System . out . println ( " infinity " ) ; return ; } long cont = 0 ; long semresto = a - b ; long meio = ( long ) ( Math . sqrt ( semresto ) + 1 ) ; for ( int i = 1 ; i < meio ; i ++ ) { if ( semresto % i == 0 ) { if ( i > b ) cont ++ ; if ( ( semresto / i ) != i && ( semresto / i ) > b ) cont ++ ; } } System . out . println ( cont ) ; } }


from math import sqrtn_to_mod , remainder = input ( ) . split ( )   n_to_mod = int ( n_to_mod ) remainder = int ( remainder )     def verify_n_divisors ( array_div_population ) : if array_div_population == [ ] : return 0 n_of_divisors = 1 for idx_div in range ( len ( array_div ) ) : n_of_divisors *= ( array_div_population [ idx_div ] + 1 ) return n_of_divisors     def is_at_array_div ( divisor , array_div , array_div_population ) : for div_idx in range ( len ( array_div ) ) : if divisor == array_div [ div_idx ] : array_div_population [ div_idx ] += 1 return array_div_population . append ( 1 ) array_div . append ( divisor )     def get_divisors ( array_div , array_div_population ) : divisors = [ 1 ]   for div_idx in range ( len ( array_div ) ) :   divisors = multiply_fact_n_times ( divisors , array_div [ div_idx ] , array_div_population [ div_idx ] ) return divisors     def multiply_fact_n_times ( divisors , factor , n_times ) : new_divisors = [ ] for div in divisors : result = div * factor new_divisors . append ( result ) divisors = divisors + new_divisors   while n_times - 1 > 0 : final_divisors = [ ] for div in new_divisors : result = div * factor final_divisors . append ( result ) divisors = divisors + final_divisors new_divisors = final_divisors n_times -= 1   return divisors   if n_to_mod == remainder : print ( ' infinity ' ) elif n_to_mod <= remainder : print ( 0 ) else : array_div = [ ] array_div_population = [ ] factor_count = 2 plus_two = False   first_module = n_to_mod - remainder max_size = sqrt ( first_module ) count_modular_times = 0 module_controller = 2 while first_module != 1 : if first_module % factor_count == 0 : first_module //= factor_count is_at_array_div ( factor_count , array_div , array_div_population )   else : if not plus_two : factor_count += 1 plus_two = True else : factor_count += 2   if factor_count > max_size : factor_count = first_module   divisors = list ( sorted ( get_divisors ( array_div , array_div_population ) ) ) for divisor in divisors : if divisor > remainder : count_modular_times += 1 print ( count_modular_times )   NEW_LINE


a , b = map ( int , input ( ) . split ( ) ) if a == b : print ( ' infinity ' ) exit ( 0 ) x = abs ( a - b ) ans = 0 for xx in range ( 1 , int ( x ** 0.5 ) + 1 ) : if x % xx == 0 : if a % xx == b : ans += 1 if xx * xx != x : if a % ( x // xx ) == b : ans += 1 print ( ans ) NEW_LINE


arr = [ int ( x ) for x in input ( ) . split ( ) ] a = arr [ 0 ] b = arr [ 1 ] resp = 0 if a == b : resp = ' infinity ' if resp != ' infinity ' : x = a - b i = 1 c = 0 while i ** 2 < x : c += 1 if x % i == 0 : if i > b : resp += 1 if x / i > b : resp += 1 i += 1 if i ** 2 == x and i > b : resp += 1 print ( resp )   NEW_LINE


import java . util . Scanner ;   public class Teste { public static void main ( String args [ ] ) {


import static java . lang . Math . sqrt ; import java . util . Scanner ; public class modularEquations { public static void main ( String args [ ] ) { Scanner sc = new Scanner ( System . in ) ; int a = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int count = 0 ; int end = a - b ; if ( a == b ) { System . out . println ( " infinity " ) ; return ; } for ( int i = 1 ; i <= Math . sqrt ( end ) ; i ++ ) { if ( a % i == b ) count ++ ; if ( ( end % i ) == 0 ) { if ( i > end ) count ++ ;   if ( ( end / i ) != i && ( end / i ) > b ) count ++ ; } } System . out . println ( Integer . toString ( count ) ) ; } }


import java . util . * ; import java . math . * ;   public class Main { private static Scanner s ; public static void main ( String [ ] args ) { s = new Scanner ( System . in ) ; int num = s . nextInt ( ) ; int resp = s . nextInt ( ) ; int mod = 0 ; int count = 0 ; if ( num == resp ) { System . out . println ( " infinity " ) ; return ; } if ( resp > num ) { System . out . println ( "0" ) ; return ; } int diff = num - resp ; for ( int i = 1 ; i * i <= diff ; i ++ ) { if ( diff % i == 0 ) { if ( diff / i == i && i > resp ) { count ++ ; } else { if ( i > resp ) count ++ ; if ( diff / i > resp ) count ++ ; } } } System . out . println ( count ) ; s . close ( ) ; } }


import java . util . * ; import java . lang . * ; import java . math . * ; import java . awt . image . ConvolveOp ; import java . io . * ; import java . text . DecimalFormat ; import java . lang . reflect . Array ; import java . io . BufferedOutputStream ; import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . io . PrintWriter ; import java . math . BigDecimal ; import java . util . * ; public class Codeforces { public static PrintWriter out = new PrintWriter ( new BufferedOutputStream ( System . out ) ) ; static long MOD = ( long ) ( 1e9 + 7 ) ; static FastReader sc = new FastReader ( ) ; static int pInf = Integer . MAX_VALUE ; static int nInf = Integer . MIN_VALUE ; public static void main ( String [ ] args ) { int test = 1 ;


import java . util . * ; public class Main { public static void main ( String args [ ] ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; boolean is = false ; if ( n < 0 ) { n = n * - 1 ; is = true ; } int last , lastSecond ; if ( is ) { last = n % 10 ; lastSecond = n % 100 ; lastSecond = lastSecond / 10 ; if ( last >= lastSecond ) { n = n / 10 ; } else { n = n / 100 ; n = n * 10 ; n = n + last ; } n = n * - 1 ; } System . out . println ( n ) ; } }

n = input ( ) n = int ( n )   if n >= 0 : print ( n ) else : n = str ( n ) print ( max ( int ( n [ 0 : - 2 ] + n [ - 1 : ] ) , int ( n [ 0 : - 1 ] ) ) ) NEW_LINE


n = int ( input ( ) ) if n < 0 : print ( max ( int ( str ( n ) [ : - 1 ] ) , int ( str ( n ) [ : - 2 ] + str ( n ) [ - 1 ] ) ) ) else : print ( n ) NEW_LINE


n = int ( input ( ) ) a = abs ( n ) % 10 b = abs ( n ) // 10 % 10 if n > 0 : print ( n ) elif a > b : print ( int ( str ( n ) [ 0 : - 1 ] ) ) else : n = str ( n ) print ( int ( n [ 0 : - 2 ] + n [ - 1 ] ) ) NEW_LINE


s1 = input ( ) n = int ( s1 ) if n > 0 : print ( n ) else : b = s1 [ len ( s1 ) - 1 ] a = s1 [ len ( s1 ) - 2 ] s2 = s1 [ 0 : len ( s1 ) - 2 ] aa = s2 + a bb = s2 + b n1 = int ( aa ) n2 = int ( bb ) if n1 >= n2 : print ( n1 ) else : print ( n2 ) NEW_LINE


import java . util . * ;   public class Codeforces { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; int n = in . nextInt ( ) ; if ( n >= 0 ) { System . out . println ( n ) ; } else { int max = Math . max ( n / 10 , n / 100 * 10 + n % 10 ) ; System . out . println ( max ) ; } System . out . println ( ) ;   }   }


import java . io . * ; import java . util . StringTokenizer ;   public class A313 { public static void main ( String [ ] args ) throws IOException { PrintWriter out = new PrintWriter ( System . out ) ; FastScanner fs = new FastScanner ( ) ; long N ; N = fs . nextInt ( ) ; if ( N > 0 ) { out . println ( N ) ; } else { out . println ( Math . max ( ( int ) ( N / 10 ) , ( int ) ( ( N / 100 ) * 10 ) + ( N % 10 ) ) ) ; } out . close ( ) ; }   static class FastScanner { BufferedReader br ; StringTokenizer st ;   public FastScanner ( ) { br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; }   public FastScanner ( String filePath ) throws FileNotFoundException { try { br = new BufferedReader ( new FileReader ( filePath ) ) ; } catch ( FileNotFoundException e ) { e . printStackTrace ( ) ; } }   String next ( ) throws IOException { while ( st == null || ! st . hasMoreTokens ( ) ) { try { st = new StringTokenizer ( br . readLine ( ) ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; throw e ; } } return st . nextToken ( ) ; }   String nextLine ( ) throws IOException { String str ; try { str = br . readLine ( ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; throw e ; } return str ; }   int nextInt ( ) throws IOException { return Integer . parseInt ( this . next ( ) ) ; }   long nextLong ( ) throws IOException { return Long . parseLong ( this . next ( ) ) ; } } }


import java . util . * ; public class lyaandBankAccount {   public static void main ( String [ ] args ) {


import java . util . * ; import java . io . * ;   public class A_Elevator {   public static void main ( String [ ] args ) throws Exception { Scanner in = new Scanner ( new File ( " input . txt " ) ) ; PrintWriter pw = new PrintWriter ( new File ( " output . txt " ) ) ;

import syssys . stdin = open ( ' input . txt ' , ' r ' ) sys . stdout = open ( ' output . txt ' , ' w ' ) s = input ( ) n = input ( ) if s == " front " and n == '1' : print ( ' L ' ) elif s == " front " and n == '2' : print ( ' R ' ) elif s == " back " and n == '1' : print ( " R " ) elif s == " back " and n == '2' : print ( " L " ) NEW_LINE


import syssys . stdin = open ( " input . txt " , " r " ) sys . stdout = open ( " output . txt " , " w " ) match = input ( ) rail = int ( input ( ) ) if match == " front " : if rail == 1 : print ( " L " ) else : print ( " R " ) else : if rail == 1 : print ( " R " ) else : print ( " L " ) NEW_LINE


input_file = open ( " input . txt " , " r " ) door = input_file . readline ( ) [ : - 1 ] rail_no = int ( input_file . readline ( ) )   if ( door == " front " ) : d_num = 1 else : d_num = 2   output_file = open ( " output . txt " , " w " ) if ( ( rail_no + d_num ) % 2 == 0 ) : output_file . write ( " L " ) else : output_file . write ( " R " ) NEW_LINE


a = open ( " input . txt " , " r " ) . read ( ) . split ( ) f = open ( " output . txt " , " w " ) if a [ 0 ] [ 0 ] == " f " and a [ 1 ] == "1" or a [ 0 ] [ 0 ] == " b " and a [ 1 ] == "2" : f . write ( " L " ) else : f . write ( " R " ) f . close ( ) NEW_LINE


f = open ( ' input . txt ' , ' r ' ) n1 = f . readline ( ) n2 = f . readline ( ) n2 = int ( n2 ) n1 = n1 [ : n1 . index ( ' \n ' ) ] g = open ( ' output . txt ' , ' w ' ) if n1 == ' front ' and n2 == 1 : g . write ( ' L ' ) elif n1 == ' back ' and n2 == 1 : g . write ( ' R ' ) elif n1 == ' back ' and n2 == 2 : g . write ( ' L ' ) elif n1 == ' front ' and n2 == 2 : g . write ( ' R ' ) NEW_LINE


import java . io . PrintWriter ; import java . io . BufferedReader ; import java . io . InputStreamReader ; import java . math . BigInteger ; import java . util . Scanner ; import java . util . * ; import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStream ; import java . io . InputStreamReader ; import java . io . BufferedWriter ; import java . io . DataInputStream ; import java . io . File ; import java . io . FileInputStream ; import java . io . OutputStreamWriter ; import java . util . InputMismatchException ; import jdk . nashorn . internal . codegen . CompilerConstants ; public class Solution { public static void main ( String [ ] args ) throws IOException {


import java . io . PrintWriter ; import java . io . BufferedReader ; import java . io . InputStreamReader ; import java . math . BigInteger ; import java . util . Scanner ; import java . util . * ; import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStream ; import java . io . InputStreamReader ; import java . io . BufferedWriter ; import java . io . DataInputStream ; import java . io . File ; import java . io . FileInputStream ; import java . io . OutputStreamWriter ; import java . util . InputMismatchException ; import jdk . nashorn . internal . codegen . CompilerConstants ;   public class Solution { public static void main ( String [ ] args ) throws IOException {


import java . io . * ; import java . util . * ; public class kuchBhi { public static void main ( String [ ] args ) throws Throwable {


import java . util . * ; public class Main {   public static void main ( String [ ] args ) { int t , n ;   Scanner sc = new Scanner ( System . in ) ;   t = sc . nextInt ( ) ;   while ( t -- > 0 ) { n = sc . nextInt ( ) ;   System . out . println ( ( n <= 3 ) ? n - 1 : 2 + ( n & 1 ) ) ; }

def solve ( n ) : if NEW_LINE n == 1 : NEW_LINE return 0 elif n == 2 : NEW_LINE return 1 elif n == 3 : NEW_LINE return 2 else : if n % 2 == 0 : NEW_LINE INDENT return 2 else : NEW_LINE return 3   t = int ( input ( ) ) NEW_LINE DEDENT for tc in range ( t ) : n = int ( input ( ) ) NEW_LINE print ( solve ( n ) ) NEW_LINE


for i in range ( int ( input ( ) ) ) : n = int ( input ( ) ) NEW_LINE if n == 1 : NEW_LINE INDENT print ( 0 ) elif n == 2 : NEW_LINE print ( 1 ) elif n == 3 : NEW_LINE print ( 2 ) elif n % 2 == 0 : NEW_LINE print ( 2 ) else : NEW_LINE print ( 3 ) NEW_LINE DEDENT


for _ in range ( int ( input ( ) ) ) : n = input ( ) NEW_LINE if n == "1" : NEW_LINE INDENT count = 0 elif n == "2" : NEW_LINE count = 1 elif int ( n [ - 1 ] ) % 2 == 0 or n == "3" : NEW_LINE count = 2 else : NEW_LINE count = 3 NEW_LINE DEDENT print ( count ) NEW_LINE


t = int ( input ( ) ) NEW_LINE while t > 0 : t = t - 1 NEW_LINE n = int ( input ( ) ) NEW_LINE if n == 1 : NEW_LINE INDENT print ( 0 ) elif n == 2 : NEW_LINE print ( 1 ) elif n == 3 : NEW_LINE print ( 2 ) elif n % 2 == 0 : NEW_LINE print ( 2 ) else : NEW_LINE print ( 3 ) NEW_LINE DEDENT


import java . util . * ;   import static java . lang . Math . * ;   public class WayTooLongWords { public static void main ( String args [ ] ) { Scanner in = new Scanner ( System . in ) ; int x = in . nextInt ( ) ; while ( x > 0 ) { x -- ; int n = in . nextInt ( ) ; if ( n == 1 ) System . out . println ( 0 ) ; else if ( n == 2 ) System . out . println ( 1 ) ; else if ( n == 3 ) System . out . println ( 2 ) ; else if ( n > 3 && n % 2 == 0 ) System . out . println ( 2 ) ; else System . out . println ( 3 ) ; } } }


import java . util . Scanner ;    public class JavaApplication71 {   public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; int size = in . nextInt ( ) ; for ( int i = 0 ; i < size ; i ++ ) { int n = in . nextInt ( ) ; if ( n == 1 ) { System . out . println ( 0 ) ; continue ; } if ( n == 2 ) { System . out . println ( 1 ) ; continue ; } if ( n == 3 ) { System . out . println ( 2 ) ; continue ; } if ( n % 2 == 0 ) { System . out . println ( 2 ) ; continue ; } else { System . out . println ( 3 ) ; continue ; } } } }


import java . util . * ; public class Array {   public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; int n = in . nextInt ( ) ; int a [ ] = new int [ n ] ; for ( int j = 0 ; j < n ; j ++ ) a [ j ] = in . nextInt ( ) ; for ( int j = 0 ; j < n ; j ++ ) { if ( a [ j ] == 1 ) System . out . println ( 0 ) ; else if ( a [ j ] == 2 ) System . out . println ( 1 ) ; else if ( a [ j ] == 3 ) System . out . println ( 2 ) ; else if ( a [ j ] % 2 == 0 ) System . out . println ( 2 ) ; else System . out . println ( 3 ) ; } } }


import java . util . Scanner ;   public class A1451 { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int t = scanner . nextInt ( ) ; for ( int i = 0 ; i < t ; i ++ ) { int n = scanner . nextInt ( ) ; if ( n == 1 ) { System . out . println ( 0 ) ; continue ; } else if ( n == 2 ) { System . out . println ( 1 ) ; } else if ( n == 3 ) { System . out . println ( 2 ) ; } else { System . out . println ( n % 2 == 1 ? 3 : 2 ) ; } } } }


import java . util . * ; import java . io . * ; import java . math . * ; public class Main { static BufferedReader input = new BufferedReader ( new InputStreamReader ( System . in ) ) ; static StringTokenizer st ; static PrintWriter pr = new PrintWriter ( new BufferedWriter ( new OutputStreamWriter ( System . out ) ) ) ; public static void main ( String [ ] args ) throws IOException { int n = readInt ( ) , q = readInt ( ) , a [ ] = new int [ n ] ; Set < Integer > s = new HashSet ( ) ; for ( int i = 0 ; i < n ; i ++ ) a [ i ] = readInt ( ) ; edge [ ] arr = new edge [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { int b = readInt ( ) ; arr [ i ] = new edge ( i , b , a [ i ] ) ; s . add ( i ) ; } Arrays . sort ( arr ) ; Map < Integer , Integer > mp = new HashMap ( ) ; for ( int i = 0 ; i < n ; i ++ ) { mp . put ( arr [ i ] . v , i ) ; } int cur = 0 ;

import sysinput = sys . stdin . readlinen , m = map ( int , input ( ) . split ( ) ) a = list ( map ( int , input ( ) . split ( ) ) ) c = list ( map ( int , input ( ) . split ( ) ) ) l = [ ] for i in range ( len ( c ) ) : l . append ( ( c [ i ] , i ) )   l . sort ( ) ptr = 0 NEW_LINE


import math , sys , bisect , heapqfrom collections import defaultdict , Counter , dequefrom itertools import groupby , accumulate NEW_LINE


import sysfrom collections import dequeinput_ = lambda : sys . stdin . readline ( ) . strip ( " \n " ) ii = lambda : int ( input_ ( ) ) il = lambda : list ( map ( int , input_ ( ) . split ( ) ) ) ilf = lambda : list ( map ( float , input ( ) . split ( ) ) ) ip = lambda : input ( ) fi = lambda : float ( input ( ) ) li = lambda : list ( input ( ) ) pr = lambda x : print ( x )   n , m = il ( ) a = il ( ) c = il ( )   z = [ [ c [ i ] , i ] for i in range ( n ) ]   z . sort ( ) z = deque ( z )   for _ in range ( m ) : x , y = il ( )   ans = 0   x -= 1   t = min ( y , a [ x ] ) a [ x ] -= t ans += t * c [ x ] y -= t   while y > 0 and z : f = z [ 0 ] t = min ( a [ f [ 1 ] ] , y ) a [ f [ 1 ] ] -= t y -= t ans += f [ 0 ] * t   if a [ f [ 1 ] ] == 0 : z . popleft ( )   if y == 0 : print ( ans ) else : print ( 0 ) NEW_LINE


import sys , math , itertoolsfrom collections import Counter , deque , defaultdictfrom bisect import bisect_left , bisect_right from heapq import heappop , heappush , heapify , nlargestfrom copy import deepcopymod = 10 ** 9 + 7 INF = float ( ' inf ' ) def inp ( ) : return int ( sys . stdin . readline ( ) ) def inpl ( ) : return list ( map ( int , sys . stdin . readline ( ) . split ( ) ) ) def inpl_1 ( ) : return list ( map ( lambda x : int ( x ) - 1 , sys . stdin . readline ( ) . split ( ) ) )   MM = 10 ** 10 n , m = inpl ( ) a = inpl ( ) c = inpl ( ) q = [ ] NEW_LINE


import java . util . * ; public class Solution { public static void main ( String [ ] args ) { Scanner s = new Scanner ( System . in ) ; int t = s . nextInt ( ) ; for ( int i = 0 ; i < t ; i ++ ) { int n = s . nextInt ( ) ; int a [ ] = new int [ n ] ; for ( int j = 0 ; j < n ; j ++ ) a [ j ] = s . nextInt ( ) ; Arrays . sort ( a ) ; int c [ ] = new int [ n ] ; int p = 0 ; for ( int g = n - 1 ; g >= 0 ; g -- ) { c [ p ] = a [ g ] ; p ++ ; } int b [ ] = new int [ n ] ; for ( int k = 0 ; k < n ; k ++ ) { b [ k ] = Math . min ( c [ k ] , ( k + 1 ) ) ; } int max = b [ 0 ] ; for ( int y = 0 ; y < n ; y ++ ) { if ( b [ y ] > max ) max = b [ y ] ; } System . out . println ( max ) ; } } }

for _ in range ( int ( input ( ) ) ) : n , A = int ( input ( ) ) , sorted ( ( int ( _ ) for _ in input ( ) . split ( ) ) ) print ( next ( ( i for i , a in enumerate ( A [ : : - 1 ] ) if i >= a ) , n ) ) NEW_LINE


k = int ( input ( ) )   for _ in range ( k ) :   n = int ( input ( ) ) planks_in = input ( ) planks = planks_in . split ( ) planks = list ( map ( int , planks ) ) planks . sort ( )   for i in range ( n ) : if planks [ i ] >= ( n - i ) : print ( n - i ) break NEW_LINE


def main_function ( ) : output_list = [ ] t = int ( input ( ) ) for i in range ( t ) : hash_list = [ 0 for i in range ( 1002 ) ] n = int ( input ( ) ) l = [ int ( i ) for i in input ( ) . split ( " ▁ " ) ] for i in range ( len ( l ) ) : hash_list [ l [ i ] ] += 1 count = 0 for i in range ( len ( hash_list ) ) : j = len ( hash_list ) - 1 - i NEW_LINE


for _ in range ( int ( input ( ) ) ) : n = int ( input ( ) ) l = [ int ( i ) for i in input ( ) . split ( ) ] mx = max ( l ) mxsq = 0 for i in range ( 1 , mx + 1 ) : c = 0 for j in l : if j >= i : c += 1 if c >= i : mxsq = max ( mxsq , i ) print ( mxsq ) NEW_LINE


def sol ( a : list ) : n = len ( a ) a . sort ( reverse = True ) ans = 0   for i in range ( n ) : if a [ i ] >= i + 1 : ans = i + 1 else : break print ( ans )     n = int ( input ( ) ) for i in range ( n ) : z = int ( input ( ) ) x = list ( map ( int , input ( ) . split ( ) ) ) sol ( x ) NEW_LINE


import java . util . * ; import java . util . Arrays ; public class program { public static void main ( String args [ ] ) { Scanner sc = new Scanner ( System . in ) ; int t = sc . nextInt ( ) ; for ( int i = 0 ; i < t ; i ++ ) { int n = sc . nextInt ( ) ; int [ ] a = new int [ n ] ; for ( int j = 0 ; j < n ; j ++ ) { a [ j ] = sc . nextInt ( ) ; } Arrays . sort ( a ) ; int k = 0 , count = 0 ; for ( int j = n - 1 ; j >= 0 ; j -- ) { if ( a [ j ] >= k + 1 ) { count ++ ; } k ++ ; } System . out . println ( count ) ; } } }


import java . io . * ; import java . util . * ; import javax . print . attribute . standard . Finishings ;   import java . math . * ;   public class Square { static final Random random = new Random ( ) ; static PrintWriter out = new PrintWriter ( ( System . out ) ) ; static Reader sc = new Reader ( ) ;   public static void main ( String args [ ] ) throws IOException { int t = sc . nextInt ( ) ; while ( t -- > 0 ) {


import java . util . ArrayList ; import java . util . Arrays ; import java . util . Scanner ;   public class Singleton_Pattern { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int k = sc . nextInt ( ) ; for ( int i = 0 ; i < k ; i ++ ) { int n = sc . nextInt ( ) ; int x [ ] = new int [ n ] ; for ( int j = 0 ; j < n ; j ++ ) { x [ j ] = sc . nextInt ( ) ; }   int res = 0 ; for ( int j = 1 ; j <= n ; j ++ ) { int check = 0 ; int c = 0 ; for ( int l = 0 ; l < n ; l ++ ) { c ++ ; if ( j <= x [ l ] ) check ++ ; }


import java . util . Scanner ;    public class Bicycle { public static void main ( String [ ] args ) { Scanner input = new Scanner ( System . in ) ; int n = input . nextInt ( ) ; int k = input . nextInt ( ) ; input . nextLine ( ) ; int [ ] x = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) x [ i ] = input . nextInt ( ) ; int count = 1 ; int d = k ; boolean flag = true ; for ( int i = 1 ; ( i < n ) && flag ; i ++ ) { d -= x [ i ] - x [ i - 1 ] ; if ( d < 0 ) flag = false ; else if ( i != n - 1 && d >= ( x [ i + 1 ] - x [ i ] ) ) { continue ; } else { count ++ ; d = k ; } } count -- ; if ( flag ) System . out . println ( count ) ;   else System . out . println ( " - 1" ) ;   }   }

n , k = [ int ( i ) for i in input ( ) . split ( ) ] X = [ int ( i ) for i in input ( ) . split ( ) ] rem = kcnt = 1 for i in range ( len ( X ) - 1 ) : if X [ i + 1 ] - X [ i ] > rem : rem = k cnt += 1 if X [ i + 1 ] - X [ i ] > rem : print ( - 1 ) break rem -= X [ i + 1 ] - X [ i ] else : print ( cnt ) NEW_LINE


n , k = map ( int , input ( ) . split ( ) ) t = list ( map ( int , input ( ) . split ( ) ) ) l = [ 0 ] ch = 1 i = 0 p2 = 0 while i < n - 1 : pepe = 0 j = i + 1 while j < n : if t [ j ] - t [ i ] <= k : j += 1 else : c1 = j - 1 ch += 1 pepe = 5 break if pepe == 5 : i = j - 1 else : i += 1 if i in l : p2 = 5 break else : l . append ( i ) print ( ch if p2 == 0 else " - 1" ) NEW_LINE


n , k = ( int ( x ) for x in input ( ) . split ( ) ) x = [ int ( x ) for x in input ( ) . split ( ) ] flag = Trueif flag : for i in range ( 1 , n ) : if x [ i ] - x [ i - 1 ] > k : print ( - 1 ) flag = False breakif flag : ans = 1 stop = x [ - 1 ] - k i = 2 while i < n + 1 : if stop <= x [ 0 ] : break if x [ - i ] > stop : i += 1 elif x [ - i ] == stop : ans += 1 stop = x [ - i ] - k i += 1 else : ans += 1 stop = x [ - i + 1 ] - k   print ( ans ) NEW_LINE


n , k = map ( int , input ( ) . split ( " ▁ " ) )   x = list ( map ( int , input ( ) . split ( " ▁ " ) ) )   r = 1   cK = k   for i in range ( n ) :   try :   rr = x [ i + 1 ] - x [ i ]   if k < rr :   r = - 1   break   if rr <= cK :   cK -= rr   else :   r += 1   cK = k - rr   except :   break ;   print ( r )       NEW_LINE


n , k = list ( map ( int , input ( ) . split ( ) ) ) x = list ( map ( int , input ( ) . split ( ) ) ) dists = [ x [ i ] - x [ i - 1 ] for i in range ( 1 , n ) ] if max ( dists ) > k : print ( - 1 ) else : cnt , rest = 0 , 0 for dist in dists : if rest < dist : cnt += 1 rest = k - dist else : rest -= dist print ( cnt ) NEW_LINE


import java . io . BufferedInputStream ; import java . io . IOException ; import java . io . InputStream ; import java . io . InputStreamReader ; import java . util . LinkedList ; import java . util . List ; import java . util . Scanner ; import java . util . StringTokenizer ; import java . util . TreeSet ;   public class Main extends Thread {


import java . util . * ; public class GregsWorkout { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; String trains [ ] = { " chest " , " biceps " , " back " } ; int n = in . nextInt ( ) ; int arr [ ] = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) arr [ i ] = in . nextInt ( ) ; int sum [ ] = new int [ 3 ] ; for ( int i = 0 ; i < n ; i ++ ) { sum [ i % 3 ] += arr [ i ] ; } int maxI = 0 ; for ( int i = 1 ; i < sum . length ; i ++ ) if ( sum [ i ] > sum [ maxI ] ) maxI = i ; System . out . println ( trains [ maxI ] ) ; } }

n = int ( input ( ) ) a = list ( map ( int , input ( ) . split ( ) ) ) l = [ sum ( a [ i : : 3 ] ) for i in [ 0 , 1 , 2 ] ] print ( [ " chest " , " biceps " , " back " ] [ l . index ( max ( l ) ) ] ) NEW_LINE


n = int ( input ( ) ) array = list ( map ( int , input ( ) . split ( ) ) ) answer = [ " chest " , " biceps " , " back " , 0 , 0 , 0 ]   for i in range ( n ) : if i % 3 == 0 : answer [ 3 ] += array [ i ] elif i % 3 == 1 : answer [ 4 ] += array [ i ] elif i % 3 == 2 : answer [ 5 ] += array [ i ]   print ( answer [ answer . index ( max ( answer [ 3 : ] ) ) - 3 ] ) NEW_LINE


n = int ( input ( ) ) l = list ( map ( int , input ( ) . split ( ) ) ) a , b , c = 0 , 0 , 0 for i in range ( n ) : if i % 3 == 0 : a += l [ i ] elif i % 3 == 1 : b += l [ i ] else : c += l [ i ] if max ( a , b , c ) == a : print ( ' chest ' ) elif max ( a , b , c ) == b : print ( ' biceps ' ) else : print ( ' back ' ) NEW_LINE


n = int ( input ( ) ) l = list ( map ( int , input ( ) . split ( ) ) ) a , b , c = 0 , 0 , 0 for i in range ( n ) : if i % 3 == 0 : a += l [ i ] elif i % 3 == 1 : b += l [ i ] else : c += l [ i ] if a >= b and a >= c : print ( " chest " ) elif b >= a and b >= c : print ( " biceps " ) else : print ( " back " ) NEW_LINE


import java . util . * ;   public class Main {   public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int n = scanner . nextInt ( ) ; int [ ] a = new int [ n ] ; int chest = 0 , bicep = 0 , back = 0 , k = 0 ; for ( int i = 0 ; i < n ; i ++ ) { a [ i ] = scanner . nextInt ( ) ; if ( k == 0 ) chest += a [ i ] ; else if ( k == 1 ) bicep += a [ i ] ; else { back += a [ i ] ; k = - 1 ; } k ++ ; } int max = Math . max ( chest , Math . max ( bicep , back ) ) ; if ( max == chest ) System . out . println ( " chest " ) ; else if ( max == bicep ) System . out . println ( " biceps " ) ; else System . out . println ( " back " ) ;   } }


import java . util . Scanner ;   public class A255 {   public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int i = 0 ; int a = 0 , b = 0 , c = 0 ; while ( i <= n ) { a += sc . nextInt ( ) ; i ++ ; if ( i == n ) break ; b += sc . nextInt ( ) ; i ++ ; if ( i == n ) break ; c += sc . nextInt ( ) ; i ++ ; if ( i == n ) break ; } if ( a > b && a > c ) System . out . println ( " chest " ) ; if ( b > a && b > c ) System . out . println ( " biceps " ) ; if ( c > a && c > b ) System . out . println ( " back " ) ; } }


import java . lang . * ; import java . util . * ; import java . io . * ;   public class _temp2 { public static void main ( String [ ] args ) throws NumberFormatException , IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; int n = Integer . parseInt ( br . readLine ( ) ) ; String [ ] st = br . readLine ( ) . split ( " ▁ " ) ; int [ ] a = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { a [ i ] = Integer . parseInt ( st [ i ] ) ; } int chest = 0 , bicep = 0 , back = 0 ; int state = 0 ; for ( int i = 0 ; i < n ; i ++ ) { state = state % 3 ; if ( state == 0 ) { chest += a [ i ] ; } else if ( state == 1 ) { bicep += a [ i ] ; } else if ( state == 2 ) { back += a [ i ] ; } state ++ ; } if ( chest > bicep ) { if ( chest > back ) { System . out . println ( " chest " ) ; } else { System . out . println ( " back " ) ; } } else { if ( bicep > back ) { System . out . println ( " biceps " ) ; } else { System . out . println ( " back " ) ; } } } }


import java . util . Scanner ;   public class A255 { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int n = scanner . nextInt ( ) , ch = 0 , bic = 0 , back = 0 ; int a [ ] = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { a [ i ] = scanner . nextInt ( ) ; } for ( int i = 0 ; i < n ; i += 3 ) { ch += a [ i ] ; } for ( int i = 1 ; i < n ; i += 3 ) { bic += a [ i ] ; } for ( int i = 2 ; i < n ; i += 3 ) { back += a [ i ] ; } int max = Math . max ( Math . max ( ch , bic ) , back ) ; if ( max == ch ) { System . out . println ( " chest " ) ; } else if ( max == bic ) { System . out . println ( " biceps " ) ; } else { System . out . println ( " back " ) ; } } }


import java . util . * ; public class TernaryLogic {   public static void main ( String [ ] args ) {

a , b = map ( int , input ( ) . split ( ) ) sum = 0 k = 1   while a or b : sum += k * ( ( ( b % 3 ) - ( a % 3 ) ) % 3 ) a //= 3 b //= 3 k *= 3 print ( sum ) NEW_LINE


import java . util . * ; public class ternary_logic { long ter ( int x ) { String s = " " ; if ( x == 0 ) s = "0" ; while ( x > 0 ) { s = x % 3 + s ; x /= 3 ; } return Long . valueOf ( s ) ; } public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; int a = in . nextInt ( ) ; int c = in . nextInt ( ) ; ternary_logic ob = new ternary_logic ( ) ; long at = ob . ter ( a ) ; long ct = ob . ter ( c ) ;


import java . util . Scanner ; import java . util . Arrays ; public class Codechef { public static void main ( String [ ] args ) throws java . lang . Exception { try { Scanner sc = new Scanner ( System . in ) ; int a , b , i , n ; long k = 0 ; String s , w , c ; s = w = c = " " ; a = sc . nextInt ( ) ; b = sc . nextInt ( ) ; while ( a > 0 ) { n = a % 3 ; s = n + s ; a = a / 3 ; } while ( b > 0 ) { n = b % 3 ; w = n + w ; b = b / 3 ; } n = s . length ( ) ; for ( i = 0 ; i < 20 - n ; i ++ ) s = "0" + s ; n = w . length ( ) ; for ( i = 0 ; i < 20 - n ; i ++ ) w = "0" + w ;


import java . io . * ; import java . util . * ;   public class E {   public static void main ( String [ ] args ) { FastScanner in = new FastScanner ( ) ; PrintWriter out = new PrintWriter ( System . out ) ; int t = in . nextInt ( ) ; while ( t -- > 0 ) { int n = in . nextInt ( ) , xx = in . nextInt ( ) ; int d = 0 , h = 0 ; int maxDiff = 0 , max = 0 ; for ( int i = 0 ; i < n ; i ++ ) { d = in . nextInt ( ) ; h = in . nextInt ( ) ; maxDiff = Math . max ( maxDiff , d - h ) ; max = Math . max ( max , d ) ; } if ( maxDiff == 0 && max < xx ) out . println ( - 1 ) ; else if ( max >= xx ) out . println ( 1 ) ; else out . println ( 1 + ( ( xx - max ) + ( maxDiff - 1 ) ) / maxDiff ) ; } out . flush ( ) ; }

t = int ( input ( ) ) for _ in range ( t ) : n , l = map ( int , input ( ) . split ( ) ) a = [ ] m = 0 ans = 10 ** 10 for i in range ( n ) : x , y = map ( int , input ( ) . split ( ) ) m = max ( m , x ) a . append ( [ x , y ] ) d = 0 for i in range ( n ) : if a [ i ] [ 0 ] > a [ i ] [ 1 ] : d = max ( d , a [ i ] [ 0 ] - a [ i ] [ 1 ] ) if d == 0 : if m < l : print ( - 1 ) else : print ( 1 ) else : l = l - m ans = max ( l // d + bool ( l % d ) + 1 , 1 ) print ( ans ) NEW_LINE


import mathfor _ in range ( int ( input ( ) ) ) : n , m = map ( int , input ( ) . split ( ) ) maxDH = - 10 ** 9 arr = [ ] for i in range ( n ) : a , b = map ( int , input ( ) . split ( ) ) maxDH = max ( maxDH , a - b ) arr . append ( [ a , b ] ) res = 1 maxD = - 1 for i in arr : maxD = max ( maxD , i [ 0 ] ) m -= maxD if m > 0 : if maxDH <= 0 : res = - 1 else : res += ( m + maxDH - 1 ) // maxDH print ( res ) NEW_LINE


from collections import defaultdict , deque , Counterfrom sys import stdin , stdoutfrom heapq import heappush , heappopimport mathimport ioimport osimport mathimport bisect   NEW_LINE


import sys , os , ioimport math , bisect , operatorinf , mod = float ( ' inf ' ) , 10 ** 9 + 7 NEW_LINE


import math , sys , bisect , heapq , osfrom collections import defaultdict , Counter , dequefrom itertools import groupby , accumulatefrom functools import lru_cache NEW_LINE


import java . io . * ; import java . util . * ;   public class Main { public static void main ( String [ ] args ) throws IOException {


import java . util . * ;    public class B_Zmei_Gorynich { public static void main ( String args [ ] ) { Scanner sc = new Scanner ( System . in ) ; int q = sc . nextInt ( ) ; while ( q -- > 0 ) { int n = sc . nextInt ( ) ; int x = sc . nextInt ( ) ; IntegerPair ar [ ] = new IntegerPair [ n ] ; int i = 0 ; int max = - 1 ; for ( i = 0 ; i < n ; i ++ ) { int a = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; max = Math . max ( max , a ) ; IntegerPair temp = new IntegerPair ( a , b ) ; ar [ i ] = temp ; } Arrays . sort ( ar ) ; int dif = ar [ 0 ] . first ( ) - ar [ 0 ] . second ( ) ; if ( max >= x ) { System . out . println ( 1 ) ; continue ; } if ( dif <= 0 ) { System . out . println ( - 1 ) ; continue ; } int ans = ( ( x - 1 - max ) / dif ) + 2 ; System . out . println ( ans ) ; } } } class IntegerPair implements Comparable < IntegerPair > { Integer f ; Integer s ; Integer d ; public IntegerPair ( Integer first , Integer second ) { f = first ; s = second ; d = second - first ; } public int compareTo ( IntegerPair o ) { if ( this . diff ( ) . equals ( o . diff ( ) ) ) { return o . first ( ) - this . first ( ) ; } else { return this . diff ( ) - o . diff ( ) ; } } public Integer diff ( ) { return d ; } public Integer first ( ) { return f ; } public Integer second ( ) { return s ; } }


import java . util . Scanner ; import java . util . Arrays ; public class Main { public static void main ( String args [ ] ) { Scanner scan = new Scanner ( System . in ) ; int n = scan . nextInt ( ) ; int m = scan . nextInt ( ) ; int [ ] arr = new int [ n ] ; int c = 0 ; for ( int i = 0 ; i < n ; i ++ ) { int a = scan . nextInt ( ) ; if ( a < 0 ) { arr [ i ] = a ; c ++ ; } } int sum = 0 ; Arrays . sort ( arr ) ; if ( c >= m ) { for ( int i = 0 ; i < m ; i ++ ) { sum = sum + Math . abs ( arr [ i ] ) ; } } else { for ( int i = 0 ; i < arr . length ; i ++ ) { sum = sum + Math . abs ( arr [ i ] ) ; } } System . out . print ( sum ) ; } }

import sysfrom math import * input = sys . stdin . readline   def solve ( n , k , arr ) : arr . sort ( ) tot = 0 for i in range ( n ) : if i + 1 > k : print ( tot ) return else : if arr [ i ] <= 0 : tot += abs ( arr [ i ] ) else : print ( tot ) return else : print ( tot )   NEW_LINE


n , m = map ( int , input ( ) . split ( ) ) lst = [ * map ( int , input ( ) . split ( ) ) ] lst . sort ( )   total = 0   for num in lst [ : m ] : if num > 0 : break else : total += numprint ( abs ( total ) ) NEW_LINE


n , m = map ( int , input ( ) . split ( ) ) l = sorted ( list ( map ( int , input ( ) . split ( ) ) ) ) c = 0 s = 0 for i in l : if ( i < 0 and c < m ) : s += i c += 1 else : break print ( - s ) NEW_LINE


import math   def solve ( ) : a , b = list ( map ( int , input ( ) . split ( ) ) ) arr = [ int ( i ) for i in input ( ) . split ( ) ] arr . sort ( )   sum = 0   for i in range ( b ) : if arr [ i ] > 0 : break sum += - 1 * arr [ i ]   return sum         print ( solve ( ) ) NEW_LINE


n , m = map ( int , input ( ) . split ( ) ) a = list ( map ( int , input ( ) . split ( ) ) ) count = mans = 0 for i in range ( len ( a ) ) : k = min ( a ) if k < 0 : ans = ans - k count -= 1 a [ a . index ( k ) ] = 1 else : break if count == 0 : breakprint ( ans ) NEW_LINE


import java . util . Arrays ; import java . util . Comparator ; import java . util . Scanner ;   public class Sale { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int n = scanner . nextInt ( ) ; int m = scanner . nextInt ( ) ; scanner . nextLine ( ) ;   int [ ] arr = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { arr [ i ] = scanner . nextInt ( ) ; }   int [ ] ints = Arrays . stream ( arr ) . filter ( e -> e < 0 ) . sorted ( ) . limit ( m ) . toArray ( ) ;   int gain = 0 ; for ( int i = ints . length - 1 ; i >= 0 ; i -- ) { int item = ints [ i ] ; if ( item < 0 ) { gain += Math . abs ( item ) ; } }   System . out . println ( gain ) ;    } }


import java . util . * ; public class MyClass { public static void main ( String args [ ] ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int m = sc . nextInt ( ) ; int [ ] arr = new int [ n ] ; int s = 0 ; for ( int i = 0 ; i < n ; i ++ ) { arr [ i ] = sc . nextInt ( ) ; } Arrays . sort ( arr ) ; for ( int i = 0 ; i < m ; i ++ ) { if ( arr [ i ] >= 0 ) break ; s = s + arr [ i ] ; } System . out . println ( - s ) ; } }


import java . util . * ; public class Sale { public static void main ( String arg [ ] ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int m = sc . nextInt ( ) ; int [ ] ar = new int [ n ] ;    for ( int i = 0 ; i < n ; i ++ ) { ar [ i ] = sc . nextInt ( ) ; }   Arrays . sort ( ar ) ; int res = 0 ;   for ( int i = 0 ; i < m ; i ++ ) { if ( ar [ i ] < 0 ) res += ar [ i ] ; }   System . out . println ( Math . abs ( res ) ) ;   }   }