#include <bits/stdc++.h>
/* #include <atcoder/lazysegtree> */
#include <iostream>
using namespace std;
/* using namespace atcoder; */
using pint = pair<int, int>;
using ll = long long;
using ull = unsigned long long;
using vll = vector<long long>;
using pll = pair<ll, ll>;
#define FOR(i, begin, end) \
    for (long long i = (begin), i##_end_ = (end); i < i##_end_; i++)
#define IFOR(i, begin, end) \
    for (int i = (end)-1, i##_begin_ = (begin); i >= i##_begin_; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define VREP(s, ite) for (auto ite = s.begin(); ite != s.end(); ++ite)
#define FI first
#define SE second
#define ALL(v) v.begin(), v.end()
#define endl "\n"
#define ciosup  \
    cin.tie(0); \
    ios::sync_with_stdio(false);
#define eb emplace_back
#define vint vector<int>
constexpr ll INF = 1e15 + 7LL;
constexpr ll MOD = 1e9 + 7LL;
template <typename T>
istream &operator>>(istream &is, vector<T> &v) {
    for (int i = 0; i < v.size(); ++i) {
        is >> v[i];
    }
    return is;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v) {
    if (v.size() == 0) return os;
    for (int i = 0; i < v.size() - 1; ++i) {
        os << v[i] << " ";
    }
    os << v[v.size() - 1];
    return os;
}

void solve() {
    int n, k;
    cin >> n >> k;
    string s;
    cin >> s;
    string tmpstr = s;
    while (k >= 1) {
        if (tmpstr.size() % 2 == 1) {
            string tmp = tmpstr;
            REP(i, tmp.size()) {
                tmpstr.push_back(tmp[i]);
            }
        }
        string newstr;
        REP(i, tmpstr.size()/2) {
            char f1 = tmpstr[2*i], f2 = tmpstr[2*i+1];
            if (f1 == f2) {
                newstr.push_back(f1);
            } else if (((f1 == 'R') && (f2 == 'S')) || ((f2 == 'R') && (f1 == 'S'))) {
                newstr.push_back('R');
            } else if (((f1 == 'P') && (f2 == 'R')) || ((f2 == 'P') && (f1 == 'R'))) {
                newstr.push_back('P');
            } else if (((f1 == 'S') && (f2 == 'P')) || ((f2 == 'S') && (f1 == 'P'))) {
                newstr.push_back('S');
            }
        }
        tmpstr = newstr;
        --k;
    }
    cout << tmpstr[0] << endl;
}


int main() {
    solve();
    char tmp;
    while (cin >> tmp) {
        cin.putback(tmp);
        solve();
    }
}


#include <bits/stdc++.h>
#define bug1(x) cout<<#x<<" = "<<x<<endl
#define bug2(x,y) cout<<#x<<" = "<<x<<" "<<#y<<" = "<<y<<endl
#define bug3(x,y,z) cout<<#x<<" = "<<x<<" "<<#y<<" = "<<y<<" "<<#z<<" = "<<z<<endl
#define bug4(x,y,z,m) cout<<#x<<" = "<<x<<" "<<#y<<" = "<<y<<" "<<#z<<" = "<<z<<" "<<#m<<" = "<<m<<endl

using namespace std;

template<class L, class R> 
ostream& operator<<(ostream &os, const pair<L,R> &input) {
    os << "(";
	os << input.first << "," << input.second;
	return os << ")";
}

template<class T> 
ostream& operator<<(ostream &os, const vector<T> &input) {
    os << "[ ";
    for(auto elem : input) { 
		os << elem << " ";
	}
	return os << "]";
}

template<class T> 
ostream& operator<<(ostream &os, const set<T> &input) {
    os << "{ ";
    for(auto elem : input) { 
		os << elem << " ";
	}
	return os << "}";
}

template<class T> 
ostream& operator<<(ostream &os, const unordered_set<T> &input) {
    os << "{ ";
    for(auto elem : input) { 
		os << elem << " ";
	}
	return os << "}";
}

template<class T> 
ostream& operator<<(ostream &os, const multiset<T> &input) {
    os << "{ ";
    for(auto elem : input) { 
		os << elem << " ";
	}
	return os << "}";
}

template<class T> 
ostream& operator<<(ostream &os, const unordered_multiset<T> &input) {
    os << "{ ";
    for(auto elem : input) { 
		os << elem << " ";
	}
	return os << "}";
}

template<class L, class R> 
ostream& operator<<(ostream &os, const map<L,R> &input) {
    os << "{ ";
    for(auto elem : input) { 
		os << "(" << elem.first << " , " << elem.second << ") ";
	}
	return os << "}";
}

template<class L, class R> 
ostream& operator<<(ostream &os, const unordered_map<L,R> &input) {
    os << "{ ";
    for(auto elem : input) { 
		os << "(" << elem.first << " , " << elem.second << ") ";
	}
	return os << "}";
}

#define ll long long
const int MAXN = 500005;
const int INF = 1e9;
const int MOD = 998244353;

class TaskC {
private:
	int n;
	vector<int> a , b, who, types;
	bool ok(int from, int upto) {
		int sz = upto - from + 1;
		assert(sz % 2 == 0);
		int len = sz / 2;
		for(int i = from, it = 0;  it < len; i++, it++) {
			if(who[i] == -1 && who[i+len] == -1) {
				continue;
			}
			if(who[i+len] == -1) {
				if(types[i] == 1) {
					return false;
				}
			} else if(who[i] == -1) {
				if(types[i+len] == 0) {
					return false;
				}
			} else {
				if(who[i] != who[i+len] || types[i] >= types[i+len]) {
					return false;
				}
			}
		}
		return true;
	}

	vector<int> memo;
	bool rec(int pos) {
		if(pos == 2*n) {
			return true;
		}
		if(memo[pos] != -1) {
			return memo[pos];
		}
		bool ans = 0;
		for(int upto = pos+1; upto < 2*n; upto += 2) {
			if(ok(pos, upto)) {
				ans |= rec(upto+1);
			}
		}
		return memo[pos] = ans;
	}

public:
	void solveOne(int it){
		cin >> n;
		a.assign(n, -1);
		b.assign(n, -1);
		vector<bool> used(2*n, false);
		who.assign(2*n, -1);
		types.assign(2*n, -1);
		for(int i = 0; i < n; i++) {
			cin >> a[i] >> b[i];
			if(a[i] != -1) {
				a[i]--;
				if(used[a[i]]) {
					cout << "No\n";
					return;
				}
				used[a[i]] = true;
				who[a[i]] = i;
				types[a[i]] = 0;
			}
			if(b[i] != -1) {
				b[i]--;
				if(used[b[i]]) {
					cout << "No\n";
					return;
				}
				used[b[i]] = true;
				who[b[i]] = i;
				types[b[i]] = 1;
			}
			if(a[i] != -1 && b[i] != -1 && a[i] >= b[i]) {
				cout << "No\n";
				return;
			}
		}
		memo.assign(2*n+1, -1);
		int ans = rec(0);
		cout << (ans ? "Yes":"No") << endl;
	}

	void solve(){
		int tc = 1;
		for(int it = 1; it <= tc; it++){
			solveOne(it);
		}
	}
};


int main(){
	ios_base::sync_with_stdio(false);
	TaskC solver;
	solver.solve();
	return 0;
}
