public static void main ( String [ ] $ ) {
  int [ ] order = new int [ 10 ] ;
  REPS ( 10 ) . forEach ( i -> order [ getInt ( ) ] = i ) ;
  ArrayList < E > m = new ArrayList < > ( ) ;
  for ( int i = getInt ( ) ;
  i > 0 ;
  -- i ) {
    String in = s . next ( ) ;
    char [ ] c = in . toCharArray ( ) ;
    for ( int j = 0 ;
    j < c . length ;
    ++ j ) {
      c [ j ] = ( char ) ( order [ c [ j ] - '0' ] + '0' ) ;
    }
    m . add ( new E ( in , Integer . parseInt ( String . valueOf ( c ) ) ) ) ;
  }
  m . stream ( ) . sorted ( Comparator . comparingInt ( E :: getL ) . thenComparingInt ( E :: getI ) ) . map ( E :: getT ) . forEach ( System . out :: println ) ;
}

public static void main ( String [ ] $ ) { int [ ] order = new int [ 10 ] ; REPS ( 10 ) . forEach ( i -> order [ getInt ( ) ] = i ) ; ArrayList < E > m = new ArrayList < > ( ) ; for ( int i = getInt ( ) ; i > 0 ; -- i ) { String in = s . next ( ) ; char [ ] c = in . toCharArray ( ) ; for ( int j = 0 ; j < c . length ; ++ j ) { c [ j ] = ( char ) ( order [ c [ j ] - '0' ] + '0' ) ; } m . add ( new E ( in , Integer . parseInt ( String . valueOf ( c ) ) ) ) ; } m . stream ( ) . sorted ( Comparator . comparingInt ( E :: getL ) . thenComparingInt ( E :: getI ) ) . map ( E :: getT ) . forEach ( System . out :: println ) ; }
(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: (array_type element: (integral_type) dimensions: (dimensions)) declarator: (variable_declarator name: (identifier) value: (array_creation_expression type: (integral_type) dimensions: (dimensions_expr (decimal_integer_literal))))) (expression_statement (method_invocation object: (method_invocation name: (identifier) arguments: (argument_list (decimal_integer_literal))) name: (identifier) arguments: (argument_list (lambda_expression parameters: (identifier) body: (assignment_expression left: (array_access array: (identifier) index: (method_invocation name: (identifier) arguments: (argument_list))) right: (identifier)))))) (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: (method_invocation name: (identifier) arguments: (argument_list)))) condition: (binary_expression left: (identifier) right: (decimal_integer_literal)) update: (update_expression (identifier)) body: (block (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: (array_type element: (integral_type) dimensions: (dimensions)) declarator: (variable_declarator name: (identifier) value: (method_invocation object: (identifier) name: (identifier) 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: (field_access object: (identifier) field: (identifier))) update: (update_expression (identifier)) body: (block (expression_statement (assignment_expression left: (array_access array: (identifier) index: (identifier)) right: (cast_expression type: (integral_type) value: (parenthesized_expression (binary_expression left: (array_access array: (identifier) index: (binary_expression left: (array_access array: (identifier) index: (identifier)) right: (character_literal))) right: (character_literal)))))))) (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (object_creation_expression type: (type_identifier) arguments: (argument_list (identifier) (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier)))))))))))) (expression_statement (method_invocation object: (method_invocation object: (method_invocation object: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)) name: (identifier) arguments: (argument_list (method_invocation object: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (method_reference (identifier) (identifier)))) name: (identifier) arguments: (argument_list (method_reference (identifier) (identifier)))))) name: (identifier) arguments: (argument_list (method_reference (identifier) (identifier)))) name: (identifier) arguments: (argument_list (method_reference (field_access object: (identifier) field: (identifier)) (identifier)))))))