#include <bits/stdc++.h>

#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

using namespace std;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef double ld;

template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.precision(10);
    cout << fixed;
#ifdef LOCAL_DEFINE
    freopen("input.txt", "rt", stdin);
#endif

    int n;
    cin >> n;
    vector<pii> a(n); // vector<pair<int, int> > 
    forn(i, n) { // i = 0 .. n - 1
        cin >> a[i].fi >> a[i].se; // a[i].first, a[i].second
    }
    vector<int> dp(n + 1);
    dp[0] = 1;
    forn(i, n) { // i = 0 .. n - 1
        if (!dp[i]) continue;
        for (int x = 1; i + x <= n; ++x) { // (2 * i + 1, 2 * i + 1 + x), ... (2 * i + x, 2 * i + 2 * x)
            bool okBlock = true;
            for1(y, x) { // y = 1 .. x
                int v1 = 2 * i + y, v2 = v1 + x;
                bool ok = true;
                int fit = 0;
                forn(j, n) {
                    if (a[j].fi == v2 || a[j].se == v1) ok = false;
                    if (a[j].fi != v1 && a[j].se != v2) continue;
                    if (a[j].fi == v1) { // (v1, -1) or (v1, v2)
                        if (a[j].se != -1 && a[j].se != v2) ok = false;
                    }
                    if (a[j].se == v2) {
                        if (a[j].fi != -1 && a[j].fi != v1) ok = false;
                    }
                    // (?, v1)
                    if (ok) ++fit;
                }
                // (v1, -1), (-1, v2)
                okBlock &= ok && fit < 2;
            }
            if (okBlock) {
//                cerr << i << ' ' << x << '\n';
                dp[i + x] = 1;
            }
        }
    }

    // O(n^4)

    cout << (dp[n] ? "Yes" : "No") << '\n';

#ifdef LOCAL_DEFINE
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
    return 0;
}

#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define f first
#define s second
#define dbg(x) cout<< #x <<" "<<x<<"\n";
using namespace std;





void solve(){
    ll n;
    cin>>n;
    vector<string> v(n+1);
    vector<ll> dp(n+1,1);
    for(ll i=1; i<=n; ++i){
        cin>>v[i];
    }
    for(ll i=1; i<=n; ++i){
        if(v[i]=="AND"){
            dp[i] = dp[i-1];
        }
        else{
            dp[i] = dp[i-1] + (1LL<<i);
        }
    }
    cout<<dp[n]<<"\n";
}

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    solve();
}