#include <stdio.h>

int main () {
  int n = 0;
  char s[200001] = "";
  char t[200001] = "";
  
  int res = 0;
  
  int is_ng = 0;
  int cnt[3] = {};
  
  res = scanf("%d", &n);
  res = scanf("%s", s);
  res = scanf("%s", t);
  
  for (int i = 0; i < n; i++) {
    if (s[i] > t[i]) {
      is_ng = 1;
    } else if (s[i] == 'A' && t[i] == 'B') {
      cnt[0]++;
    } else if (s[i] == 'B' && t[i] == 'C') {
      cnt[1]++;
    } else if (s[i] == 'A' && t[i] == 'C') {
      cnt[2]++;
    }
  }
  
  if (cnt[0] != cnt[1] || (cnt[2] > 0 && cnt[0] == 0)) {
    is_ng = 1;
  }
  
  if (is_ng > 0) {
    printf("No\n");
  } else {
    printf("Yes\n");
  }
  
  return 0;
}