Language: C++

#pragma region include
#include "bits/stdc++.h"
#define ALL(obj) (obj).begin(),(obj).end()
#define RALL(obj) (obj).rbegin(),(obj).rend()
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define REPR(i, n) for(int i = (int)(n); i >= 0; i--)
#define FOR(i,n,m) for(int i = (int)(n); i < int(m); i++)
#define MOD (int)(1e9+7)
#define INF (int)(1e9)
#define LLINF (int)(4e18)
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
void input() {}
template<typename... R> void input(int& f, R&... r) { scanf("%d", &f); input(r...); }
template<typename... R> void input(double& f, R&... r) { scanf("%lf", &f); input(r...); }
template<typename... R> void input(ll& f, R&... r) { scanf("%lld", &f); input(r...); }
template<typename... R> void input(char& f, R&... r) { scanf("%c", &f); input(r...); }
template<typename... R> void input(basic_string<char>& f, R&... r) { cin >> f; input(r...); }
template<typename T, typename... R> void input(vector<T>& f, R&... r) { REP(i, f.size())input(f[i]); input(r...); }
#pragma endregion
    
int main() {
    int N;
    string s1, s2; input(N, s1, s2);
    ll ans = 1;
    int i = 0;
    bool two;
    if (s1[0] == s2[0]) {
        ans *= 3;
        i++;
        two = false;
    }
    else {
        ans *= 6;
        i += 2;
        two = true;
    }
    for (; i < N; i++) {
        if (s1[i] == s2[i]) {
            if (two) {
                ans *= 1;
            }
            else {
                ans *= 2;
            }
            ans %= MOD;
            two = false;
        }
        else {
            if (two) {
                ans *= 3;
            }
            else {
                ans *= 2;
            }
            i++;
            ans %= MOD;
            two = true;
        }
    }
    cout << ans << endl;
    getchar(); getchar();
}

Compiler output:
a.cc: In instantiation of 'void input(int&, R& ...) [with R = {std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >}]':
a.cc:27:25:   required from here
   27 |     string s1, s2; input(N, s1, s2);
      |                    ~~~~~^~~~~~~~~~~
a.cc:17:77: error: no matching function for call to 'input(std::__cxx11::basic_string<char>&, std::__cxx11::basic_string<char>&)'
   17 | template<typename... R> void input(int& f, R&... r) { scanf("%d", &f); input(r...); }
      |                                                                        ~~~~~^~~~~~
a.cc:17:30: note: candidate: 'template<class ... R> void input(int&, R& ...)'
   17 | template<typename... R> void input(int& f, R&... r) { scanf("%d", &f); input(r...); }
      |                              ^~~~~
a.cc:17:30: note:   template argument deduction/substitution failed:
a.cc:17:77: note:   cannot convert 'r#0' (type 'std::__cxx11::basic_string<char>') to type 'int&'
   17 | template<typename... R> void input(int& f, R&... r) { scanf("%d", &f); input(r...); }
      |                                                                        ~~~~~^~~~~~
a.cc:16:6: note: candidate: 'void input()'
   16 | void input() {}
      |      ^~~~~
a.cc:16:6: note:   candidate expects 0 arguments, 2 provided