public static void main ( String [ ] args ) {
  Scanner sc = new Scanner ( System . in ) ;
  int t = sc . nextInt ( ) ;
  while ( t -- != 0 ) {
    int len = sc . nextInt ( ) ;
    sc . nextLine ( ) ;
    String str = sc . nextLine ( ) ;
    int top0 = str . indexOf ( "0" ) ;
    int top1 = str . indexOf ( "1" ) ;
    int end0 = str . lastIndexOf ( "0" ) ;
    int end1 = str . lastIndexOf ( "1" ) ;
    if ( top0 == - 1 ) {
      System . out . println ( 2 * len ) ;
      continue ;
    }
    if ( top1 == - 1 ) {
      System . out . println ( len ) ;
      continue ;
    }
    int temp1 = Math . abs ( top0 - top1 ) + 1 ;
    int temp2 = Math . abs ( top0 - end1 ) + 1 ;
    int temp3 = Math . abs ( top1 - end0 ) + 1 ;
    int temp4 = Math . abs ( top1 - end1 ) + 1 ;
    int max = Math . max ( Math . max ( temp1 , temp2 ) , Math . max ( temp3 , temp4 ) ) ;
    System . out . println ( max * 2 ) ;
  }
}

public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int t = sc . nextInt ( ) ; while ( t -- != 0 ) { int len = sc . nextInt ( ) ; sc . nextLine ( ) ; String str = sc . nextLine ( ) ; int top0 = str . indexOf ( "0" ) ; int top1 = str . indexOf ( "1" ) ; int end0 = str . lastIndexOf ( "0" ) ; int end1 = str . lastIndexOf ( "1" ) ; if ( top0 == - 1 ) { System . out . println ( 2 * len ) ; continue ; } if ( top1 == - 1 ) { System . out . println ( len ) ; continue ; } int temp1 = Math . abs ( top0 - top1 ) + 1 ; int temp2 = Math . abs ( top0 - end1 ) + 1 ; int temp3 = Math . abs ( top1 - end0 ) + 1 ; int temp4 = Math . abs ( top1 - end1 ) + 1 ; int max = Math . max ( Math . max ( temp1 , temp2 ) , Math . max ( temp3 , temp4 ) ) ; System . out . println ( max * 2 ) ; } }
(method_declaration (modifiers) type: (void_type) name: (identifier) parameters: (formal_parameters (formal_parameter type: (array_type element: (type_identifier) dimensions: (dimensions)) name: (identifier))) body: (block (local_variable_declaration type: (type_identifier) declarator: (variable_declarator name: (identifier) value: (object_creation_expression type: (type_identifier) arguments: (argument_list (field_access object: (identifier) field: (identifier)))))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)))) (while_statement condition: (parenthesized_expression (binary_expression left: (update_expression (identifier)) right: (decimal_integer_literal))) 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))) (local_variable_declaration type: (type_identifier) declarator: (variable_declarator name: (identifier) value: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (string_literal))))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (string_literal))))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (string_literal))))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (string_literal))))) (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (unary_expression operand: (decimal_integer_literal)))) consequence: (block (expression_statement (method_invocation object: (field_access object: (identifier) field: (identifier)) name: (identifier) arguments: (argument_list (binary_expression left: (decimal_integer_literal) right: (identifier))))) (continue_statement))) (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (unary_expression operand: (decimal_integer_literal)))) consequence: (block (expression_statement (method_invocation object: (field_access object: (identifier) field: (identifier)) name: (identifier) arguments: (argument_list (identifier)))) (continue_statement))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (binary_expression left: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (binary_expression left: (identifier) right: (identifier)))) right: (decimal_integer_literal)))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (binary_expression left: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (binary_expression left: (identifier) right: (identifier)))) right: (decimal_integer_literal)))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (binary_expression left: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (binary_expression left: (identifier) right: (identifier)))) right: (decimal_integer_literal)))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (binary_expression left: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (binary_expression left: (identifier) right: (identifier)))) right: (decimal_integer_literal)))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier) (identifier))) (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier) (identifier))))))) (expression_statement (method_invocation object: (field_access object: (identifier) field: (identifier)) name: (identifier) arguments: (argument_list (binary_expression left: (identifier) right: (decimal_integer_literal)))))))))