public static void main ( String [ ] args ) {
  int n , temp , min , x ;
  int c [ ] = new int [ 10 ] ;
  boolean w [ ] = new boolean [ 10010 ] ;
  Arrays . fill ( w , false ) ;
  Scanner in = new Scanner ( System . in ) ;
  n = in . nextInt ( ) ;
  for ( int i = 0 ;
  i < n ;
  i ++ ) {
    in . nextLine ( ) ;
    for ( int j = 0 ;
    j < 4 ;
    j += 2 ) {
      String a = in . nextLine ( ) ;
      c [ j ] = a . charAt ( 0 ) - '0' ;
      c [ j + 1 ] = a . charAt ( 1 ) - '0' ;
    }
    temp = c [ 2 ] ;
    c [ 2 ] = c [ 3 ] ;
    c [ 3 ] = temp ;
    min = 99999 ;
    for ( int j = 0 ;
    j < 4 ;
    j ++ ) c [ j + 4 ] = c [ j ] ;
    for ( int j = 0 ;
    j < 4 ;
    j ++ ) {
      x = 0 ;
      for ( int r = j ;
      r < j + 4 ;
      r ++ ) {
        x = x * 10 + c [ r ] ;
      }
      if ( x < min ) {
        min = x ;
      }
    }
    w [ min ] = true ;
  }
  int ans = 0 ;
  for ( int i = 0 ;
  i <= 9999 ;
  i ++ ) {
    if ( w [ i ] ) ans ++ ;
  }
  System . out . println ( ans ) ;
}

public static void main ( String [ ] args ) { int n , temp , min , x ; int c [ ] = new int [ 10 ] ; boolean w [ ] = new boolean [ 10010 ] ; Arrays . fill ( w , false ) ; Scanner in = new Scanner ( System . in ) ; n = in . nextInt ( ) ; for ( int i = 0 ; i < n ; i ++ ) { in . nextLine ( ) ; for ( int j = 0 ; j < 4 ; j += 2 ) { String a = in . nextLine ( ) ; c [ j ] = a . charAt ( 0 ) - '0' ; c [ j + 1 ] = a . charAt ( 1 ) - '0' ; } temp = c [ 2 ] ; c [ 2 ] = c [ 3 ] ; c [ 3 ] = temp ; min = 99999 ; for ( int j = 0 ; j < 4 ; j ++ ) c [ j + 4 ] = c [ j ] ; for ( int j = 0 ; j < 4 ; j ++ ) { x = 0 ; for ( int r = j ; r < j + 4 ; r ++ ) { x = x * 10 + c [ r ] ; } if ( x < min ) { min = x ; } } w [ min ] = true ; } int ans = 0 ; for ( int i = 0 ; i <= 9999 ; i ++ ) { if ( w [ i ] ) ans ++ ; } System . out . println ( ans ) ; }
(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: (integral_type) declarator: (variable_declarator name: (identifier)) declarator: (variable_declarator name: (identifier)) declarator: (variable_declarator name: (identifier)) declarator: (variable_declarator name: (identifier))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) dimensions: (dimensions) value: (array_creation_expression type: (integral_type) dimensions: (dimensions_expr (decimal_integer_literal))))) (local_variable_declaration type: (boolean_type) declarator: (variable_declarator name: (identifier) dimensions: (dimensions) value: (array_creation_expression type: (boolean_type) dimensions: (dimensions_expr (decimal_integer_literal))))) (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier) (false)))) (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)))))) (expression_statement (assignment_expression left: (identifier) right: (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 (expression_statement (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: (decimal_integer_literal)) update: (assignment_expression left: (identifier) right: (decimal_integer_literal)) 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: (array_access array: (identifier) index: (identifier)) right: (binary_expression left: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (decimal_integer_literal))) right: (character_literal)))) (expression_statement (assignment_expression left: (array_access array: (identifier) index: (binary_expression left: (identifier) right: (decimal_integer_literal))) right: (binary_expression left: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (decimal_integer_literal))) right: (character_literal)))))) (expression_statement (assignment_expression left: (identifier) right: (array_access array: (identifier) index: (decimal_integer_literal)))) (expression_statement (assignment_expression left: (array_access array: (identifier) index: (decimal_integer_literal)) right: (array_access array: (identifier) index: (decimal_integer_literal)))) (expression_statement (assignment_expression left: (array_access array: (identifier) index: (decimal_integer_literal)) right: (identifier))) (expression_statement (assignment_expression left: (identifier) right: (decimal_integer_literal))) (for_statement init: (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) condition: (binary_expression left: (identifier) right: (decimal_integer_literal)) update: (update_expression (identifier)) body: (expression_statement (assignment_expression left: (array_access array: (identifier) index: (binary_expression left: (identifier) right: (decimal_integer_literal))) right: (array_access array: (identifier) index: (identifier))))) (for_statement init: (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) condition: (binary_expression left: (identifier) right: (decimal_integer_literal)) update: (update_expression (identifier)) body: (block (expression_statement (assignment_expression left: (identifier) right: (decimal_integer_literal))) (for_statement init: (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (identifier))) condition: (binary_expression left: (identifier) right: (binary_expression left: (identifier) right: (decimal_integer_literal))) update: (update_expression (identifier)) body: (block (expression_statement (assignment_expression left: (identifier) right: (binary_expression left: (binary_expression left: (identifier) right: (decimal_integer_literal)) right: (array_access array: (identifier) index: (identifier))))))) (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (identifier))) consequence: (block (expression_statement (assignment_expression left: (identifier) right: (identifier))))))) (expression_statement (assignment_expression left: (array_access array: (identifier) index: (identifier)) right: (true))))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) (for_statement init: (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) condition: (binary_expression left: (identifier) right: (decimal_integer_literal)) update: (update_expression (identifier)) body: (block (if_statement condition: (parenthesized_expression (array_access array: (identifier) index: (identifier))) consequence: (expression_statement (update_expression (identifier)))))) (expression_statement (method_invocation object: (field_access object: (identifier) field: (identifier)) name: (identifier) arguments: (argument_list (identifier))))))