#include using namespace std; using ll = long long; int N; string S, T; int ord[201010]; int main(void){ ios::sync_with_stdio(false); cin.tie(nullptr); cin >> N >> S >> T; bool f = true; for(int i = 0;i < N;i++){ f &= (S[i] <= T[i]); ord[i] = i; } sort(ord, ord + N, [](int a, int b){ if(S[a] != S[b])return S[a] < S[b]; return T[a] < T[b]; }); for(int i = 0, a = 0;i < N;i++){ if(S[ord[i]] == T[ord[i]])continue; if(T[ord[i]] == 'C'){ if(a-- == 0)f = false; } if(S[ord[i]] == 'A'){ a++; } if(i == N - 1 && a != 0)f = false; } cout << (f ? "Yes\n" : "No\n"); return 0; }