public static void main ( String [ ] args ) {
  Scanner scn = new Scanner ( System . in ) ;
  int t = scn . nextInt ( ) ;
  while ( t -- > 0 ) {
    int n = scn . nextInt ( ) ;
    String str = scn . next ( ) ;
    if ( str . equals ( "2020" ) ) {
      System . out . println ( "YES" ) ;
      continue ;
    }
    if ( str . substring ( 0 , 4 ) . equals ( "2020" ) || str . substring ( n - 4 , n ) . equals ( "2020" ) ) {
      System . out . println ( "YES" ) ;
      continue ;
    }
    if ( ( str . substring ( 0 , 3 ) + str . substring ( n - 1 , n ) ) . equals ( "2020" ) || ( str . substring ( 0 , 2 ) + str . substring ( n - 2 , n ) ) . equals ( "2020" ) || ( str . subSequence ( 0 , 1 ) + str . substring ( n - 3 , n ) ) . equals ( "2020" ) ) {
      System . out . println ( "YES" ) ;
      continue ;
    }
    System . out . println ( "NO" ) ;
  }
}

public static void main ( String [ ] args ) { Scanner scn = new Scanner ( System . in ) ; int t = scn . nextInt ( ) ; while ( t -- > 0 ) { int n = scn . nextInt ( ) ; String str = scn . next ( ) ; if ( str . equals ( "2020" ) ) { System . out . println ( " YES " ) ; continue ; } if ( str . substring ( 0 , 4 ) . equals ( "2020" ) || str . substring ( n - 4 , n ) . equals ( "2020" ) ) { System . out . println ( " YES " ) ; continue ; } if ( ( str . substring ( 0 , 3 ) + str . substring ( n - 1 , n ) ) . equals ( "2020" ) || ( str . substring ( 0 , 2 ) + str . substring ( n - 2 , n ) ) . equals ( "2020" ) || ( str . subSequence ( 0 , 1 ) + str . substring ( n - 3 , n ) ) . equals ( "2020" ) ) { System . out . println ( " YES " ) ; continue ; } System . out . println ( " NO " ) ; } }
(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)))) (local_variable_declaration type: (type_identifier) declarator: (variable_declarator name: (identifier) value: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)))) (if_statement condition: (parenthesized_expression (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (string_literal)))) consequence: (block (expression_statement (method_invocation object: (field_access object: (identifier) field: (identifier)) name: (identifier) arguments: (argument_list (string_literal)))) (continue_statement))) (if_statement condition: (parenthesized_expression (binary_expression left: (method_invocation object: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (decimal_integer_literal) (decimal_integer_literal))) name: (identifier) arguments: (argument_list (string_literal))) right: (method_invocation object: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (binary_expression left: (identifier) right: (decimal_integer_literal)) (identifier))) name: (identifier) arguments: (argument_list (string_literal))))) consequence: (block (expression_statement (method_invocation object: (field_access object: (identifier) field: (identifier)) name: (identifier) arguments: (argument_list (string_literal)))) (continue_statement))) (if_statement condition: (parenthesized_expression (binary_expression left: (binary_expression left: (method_invocation object: (parenthesized_expression (binary_expression left: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (decimal_integer_literal) (decimal_integer_literal))) right: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (binary_expression left: (identifier) right: (decimal_integer_literal)) (identifier))))) name: (identifier) arguments: (argument_list (string_literal))) right: (method_invocation object: (parenthesized_expression (binary_expression left: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (decimal_integer_literal) (decimal_integer_literal))) right: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (binary_expression left: (identifier) right: (decimal_integer_literal)) (identifier))))) name: (identifier) arguments: (argument_list (string_literal)))) right: (method_invocation object: (parenthesized_expression (binary_expression left: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (decimal_integer_literal) (decimal_integer_literal))) right: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (binary_expression left: (identifier) right: (decimal_integer_literal)) (identifier))))) name: (identifier) arguments: (argument_list (string_literal))))) consequence: (block (expression_statement (method_invocation object: (field_access object: (identifier) field: (identifier)) name: (identifier) arguments: (argument_list (string_literal)))) (continue_statement))) (expression_statement (method_invocation object: (field_access object: (identifier) field: (identifier)) name: (identifier) arguments: (argument_list (string_literal))))))))