static Queue < Integer > reverse ( Queue < Integer > q ) {
  int s = q . size ( ) ;
  Queue < Integer > ans = new LinkedList < > ( ) ;
  for ( int i = 0 ;
  i < s ;
  i ++ ) {
    for ( int j = 0 ;
    j < q . size ( ) - 1 ;
    j ++ ) {
      int x = q . peek ( ) ;
      q . remove ( ) ;
      q . add ( x ) ;
    }
    ans . add ( q . peek ( ) ) ;
    q . remove ( ) ;
  }
  return ans ;
}

static Queue < Integer > reverse ( Queue < Integer > q ) { int s = q . size ( ) ; Queue < Integer > ans = new LinkedList < > ( ) ; for ( int i = 0 ; i < s ; i ++ ) { for ( int j = 0 ; j < q . size ( ) - 1 ; j ++ ) { int x = q . peek ( ) ; q . remove ( ) ; q . add ( x ) ; } ans . add ( q . peek ( ) ) ; q . remove ( ) ; } return ans ; }
(method_declaration (modifiers) type: (generic_type (type_identifier) (type_arguments (type_identifier))) name: (identifier) parameters: (formal_parameters (formal_parameter type: (generic_type (type_identifier) (type_arguments (type_identifier))) name: (identifier))) body: (block (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)))) (local_variable_declaration type: (generic_type (type_identifier) (type_arguments (type_identifier))) declarator: (variable_declarator name: (identifier) value: (object_creation_expression type: (generic_type (type_identifier) (type_arguments)) arguments: (argument_list)))) (for_statement init: (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) condition: (binary_expression left: (identifier) right: (identifier)) update: (update_expression (identifier)) body: (block (for_statement init: (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) condition: (binary_expression left: (identifier) right: (binary_expression left: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)) right: (decimal_integer_literal))) update: (update_expression (identifier)) body: (block (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)))) (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list))) (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier)))))) (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (method_invocation object: (identifier) name: (identifier) arguments: (argument_list))))) (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list))))) (return_statement (identifier))))