#include <bits/stdc++.h>
using namespace std;
#define all(x) begin(x), end(x)
mt19937_64 rng( chrono:: steady_clock :: now ( ) .time_since_epoch ( ) .count ( ) ) ;
const int maxn = 2555 , sigma = 4 ;
int dp[ maxn] [ maxn] [ sigma] ;
int get( char c) {
return c == 'R' ? 0 : c == 'G' ? 1 : 2 ;
}
class StringTransformation {
public :
string getResult( string s, string t) {
int n = s.size ( ) ;
int m = t.size ( ) ;
dp[ 0 ] [ 0 ] [ 0 ] = dp[ 0 ] [ 0 ] [ 1 ] = dp[ 0 ] [ 0 ] [ 2 ] = dp[ 0 ] [ 0 ] [ 3 ] = 1 ;
for ( int i = 1 ; i <= n; i++ ) {
for ( int j = 1 ; j <= m; j++ ) {
if ( s[ i - 1 ] == t[ j - 1 ] ) {
int c = get( s[ i - 1 ] ) ;
dp[ i] [ j] [ 3 ] = dp[ i - 1 ] [ j - 1 ] [ c] ;
}
for ( int tc = 0 ; tc <= 2 ; tc++ ) {
dp[ i] [ j] [ tc] = dp[ i] [ j] [ 3 ] ;
if ( i >= 3 && get( s[ i - 3 ] ) ! = tc) {
dp[ i] [ j] [ tc] | = dp[ i - 2 ] [ j] [ tc] ;
}
}
}
}
return dp[ n] [ m] [ 3 ] ? "YES" : "NO" ;
}
} me;
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+Cgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKI2RlZmluZSBhbGwoeCkgYmVnaW4oeCksIGVuZCh4KQptdDE5OTM3XzY0IHJuZyhjaHJvbm86OnN0ZWFkeV9jbG9jazo6bm93KCkudGltZV9zaW5jZV9lcG9jaCgpLmNvdW50KCkpOwoKY29uc3QgaW50IG1heG4gPSAyNTU1LCBzaWdtYSA9IDQ7CmludCBkcFttYXhuXVttYXhuXVtzaWdtYV07CgppbnQgZ2V0KGNoYXIgYykgewoJcmV0dXJuIGMgPT0gJ1InID8gMCA6IGMgPT0gJ0cnID8gMSA6IDI7Cn0KCmNsYXNzIFN0cmluZ1RyYW5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