public static void main ( String [ ] args ) throws IOException {
  BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ;
  String s1 = br . readLine ( ) ;
  String s2 = br . readLine ( ) ;
  String s3 = br . readLine ( ) ;
  s1 = s1 . replaceAll ( "-|;|_" , "" ) . toLowerCase ( ) ;
  s2 = s2 . replaceAll ( "-|;|_" , "" ) . toLowerCase ( ) ;
  s3 = s3 . replaceAll ( "-|;|_" , "" ) . toLowerCase ( ) ;
  String [ ] ss = new String [ 6 ] ;
  ss [ 0 ] = s1 + s2 + s3 ;
  ss [ 1 ] = s1 + s3 + s2 ;
  ss [ 2 ] = s2 + s1 + s3 ;
  ss [ 3 ] = s2 + s3 + s1 ;
  ss [ 4 ] = s3 + s1 + s2 ;
  ss [ 5 ] = s3 + s2 + s1 ;
  int n = Integer . parseInt ( br . readLine ( ) ) ;
  for ( int i = 0 ;
  i < n ;
  i ++ ) {
    String str = br . readLine ( ) ;
    str = str . replaceAll ( "-|;|_" , "" ) . toLowerCase ( ) ;
    int j ;
    for ( j = 0 ;
    j < 6 ;
    j ++ ) {
      if ( str . equals ( ss [ j ] ) ) {
        System . out . println ( "ACC" ) ;
        break ;
      }
    }
    if ( j < 6 ) {
      continue ;
    }
    System . out . println ( "WA" ) ;
  }
}

public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String s1 = br . readLine ( ) ; String s2 = br . readLine ( ) ; String s3 = br . readLine ( ) ; s1 = s1 . replaceAll ( " - | ; | _ " , " " ) . toLowerCase ( ) ; s2 = s2 . replaceAll ( " - | ; | _ " , " " ) . toLowerCase ( ) ; s3 = s3 . replaceAll ( " - | ; | _ " , " " ) . toLowerCase ( ) ; String [ ] ss = new String [ 6 ] ; ss [ 0 ] = s1 + s2 + s3 ; ss [ 1 ] = s1 + s3 + s2 ; ss [ 2 ] = s2 + s1 + s3 ; ss [ 3 ] = s2 + s3 + s1 ; ss [ 4 ] = s3 + s1 + s2 ; ss [ 5 ] = s3 + s2 + s1 ; int n = Integer . parseInt ( br . readLine ( ) ) ; for ( int i = 0 ; i < n ; i ++ ) { String str = br . readLine ( ) ; str = str . replaceAll ( " - | ; | _ " , " " ) . toLowerCase ( ) ; int j ; for ( j = 0 ; j < 6 ; j ++ ) { if ( str . equals ( ss [ j ] ) ) { System . out . println ( " ACC " ) ; break ; } } if ( j < 6 ) { continue ; } System . out . println ( " WA " ) ; } }
(method_declaration (modifiers) type: (void_type) name: (identifier) parameters: (formal_parameters (formal_parameter type: (array_type element: (type_identifier) dimensions: (dimensions)) name: (identifier))) (throws (type_identifier)) body: (block (local_variable_declaration type: (type_identifier) declarator: (variable_declarator name: (identifier) value: (object_creation_expression type: (type_identifier) arguments: (argument_list (object_creation_expression type: (type_identifier) arguments: (argument_list (field_access object: (identifier) field: (identifier)))))))) (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: (type_identifier) 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)))) (expression_statement (assignment_expression left: (identifier) right: (method_invocation object: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (string_literal) (string_literal))) name: (identifier) arguments: (argument_list)))) (expression_statement (assignment_expression left: (identifier) right: (method_invocation object: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (string_literal) (string_literal))) name: (identifier) arguments: (argument_list)))) (expression_statement (assignment_expression left: (identifier) right: (method_invocation object: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (string_literal) (string_literal))) name: (identifier) arguments: (argument_list)))) (local_variable_declaration type: (array_type element: (type_identifier) dimensions: (dimensions)) declarator: (variable_declarator name: (identifier) value: (array_creation_expression type: (type_identifier) dimensions: (dimensions_expr (decimal_integer_literal))))) (expression_statement (assignment_expression left: (array_access array: (identifier) index: (decimal_integer_literal)) right: (binary_expression left: (binary_expression left: (identifier) right: (identifier)) right: (identifier)))) (expression_statement (assignment_expression left: (array_access array: (identifier) index: (decimal_integer_literal)) right: (binary_expression left: (binary_expression left: (identifier) right: (identifier)) right: (identifier)))) (expression_statement (assignment_expression left: (array_access array: (identifier) index: (decimal_integer_literal)) right: (binary_expression left: (binary_expression left: (identifier) right: (identifier)) right: (identifier)))) (expression_statement (assignment_expression left: (array_access array: (identifier) index: (decimal_integer_literal)) right: (binary_expression left: (binary_expression left: (identifier) right: (identifier)) right: (identifier)))) (expression_statement (assignment_expression left: (array_access array: (identifier) index: (decimal_integer_literal)) right: (binary_expression left: (binary_expression left: (identifier) right: (identifier)) right: (identifier)))) (expression_statement (assignment_expression left: (array_access array: (identifier) index: (decimal_integer_literal)) right: (binary_expression left: (binary_expression left: (identifier) right: (identifier)) right: (identifier)))) (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)))))) (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 (local_variable_declaration type: (type_identifier) declarator: (variable_declarator name: (identifier) value: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)))) (expression_statement (assignment_expression left: (identifier) right: (method_invocation object: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (string_literal) (string_literal))) name: (identifier) arguments: (argument_list)))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier))) (for_statement init: (assignment_expression left: (identifier) right: (decimal_integer_literal)) condition: (binary_expression left: (identifier) right: (decimal_integer_literal)) update: (update_expression (identifier)) body: (block (if_statement condition: (parenthesized_expression (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (array_access array: (identifier) index: (identifier))))) consequence: (block (expression_statement (method_invocation object: (field_access object: (identifier) field: (identifier)) name: (identifier) arguments: (argument_list (string_literal)))) (break_statement))))) (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (decimal_integer_literal))) consequence: (block (continue_statement))) (expression_statement (method_invocation object: (field_access object: (identifier) field: (identifier)) name: (identifier) arguments: (argument_list (string_literal))))))))