public static void main ( String [ ] args ) throws IOException {
  Reader . init ( System . in ) ;
  int n = Reader . nextInt ( ) ;
  String s1 = Reader . next ( ) ;
  String s2 = Reader . next ( ) ;
  if ( n == 1 ) {
    System . out . println ( 3 ) ;
  }
  else {
    String d ;
    int i = 1 ;
    long a = 1 ;
    if ( s1 . charAt ( 0 ) == s2 . charAt ( 0 ) ) {
      d = "single" ;
      a = 3 ;
    }
    else {
      d = "double" ;
      i = 2 ;
      a = 6 ;
    }
    while ( i < n ) {
      if ( s1 . charAt ( i ) != s2 . charAt ( i ) ) {
        if ( d . compareTo ( "single" ) == 0 ) {
          a = ( ( a % 1000000007 ) * 2 ) % 1000000007 ;
        }
        else {
          a = ( ( a % 1000000007 ) * 3 ) % 1000000007 ;
        }
        i += 2 ;
        d = "double" ;
      }
      else {
        if ( d . compareTo ( "single" ) == 0 ) {
          a = ( ( a % 1000000007 ) * 2 ) % 1000000007 ;
        }
        d = "single" ;
        i ++ ;
      }
    }
    System . out . println ( a ) ;
  }
}

public static void main ( String [ ] args ) throws IOException { Reader . init ( System . in ) ; int n = Reader . nextInt ( ) ; String s1 = Reader . next ( ) ; String s2 = Reader . next ( ) ; if ( n == 1 ) { System . out . println ( 3 ) ; } else { String d ; int i = 1 ; long a = 1 ; if ( s1 . charAt ( 0 ) == s2 . charAt ( 0 ) ) { d = " single " ; a = 3 ; } else { d = " double " ; i = 2 ; a = 6 ; } while ( i < n ) { if ( s1 . charAt ( i ) != s2 . charAt ( i ) ) { if ( d . compareTo ( " single " ) == 0 ) { a = ( ( a % 1000000007 ) * 2 ) % 1000000007 ; } else { a = ( ( a % 1000000007 ) * 3 ) % 1000000007 ; } i += 2 ; d = " double " ; } else { if ( d . compareTo ( " single " ) == 0 ) { a = ( ( a % 1000000007 ) * 2 ) % 1000000007 ; } d = " single " ; i ++ ; } } System . out . println ( a ) ; } }
(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 (expression_statement (method_invocation object: (identifier) name: (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)))) (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)))) (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (decimal_integer_literal))) consequence: (block (expression_statement (method_invocation object: (field_access object: (identifier) field: (identifier)) name: (identifier) arguments: (argument_list (decimal_integer_literal))))) alternative: (block (local_variable_declaration type: (type_identifier) declarator: (variable_declarator name: (identifier))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) (if_statement condition: (parenthesized_expression (binary_expression left: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (decimal_integer_literal))) right: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (decimal_integer_literal))))) consequence: (block (expression_statement (assignment_expression left: (identifier) right: (string_literal))) (expression_statement (assignment_expression left: (identifier) right: (decimal_integer_literal)))) alternative: (block (expression_statement (assignment_expression left: (identifier) right: (string_literal))) (expression_statement (assignment_expression left: (identifier) right: (decimal_integer_literal))) (expression_statement (assignment_expression left: (identifier) right: (decimal_integer_literal))))) (while_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (identifier))) body: (block (if_statement condition: (parenthesized_expression (binary_expression left: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier))) right: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier))))) consequence: (block (if_statement condition: (parenthesized_expression (binary_expression left: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (string_literal))) right: (decimal_integer_literal))) consequence: (block (expression_statement (assignment_expression left: (identifier) right: (binary_expression left: (parenthesized_expression (binary_expression left: (parenthesized_expression (binary_expression left: (identifier) right: (decimal_integer_literal))) right: (decimal_integer_literal))) right: (decimal_integer_literal))))) alternative: (block (expression_statement (assignment_expression left: (identifier) right: (binary_expression left: (parenthesized_expression (binary_expression left: (parenthesized_expression (binary_expression left: (identifier) right: (decimal_integer_literal))) right: (decimal_integer_literal))) right: (decimal_integer_literal)))))) (expression_statement (assignment_expression left: (identifier) right: (decimal_integer_literal))) (expression_statement (assignment_expression left: (identifier) right: (string_literal)))) alternative: (block (if_statement condition: (parenthesized_expression (binary_expression left: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (string_literal))) right: (decimal_integer_literal))) consequence: (block (expression_statement (assignment_expression left: (identifier) right: (binary_expression left: (parenthesized_expression (binary_expression left: (parenthesized_expression (binary_expression left: (identifier) right: (decimal_integer_literal))) right: (decimal_integer_literal))) right: (decimal_integer_literal)))))) (expression_statement (assignment_expression left: (identifier) right: (string_literal))) (expression_statement (update_expression (identifier))))))) (expression_statement (method_invocation object: (field_access object: (identifier) field: (identifier)) name: (identifier) arguments: (argument_list (identifier))))))))