#ifndef ONLINE_JUDGE
#define DEBUG true
#endif
#ifndef DEBUG
#define DEBUG false
#endif
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define sz(x) ((int)x.size())
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pi;
typedef deque<int> di;
typedef deque<pi> dpi;
typedef deque<bool> db;
typedef vector<ll> vi;
typedef vector<pi> vpi;
typedef vector<bool> vb;
#define NO cout << "NO" << endl
#define YES cout << "YES" << endl
#define No cout << "No" << endl
#define Yes cout << "Yes" << endl
#define endl '\n'
const ll INF = 1e9;
const int MOD = 1e9+7;
const int MAXN = 2e5;
void solve()
{
int n;
cin >> n;
string a,b;
cin >> a >> b;
for(int i = 0; i < n; i++){
if ((a[i] == 'R' && b[i] != 'R') || (a[i] != 'R' && b[i] == 'R')){
NO;
return;
}
}
YES;
}
int32_t main()
{
ios_base::sync_with_stdio(false);
//cin.tie(NULL);
int t;
cin >> t;
while(t--){
solve();
}
//if (DEBUG) cerr << endl << "finished in " << clock() * 1.0 / CLOCKS_PER_SEC << " sec" << endl;
}
//To input a whole line without getting seperated by spaces, use getline(cin, string_name)
//Make string to int: stoi(your_String)
//Make int to string: to_string(your_Int)
1729B - Decode String | 1729C - Jumping on Tiles |
1729E - Guess the Cycle Size | 553B - Kyoya and Permutation |
1729D - Friends and the Restaurant | 1606C - Banknotes |
580C - Kefa and Park | 342A - Xenia and Divisors |
1033A - King Escape | 39D - Cubical Planet |
1453A - Cancel the Trains | 645A - Amity Assessment |
1144A - Diverse Strings | 1553B - Reverse String |
1073A - Diverse Substring | 630N - Forecast |
312B - Archer | 34D - Road Map |
630I - Parking Lot | 160B - Unlucky Ticket |
371B - Fox Dividing Cheese | 584B - Kolya and Tanya |
137B - Permutation | 550C - Divisibility by Eight |
5A - Chat Servers Outgoing Traffic | 615A - Bulbs |
5B - Center Alignment | 549A - Face Detection |
535B - Tavas and SaDDas | 722C - Destroying Array |