#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#define INF 2100000000
using namespace std;
char str[1000];
class SELL
{
public:
    int x,last,pos;
    SELL(int a,int b,int c)
    {
        x=a;
        last=b;
        pos=c;
    }
};
bool cmp(SELL a,SELL b)
{
    if(a.x>b.x)
        return true;
    //else if(a.x==b.x&&(a.pos-a.last)<(b.pos-b.last))
    //    return true;
    else
        return false;
}
char* Gplus(char* a,char* b)
{
    int La,Lb,jin=0,i,j;
    char tmp;
    La=strlen(a);
    Lb=strlen(b);
    for(i=0;i<La&&i<Lb;i++)
    {
        str[i]=(a[La-1-i]-'0'+b[Lb-1-i]-'0'+jin)%10+'0';
        jin=(a[La-1-i]-'0'+b[Lb-1-i]-'0'+jin)/10;
    }
    if(La==Lb)
    {
        if(jin!=0)
        {
            str[i]=jin+'0';
            i++;
        }
    }
    else if(La<Lb)
    {
        for(;i<Lb;i++)
        {
            str[i]=(b[Lb-1-i]-'0'+jin)%10+'0';
            jin=(b[Lb-1-i]-'0'+jin)/10;
        }
        if(jin!=0)
        {
            str[i]=jin+'0';
            i++;
        }
    }
    else
    {
        for(;i<La;i++)
        {
            str[i]=(a[La-1-i]-'0'+jin)%10+'0';
            jin=(a[La-1-i]-'0'+jin)/10;
        }
        if(jin!=0)
        {
            str[i]=jin+'0';
            i++;
        }
    }
    for(j=i-1;j>=i/2;j--)
    {
        tmp=str[i-1-j];
        str[i-1-j]=str[j];
        str[j]=tmp;
    }
    str[i]='\0';
    //cout<<a<<'+'<<b<<'='<<str<<endl;
    return str;
}

int main()
{
	int N,i,j,k,temp,win[2001];
	char act[10],lastact[10],sum[1000],ans[1000],num2[2]="2";
	bool able,used[2001]={0};
	vector<SELL> sell;
	for(i=0;i<=2000;i++)
        win[i]=-1;
	scanf("%d",&N);
	strcpy(sum,"0");
	for(i=1;i<=N;i++)
    {
        scanf("%s",act);
        if(strcmp(act,"win")==0)
        {
            scanf("%d",&temp);
            win[temp]=i;
        }
        else
        {
            scanf("%d",&temp);
            if(win[temp]!=-1)
                sell.push_back(SELL(temp,win[temp],i));
        }
    }
    sort(sell.begin(),sell.end(),cmp);
    for(i=0;i<sell.size();i++)
    {
        able=true;
        for(j=sell[i].pos;j>=sell[i].last;j--)
            if(used[j])
            {
                able=false;
                break;
            }
        if(able)
        {
            for(j=sell[i].pos;j>=sell[i].last;j--)
                used[j]=true;
            strcpy(ans,"1");
            for(k=1;k<=sell[i].x;k++)
                strcpy(ans,Gplus(ans,ans));
            strcpy(sum,Gplus(sum,ans));
        }
    }
    printf("%s",sum);
	return 0;
}


#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#define INF 2100000000
using namespace std;
char str[1000];
class SELL
{
public:
    int x,last,pos;
    SELL(int a,int b,int c)
    {
        x=a;
        last=b;
        pos=c;
    }
};
bool cmp(SELL a,SELL b)
{
    return a.x>b.x;
}
char* Gplus(char* a,char* b)
{
    int La,Lb,jin=0,i,j;
    char tmp;
    La=strlen(a);
    Lb=strlen(b);
    for(i=0;i<La&&i<Lb;i++)
    {
        str[i]=(a[La-1-i]-'0'+b[Lb-1-i]-'0'+jin)%10+'0';
        jin=(a[La-1-i]-'0'+b[Lb-1-i]-'0'+jin)/10;
    }
    if(La==Lb)
    {
        if(jin!=0)
        {
            str[i]=jin+'0';
            i++;
        }
    }
    else if(La<Lb)
    {
        for(;i<Lb;i++)
        {
            str[i]=(b[Lb-1-i]-'0'+jin)%10+'0';
            jin=(b[Lb-1-i]-'0'+jin)/10;
        }
        if(jin!=0)
        {
            str[i]=jin+'0';
            i++;
        }
    }
    else
    {
        for(;i<La;i++)
        {
            str[i]=(a[La-1-i]-'0'+jin)%10+'0';
            jin=(a[La-1-i]-'0'+jin)/10;
        }
        if(jin!=0)
        {
            str[i]=jin+'0';
            i++;
        }
    }
    for(j=i-1;j>=i/2;j--)
    {
        tmp=str[i-1-j];
        str[i-1-j]=str[j];
        str[j]=tmp;
    }
    str[i]='\0';
    //cout<<a<<'+'<<b<<'='<<str<<endl;
    return str;
}

int main()
{
	int N,i,j,k,temp,win[2001];
	char act[10],lastact[10],sum[1000],ans[1000],num2[2]="2";
	bool able,used[5001]={0};
	vector<SELL> sell;
	for(i=0;i<=2000;i++)
        win[i]=-1;
	scanf("%d",&N);
	strcpy(sum,"0");
	for(i=1;i<=N;i++)
    {
        scanf("%s",act);
        if(strcmp(act,"win")==0)
        {
            scanf("%d",&temp);
            win[temp]=i;
        }
        else
        {
            scanf("%d",&temp);
            if(win[temp]!=-1)
                sell.push_back(SELL(temp,win[temp],i));
        }
    }
    sort(sell.begin(),sell.end(),cmp);
    for(i=0;i<sell.size();i++)
    {
        able=true;
        for(j=sell[i].pos;j>=sell[i].last;j--)
            if(used[j])
            {
                able=false;
                break;
            }
        if(able)
        {
            for(j=sell[i].pos;j>=sell[i].last;j--)
                used[j]=true;
            strcpy(ans,"1");
            for(k=1;k<=sell[i].x;k++)
                strcpy(ans,Gplus(ans,ans));
            strcpy(sum,Gplus(sum,ans));
        }
    }
    printf("%s",sum);
	return 0;
}


#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#define INF 2100000000
using namespace std;
bool cmp(int a,int b)
{
    return a>b;
}
char str[1000];
char* Gplus(char* a,char* b)
{
    int La,Lb,jin=0,i,j;
    char tmp;
    La=strlen(a);
    Lb=strlen(b);
    for(i=0;i<La&&i<Lb;i++)
    {
        str[i]=(a[La-1-i]-'0'+b[Lb-1-i]-'0'+jin)%10+'0';
        jin=(a[La-1-i]-'0'+b[Lb-1-i]-'0'+jin)/10;
    }
    if(La==Lb)
    {
        if(jin!=0)
        {
            str[i]=jin+'0';
            i++;
        }
    }
    else if(La<Lb)
    {
        for(;i<Lb;i++)
        {
            str[i]=(b[Lb-1-i]-'0'+jin)%10+'0';
            jin=(b[Lb-1-i]-'0'+jin)/10;
        }
        if(jin!=0)
        {
            str[i]=jin+'0';
            i++;
        }
    }
    else
    {
        for(;i<La;i++)
        {
            str[i]=(a[La-1-i]-'0'+jin)%10+'0';
            jin=(a[La-1-i]-'0'+jin)/10;
        }
        if(jin!=0)
        {
            str[i]=jin+'0';
            i++;
        }
    }
    for(j=i-1;j>=i/2;j--)
    {
        tmp=str[i-1-j];
        str[i-1-j]=str[j];
        str[j]=tmp;
    }
    str[i]='\0';
    //cout<<a<<'+'<<b<<'='<<str<<endl;
    return str;
}
char* Gmult(char* a,char* b)
{

    return str;
}
int main()
{
	int N,i,j,k,temp;
	char act[10],lastact[10],sum[1000],ans[1000],num2[2]="2";
	vector<int> win,sell;
	vector<int>::iterator iter;
	scanf("%d",&N);
	strcpy(sum,"0");
	for(i=1;i<=N;i++)
    {
        scanf("%s",act);
        if(strcmp(act,"win")==0)
        {
            if(strcmp(lastact,"sell")==0)
            {
                sort(win.begin(),win.end());
                sort(sell.begin(),sell.end(),cmp);
                for(j=0;j<sell.size();j++)
                {
                    iter=lower_bound(win.begin(),win.end(),sell[j]);
                    if(iter!=win.end()&&*iter==sell[j])
                    {
                        strcpy(ans,"1");
                        for(k=1;k<=sell[j];k++)
                            strcpy(ans,Gplus(ans,ans));
                        strcpy(sum,Gplus(sum,ans));
                        break;
                    }
                }
                win.clear();
                sell.clear();
            }
            scanf("%d",&temp);
            win.push_back(temp);
            strcpy(lastact,act);
        }
        else
        {
            scanf("%d",&temp);
            sell.push_back(temp);
            strcpy(lastact,act);
        }
    }
    if(strcmp(lastact,"sell")==0)
    {
        sort(win.begin(),win.end());
        sort(sell.begin(),sell.end(),cmp);
        for(j=0;j<sell.size();j++)
        {
            iter=lower_bound(win.begin(),win.end(),sell[j]);
            if(iter!=win.end()&&*iter==sell[j])
            {
                strcpy(ans,"1");
                for(k=1;k<=sell[j];k++)
                    strcpy(ans,Gplus(ans,ans));
                strcpy(sum,Gplus(sum,ans));
                break;
            }
        }
        win.clear();
        sell.clear();
    }
    printf("%s",sum);
	return 0;
}


#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#define INF 2100000000
using namespace std;
char str[1000];
class SELL
{
public:
    int x,last,pos;
    SELL(int a,int b,int c)
    {
        x=a;
        last=b;
        pos=c;
    }
};
bool cmp(SELL a,SELL b)
{
    return a.x>b.x;
}
char* Gplus(char* a,char* b)
{
    int La,Lb,jin=0,i,j;
    char tmp;
    La=strlen(a);
    Lb=strlen(b);
    for(i=0;i<La&&i<Lb;i++)
    {
        str[i]=(a[La-1-i]-'0'+b[Lb-1-i]-'0'+jin)%10+'0';
        jin=(a[La-1-i]-'0'+b[Lb-1-i]-'0'+jin)/10;
    }
    if(La==Lb)
    {
        if(jin!=0)
        {
            str[i]=jin+'0';
            i++;
        }
    }
    else if(La<Lb)
    {
        for(;i<Lb;i++)
        {
            str[i]=(b[Lb-1-i]-'0'+jin)%10+'0';
            jin=(b[Lb-1-i]-'0'+jin)/10;
        }
        if(jin!=0)
        {
            str[i]=jin+'0';
            i++;
        }
    }
    else
    {
        for(;i<La;i++)
        {
            str[i]=(a[La-1-i]-'0'+jin)%10+'0';
            jin=(a[La-1-i]-'0'+jin)/10;
        }
        if(jin!=0)
        {
            str[i]=jin+'0';
            i++;
        }
    }
    for(j=i-1;j>=i/2;j--)
    {
        tmp=str[i-1-j];
        str[i-1-j]=str[j];
        str[j]=tmp;
    }
    str[i]='\0';
    //cout<<a<<'+'<<b<<'='<<str<<endl;
    return str;
}
char mi[2001][700];
int main()
{
	int N,i,j,k,temp,win[2001];
	char act[10],lastact[10],sum[1000],ans[1000],num2[2]="2";
	bool able,used[5001]={0};
	vector<SELL> sell;
	mi[0][0]='1';
	mi[0][1]='\0';
	for(i=1;i<=2000;i++)
        strcpy(mi[i],Gplus(mi[i-1],mi[i-1]));
	for(i=0;i<=2000;i++)
        win[i]=-1;
	scanf("%d",&N);
	strcpy(sum,"0");
	for(i=1;i<=N;i++)
    {
        scanf("%s",act);
        if(strcmp(act,"win")==0)
        {
            scanf("%d",&temp);
            win[temp]=i;
        }
        else
        {
            scanf("%d",&temp);
            if(win[temp]!=-1)
                sell.push_back(SELL(temp,win[temp],i));
        }
    }
    sort(sell.begin(),sell.end(),cmp);
    for(i=0;i<sell.size();i++)
    {
        able=true;
        for(j=sell[i].pos;j>=sell[i].last;j--)
            if(used[j])
            {
                able=false;
                break;
            }
        if(able)
        {
            for(j=sell[i].pos;j>=sell[i].last;j--)
                used[j]=true;
            strcpy(ans,mi[sell[i].x]);
            strcpy(sum,Gplus(sum,ans));
        }
    }
    printf("%s",sum);
	return 0;
}


#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#define INF 2100000000
using namespace std;
char str[1000];
class SELL
{
public:
    int x,last,pos;
    SELL(int a,int b,int c)
    {
        x=a;
        last=b;
        pos=c;
    }
};
bool cmp(SELL a,SELL b)
{
    return a.x>b.x;
}
char* Gplus(char* a,char* b)
{
    int La,Lb,jin=0,i,j;
    char tmp;
    La=strlen(a);
    Lb=strlen(b);
    for(i=0;i<La&&i<Lb;i++)
    {
        str[i]=(a[La-1-i]-'0'+b[Lb-1-i]-'0'+jin)%10+'0';
        jin=(a[La-1-i]-'0'+b[Lb-1-i]-'0'+jin)/10;
    }
    if(La==Lb)
    {
        if(jin!=0)
        {
            str[i]=jin+'0';
            i++;
        }
    }
    else if(La<Lb)
    {
        for(;i<Lb;i++)
        {
            str[i]=(b[Lb-1-i]-'0'+jin)%10+'0';
            jin=(b[Lb-1-i]-'0'+jin)/10;
        }
        if(jin!=0)
        {
            str[i]=jin+'0';
            i++;
        }
    }
    else
    {
        for(;i<La;i++)
        {
            str[i]=(a[La-1-i]-'0'+jin)%10+'0';
            jin=(a[La-1-i]-'0'+jin)/10;
        }
        if(jin!=0)
        {
            str[i]=jin+'0';
            i++;
        }
    }
    for(j=i-1;j>=i/2;j--)
    {
        tmp=str[i-1-j];
        str[i-1-j]=str[j];
        str[j]=tmp;
    }
    str[i]='\0';
    //cout<<a<<'+'<<b<<'='<<str<<endl;
    return str;
}

int main()
{
	int N,i,j,k,temp,win[2001];
	char act[10],lastact[10],sum[1000],ans[1000],num2[2]="2";
	bool able,used[2001]={0};
	vector<SELL> sell;
	for(i=0;i<=2000;i++)
        win[i]=-1;
	scanf("%d",&N);
	strcpy(sum,"0");
	for(i=1;i<=N;i++)
    {
        scanf("%s",act);
        if(strcmp(act,"win")==0)
        {
            scanf("%d",&temp);
            win[temp]=i;
        }
        else
        {
            scanf("%d",&temp);
            if(win[temp]!=-1)
                sell.push_back(SELL(temp,win[temp],i));
        }
    }
    sort(sell.begin(),sell.end(),cmp);
    for(i=0;i<sell.size();i++)
    {
        able=true;
        for(j=sell[i].pos;j>=sell[i].last;j--)
            if(used[j])
            {
                able=false;
                break;
            }
        if(able)
        {
            for(j=sell[i].pos;j>=sell[i].last;j--)
                used[j]=true;
            strcpy(ans,"1");
            for(k=1;k<=sell[i].x;k++)
                strcpy(ans,Gplus(ans,ans));
            strcpy(sum,Gplus(sum,ans));
        }
    }
    printf("%s",sum);
	return 0;
}


#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#define INF 2100000000
using namespace std;
char str[1000];
class SELL
{
public:
    int x,last,pos;
    SELL(int a,int b,int c)
    {
        x=a;
        last=b;
        pos=c;
    }
};
bool cmp(SELL a,SELL b)
{
    if(a.x>b.x)
        return true;
    else if(a.x==b.x&&(a.pos-a.last)<(b.pos-b.last))
        return true;
    else
        return false;
}
char* Gplus(char* a,char* b)
{
    int La,Lb,jin=0,i,j;
    char tmp;
    La=strlen(a);
    Lb=strlen(b);
    for(i=0;i<La&&i<Lb;i++)
    {
        str[i]=(a[La-1-i]-'0'+b[Lb-1-i]-'0'+jin)%10+'0';
        jin=(a[La-1-i]-'0'+b[Lb-1-i]-'0'+jin)/10;
    }
    if(La==Lb)
    {
        if(jin!=0)
        {
            str[i]=jin+'0';
            i++;
        }
    }
    else if(La<Lb)
    {
        for(;i<Lb;i++)
        {
            str[i]=(b[Lb-1-i]-'0'+jin)%10+'0';
            jin=(b[Lb-1-i]-'0'+jin)/10;
        }
        if(jin!=0)
        {
            str[i]=jin+'0';
            i++;
        }
    }
    else
    {
        for(;i<La;i++)
        {
            str[i]=(a[La-1-i]-'0'+jin)%10+'0';
            jin=(a[La-1-i]-'0'+jin)/10;
        }
        if(jin!=0)
        {
            str[i]=jin+'0';
            i++;
        }
    }
    for(j=i-1;j>=i/2;j--)
    {
        tmp=str[i-1-j];
        str[i-1-j]=str[j];
        str[j]=tmp;
    }
    str[i]='\0';
    //cout<<a<<'+'<<b<<'='<<str<<endl;
    return str;
}

int main()
{
	int N,i,j,k,temp,win[2001];
	char act[10],lastact[10],sum[1000],ans[1000],num2[2]="2";
	bool able,used[2001]={0};
	vector<SELL> sell;
	for(i=0;i<=2000;i++)
        win[i]=-1;
	scanf("%d",&N);
	strcpy(sum,"0");
	for(i=1;i<=N;i++)
    {
        scanf("%s",act);
        if(strcmp(act,"win")==0)
        {
            scanf("%d",&temp);
            win[temp]=i;
        }
        else
        {
            scanf("%d",&temp);
            if(win[temp]!=-1)
                sell.push_back(SELL(temp,win[temp],i));
        }
    }
    sort(sell.begin(),sell.end(),cmp);
    for(i=0;i<sell.size();i++)
    {
        able=true;
        for(j=sell[i].pos;j>=sell[i].last;j--)
            if(used[j])
            {
                able=false;
                break;
            }
        if(able)
        {
            //for(j=sell[i].pos;j>=sell[i].last;j--)
            //    used[j]=true;
            strcpy(ans,"1");
            for(k=1;k<=sell[i].x;k++)
                strcpy(ans,Gplus(ans,ans));
            strcpy(sum,Gplus(sum,ans));
        }
    }
    printf("%s",sum);
	return 0;
}


#include<bits/stdc++.h>
#define ios std::ios::sync_with_stdio(false)
#define rep(i,a,n) for (int i=a;i<=n;i++)
#define per(i,n,a) for (int i=n;i>=a;i--)
#define ll long long
#define fi first
#define se second
#define pb push_back
#define all(a) a.begin(),a.end()
#define mst(a,n) memset(a,n,sizeof(a))
#define dbg(a, b) cout <<#a<<": "<<a<<" | "<<#b<<": "<<b<<endl;
#define debug(a, b, c, d)    cout <<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl;
#define printa(a,l,r) for(int i = l; i <= r; i++){cout << a[i] << " \n"[i==r];}
#define printset(st) for(auto it:st){cout << it << " ";} cout << '\n';
#define printmap(mp) for(auto &it:mp){cout << it.se << " ";} cout << '\n';
//ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
//ll lcm(ll a,ll b){return a*b/gcd(a,b);}
//ll pow_mod(ll x,ll n,ll mod){ll res=1;while(n){if(n&1)res=res*x%mod;x=x*x%mod;n>>=1;}return res;}
//ll fact_pow(ll n,ll p){ll res=0;while(n){n/=p;res+=n;}return res;}
//ll mult(ll a,ll b,ll p){a%=p;b%=p;ll r=0,v=a;while(b){if(b&1){r+=v;if(r>p)r-=p;}v<<=1;if(v>p)v-=p;b>>=1;}return r;}
//freopen("C:/Users/zyj19/Desktop/out.txt","w",stdout);int num = 0;time_t begin,end;double ret;begin=clock();end=clock();ret=double(end-begin)/CLOCKS_PER_SEC;cout<<"runtime: "<<ret<<endl;fclose(stdout);
using namespace std;
template<typename T>void read(T &res){bool flag=false;char ch;while(!isdigit(ch=getchar()))(ch=='-')&&(flag=true);for(res=ch-48;isdigit(ch=getchar());res=(res<<1)+(res<<3)+ch - 48);flag&&(res=-res);}
template<typename T>void Out(T x){if(x<0)putchar('-'),x=-x;if(x>9)Out(x/10);putchar(x%10+'0');}
//struct Edge{int nxt,to;}e[N<<1];int head[N],TOT;void add_edge(int u,int v){e[++TOT].nxt=head[u];e[TOT].to = v;head[u] = TOT;}
//struct node{int k,l,r;bool operator <(const node& A)const{return k < A.k;}};
//const ll INF = 0x3f3f3f3f3f3f3f3f;
const int N = 2e5 + 10, MOD = 1e9+7, inf = 0x3f3f3f3f;
struct Bint{
    string n;
    Bint(string s){
        n=s;
    }
    Bint operator+(const Bint &a){
        Bint x=n,y=a;
        if(x.n.size()<y.n.size())swap(x,y);
        while(y.n.size()<x.n.size())y.n="0"+y.n;
        string res="";
        bool flag=false;
        for(int i=x.n.size()-1;i>=0;i--){
            int num=(x.n[i]-'0')+(y.n[i]-'0')+flag;
            flag=false;
            if(num<10){
                res=(char)('0'+num)+res;
            }
            else{
                flag=true;
                res=(char)('0'+(num-10))+res;
            }
        }
        if(flag)res='1'+res;
        return res;
    }
    Bint operator*(const Bint &a){
        Bint x=n,y=a,res("0");
        string zeroes="";
        for(int i=y.n.size()-1;i>=0;i--){
            Bint mul("0");
            rep(_,0,y.n[i]-'0'-1)mul+=x;
            res+=Bint(mul.n+zeroes);
            zeroes+="0";
        }
        return res;
    }
    Bint pow(Bint a,int b){
        if(b==0)return Bint("1");
        if(b%2)return pow(a,b-1)*a;
        Bint memo=pow(a,b/2);
        return memo*memo;
    }
    Bint operator^(const int &a){
        return pow(n,a);
    }
    void operator+=(const Bint &b){
        *this=*this+b;
    }
    void operator*=(const Bint &b){
        *this=*this*b;
    }
};
int sell[2010],used[5010];
set<int>win[2010];
string beki[2010];
signed main()
{
	ios;
	int n, having = -1;
	pair<string,int>p[5010];
	fill(sell,sell+2010,-1);
	beki[0] = "1";
	rep(i,0,2000){
		beki[i+1] = (Bint(beki[i]) * Bint("2")).n;
	}
	cin >> n;
	Bint ans("0");
	rep(i,0,n-1)
	{
		cin >> p[i].fi >> p[i].se;
		if (p[i].fi == "sell") sell[p[i].se] = i;
		else win[p[i].se].insert(i);
	}
	per(i,2000,0){
		if (win[i].empty() || *win[i].begin() > sell[i]) continue;
		int l = *prev(win[i].upper_bound(sell[i])), r = sell[i];
		bool flag = true;
		rep(j,l,r){
			if (used[j]){
				flag = false;
				break;
			}
		}
		if (flag){
			fill(used + l, used + r + 1, true);
			ans += Bint(beki[i]);
		}
	}
	cout << ans.n << '\n';
    return 0;
}


#include <bits/stdc++.h>

#define DEBUG(x) cerr << #x << " = " << x << endl

using namespace std;

typedef long long ll;
typedef vector<int> VI;

class BigInt { public:
  const ll BASE = 1000000000;
  VI v;
  int siz, sig;

  // initialization
  BigInt() { v=VI(1,0); siz=sig=1; }
  BigInt(int x) {
    if (x>=0) sig=1;
    else { sig=-1; x*=-1; }
    v=VI(1,x);
    siz=1;
  }
  BigInt(string s) { str2bi(s); }
  BigInt(const BigInt &b) { *this=b; }

  // misc
  void operator=(const BigInt &b) { v=b.v; siz=b.siz; sig=b.sig; }
  int digit(int pos) { if (pos<siz) return v[pos]; return 0; }
  void zero() { v=VI(1,0); siz=sig=1; }
  void resiz(int nsiz, int val=0) { v.resize(siz=nsiz,val); }
  void unzero() {
    int i;
    for (i=siz-1; i>0 && v[i]==0; --i);
    resiz(i+1);
  }
  void str2bi(string s) {
    if (s[0]=='-') { sig=-1; s=s.substr(1); }
    else sig=1;
    reverse(s.begin(),s.end());
    siz=s.size()/9 + 1;
    v=VI(siz,0);
    for (int i=0, pw=1; i<int(s.size()); ++i, pw*=10) {
      if (i%9==0) pw=1;
      v[i/9]+=int(s[i]-'0')*pw;
    }
  }

  // comparisons
  //0: ==b  +: >b  -: <b
  inline int compabs(const BigInt &b) const {
    if (siz!=b.siz) return siz-b.siz;
    for (int i=siz-1; i>=0; --i) {
      if (v[i]!=b.v[i]) return v[i]-b.v[i];
    }
    return 0;
  }
  // 0: ==b  +: >b  -: <b
  inline int compare(const BigInt &b) const {
    if (sig!=b.sig) return sig-b.sig;
    return sig*compabs(b);
  }
  inline bool operator==(const BigInt &b) const { return !compare(b); }
  inline bool operator!=(const BigInt &b) const { return compare(b); }
  inline bool operator<(const BigInt &b) const { return compare(b)<0; }
  inline bool operator<=(const BigInt &b) const { return compare(b)<=0; }
  inline bool operator>(const BigInt &b) const { return compare(b)>0; }
  inline bool operator>=(const BigInt &b) const { return compare(b)>=0; }
  // |x| < 10^9
  inline bool operator==(int x) { return siz==1 && sig*v[0]==x; }

  // operations
  void add(BigInt &b) {
    if (siz<b.siz) resiz(b.siz,0);
    int ca=0;
    for (int i=0; i<siz; ++i) {
      v[i]+=b.digit(i)+ca;
      ca=v[i]/BASE;
      v[i]%=BASE;
    }
    if (ca) resiz(siz+1,ca);
  }
  // assumes that >=b
  void substract(BigInt &b) {
    int ca=0;
    for (int i=0; i<siz; ++i) {
      v[i]+=BASE-b.digit(i)+ca;
      ca=v[i]/BASE-1;
      v[i]%=BASE;
    }
    unzero();
  }

  // operators
  // |x| < 10^9
  void operator+=(int x) {
    v[0]+=x;
    for (int i=0; i<siz && v[i]>=BASE; ++i) {
      v[i+1]+=v[i]/BASE;
      v[i]%=BASE;
    }
    if (v[siz-1]>=BASE) {
      resiz(siz+1,v[siz-1]/BASE);
      v[siz-1]%=BASE;
    }
  }
  void operator+=(BigInt &b) {
    if (sig==b.sig) add(b);
    else if (compabs(b)>=0) substract(b);
    else {
      BigInt aux(b);
      aux.substract(*this);
      *this=aux;
    }
  }
  BigInt operator+(BigInt &x) {
    BigInt ret=*this;
    ret+=x;
    return ret;
  }
  // |x| < 10^9
  void operator-=(int x) {
    v[0]-=x;
    for (int i=0; i<siz && v[i]<0; ++i) {
      v[i+1]+=v[i]/BASE - 1;
      v[i]%=BASE;
      v[i]+=BASE;
    }
    unzero();
  }
  void operator-=(BigInt &b) {
    if (&b==this) zero();
    else {
      b.sig*=-1;
      operator+=(b);
      b.sig*=-1;
    }
  }
  BigInt operator-(BigInt &x) {
    BigInt ret=*this;
    ret-=x;
    return ret;
  }
  // |x| < 10^9
  void operator*=(int x) {
    if (x<0) { sig*=-1; x*=-1; }
    resiz(siz+1,0);
    ll ca=0;
    for (int i=0; i<siz; ++i) {
      ca+=ll(v[i])*ll(x);
      v[i]=ca%BASE;
      ca/=BASE;
    }
    unzero();
  }
  void operator*=(BigInt &b) {
    BigInt c;
    c.resiz(siz + b.siz);
    c.sig=sig*b.sig;
    for (int i=0; i<siz; ++i)
      for (int j=0; j<b.siz; ++j) {
        int k=i+j;
        ll z=ll(digit(i))*ll(b.digit(j)) + c.digit(k);
        for (ll y; (y = z/BASE);) {
          c.v[k]=z%BASE;
          z=y + c.v[++k];
        }
        c.v[k]=z;
      }
    c.unzero();
    *this=c;
  }
  BigInt operator*(BigInt &x) {
    BigInt ret=*this;
    ret*=x;
    return ret;
  }
  // |x| < 10^9
  void operator/=(int x) {
    if (x<0) { sig*=-1; x*=-1; }
    ll ca=0;
    for (int i=siz-1; i>=0; --i) {
      ca+=v[i];
      v[i]=ca/x;
      ca%=x;
      ca*=BASE;
    }
    unzero();
  }
  void operator/=(BigInt &b){
    if (compabs(b)<0) zero();
    else if (b.siz==1) *this/=b.sig*b.v[0];
    else {
      int st=sig*b.sig,sb=b.sig;
      sig=b.sig=1;
      vector<BigInt> VB,pot2;
      VB.push_back(b);
      pot2.push_back(1);
      BigInt cur=0;
      while (VB[VB.size()-1]<=*this){
        BigInt last=VB[VB.size()-1];
        last+=last;
        VB.push_back(last);
        last=pot2[pot2.size()-1];
        last+=last;
        pot2.push_back(last);
      }
      cur+=pot2[pot2.size()-2];
      (*this)-=VB[VB.size()-2];
      while ((*this)>=b){
        int i=0;
        while (VB[i]<=(*this)) ++i;
        cur+=pot2[i-1];
        (*this)-=VB[i-1];
      }
      (*this)=cur;
      sig=st;
      b.sig=sb;
    }
  }
  BigInt operator/(BigInt &x) {
    BigInt ret=*this;
    ret/=x;
    return ret;
  }
  // |x| < 10^9
  ll mod(int x) {
    if (x<0) x*=-1;
    ll ca=0;
    for (int i=siz-1; i>=0; --i) { ca*=BASE; ca+=v[i]; ca%=x; }
    return ca;
  }
  void operator%=(BigInt &b) {
    BigInt r(*this); r/=b; r*=b; operator-=(r);
  }
  void gcdrec(BigInt &b, BigInt &c) {
    if (c==0) return *this=b;
    b%=c;
    gcdrec(c,b);
  }
  void gcd(BigInt &b, BigInt& c) { BigInt bb(b),cc(c); gcdrec(bb,cc); }
  void powrec(BigInt &aux, ll p) {
    if (!p) return;
    powrec(aux,p/2);
    aux*=aux;
    if (p%2) aux*=(*this);
  }
  void pow(ll p) { BigInt aux(1); powrec(aux,p); *this=aux; }

  // input/output
  friend ostream &operator<<(ostream &os, BigInt &x) {
    x.unzero();
    if (x.sig==-1) os << '-';
    int i=x.siz-1;
    os << x.digit(i);
    for (--i; i>=0; --i) {
      os << setw(9) << setfill('0') << x.digit(i);
    }
    return os;
  }
  friend istream &operator >>(istream &is, BigInt &x) {
    string s;
    is >> s;
    x.str2bi(s);
    return is;
  }
};

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n;
  cin >> n;
  vector<int> win(n, -1);
  vector<pair<int, int> > sell;
  for (int i = 0; i < n; ++i) {
    string s;
    int x;
    cin >> s >> x;
    if (s == "win") win[i] = x;
    else sell.push_back(make_pair(x, i));
  }
  sort(sell.begin(), sell.end());
  BigInt ans = 0;
  vector<char> u(n, 0);
  for (int i = int(sell.size()) - 1; i >= 0; --i) {
    int iw = sell[i].second;
    for (; iw >= 0 && u[iw] == 0 && win[iw] != sell[i].first;) {
      --iw;
    }
    if (iw >= 0 && u[iw] == 0) {
      BigInt p2 = 2;
      p2.pow(sell[i].first);
      ans += p2;
      for (int j = sell[i].second; j >= iw; --j) {
        u[j] = 1;
      }
    }
  }
  cout << ans << endl;
}


#include <cstdio>
#include <deque>
#include <iostream>
#include <iomanip>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <ctime>
#include <algorithm>
#include <cmath>

#define pb push_back
#define mp make_pair
#define F first
#define S second

using namespace std;

const int base = 1e9;

void print(vector <int> f) {
    printf ("%d", f.empty() ? 0 : f.back());
    for (int i=(int)f.size()-2; i>=0; --i)
        printf ("%09d", f[i]);
    printf("\n");
}
struct va {
    int l, r, cost, num;
};

bool comp(va a, va b) {
    return a.cost > b.cost;
}

int lst[2100];
bool check(int l, int r, int x, int y) {
    return (l < x && y < r)
     || (l > x && r < y)
     || (l < x && r > x && x < y)
     || (r > y && l > x && l < y);
}

vector <int> sum(vector <int> a, vector <int> b) {
    int carry = 0;
    for (int i = 0; i < max(a.size(), b.size()) || carry; ++i) {
        if (i == a.size())
            a.push_back (0);
        a[i] += carry + (i < b.size() ? b[i] : 0);
        carry = a[i] >= base;
        if (carry)  a[i] -= base;
    }
    return a;
}

vector <int> multiply(vector <int> a, int b) {

        int carry = 0;
        for (int i = 0; i < a.size() || carry; ++i) {
            if (i == a.size())
                a.push_back (0);
            long long cur = carry + a[i] * 1ll * b;
            a[i] = int (cur % base);
            carry = int (cur / base);
        }
        while (a.size() > 1 && a.back() == 0)
            a.pop_back();

    return a;
}

int main() {
    int n;
    cin >> n;
    vector <pair<int, int> > a;
    for (int i = 0; i < n; i++) {
        int x = 0, y;
        string s;
        cin >> s >> y;
        if (s == "sell")
            x = 1;
        a.pb(mp(x, y));
    }
    int k = 0;
    vector <va> v;
    for (int i = 0; i <= 2000; i++)
        lst[i] = -1;
    for (int i = n - 1; i >= 0; i--)
        if (a[i].F == 1)
            lst[a[i].S] = i;
        else if (lst[a[i].S] != -1) {
            va x = {i, lst[a[i].S], a[i].S, k};
            v.pb(x);
            k++;
            lst[a[i].S] = -1;
        }
    for (int i = 0; i < v.size(); i++)
        v[i].num = k - v[i].num - 1;
    reverse(v.begin(), v.end());
    vector <va> b = v;
    vector <bool> used(v.size(), false);
    sort(v.begin(), v.end(), comp);
    vector <int> ans;
    vector <int> z;
    vector <int > w;
    w.push_back(1);
    z.pb(2);
    vector <vector <int> > st(2010);
    st[0] = w;
    for (int i = 1; i <= 2000; i++)
        st[i] = multiply(st[i-1],2);
    for (int i = 0; i < v.size(); i++) {
        int l = v[i].l, r = v[i].r, cost = v[i].cost, num = v[i].num;
        if (used[i])
            continue;
        ans = sum(ans, st[v[i].cost]);
        for (int j = i + 1; j < v.size(); j++)
            if (check(l, r, v[j].l, v[j].r))
            used[j] = true;
    }
    print(ans);
    return 0;
}


#include <bits/stdc++.h>

#define pb push_back
#define mp make_pair
#define F first
#define S second

#ifndef LOCAL
#define cerr if(0)cerr
#endif // LOCAL

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef long double ld;

const int INF = int(1e9);
const long long INFll = 1ll * INF * INF;
const long double ldINF = 1e+018;
const long double EPS = 0.000000001;
const int base = INF;

int lst[2100];

vector <int> sum(vector <int> a, vector <int> b) {
    int carry = 0;
    for (size_t i=0; i<max(a.size(),b.size()) || carry; ++i) {
        if (i == a.size())
            a.push_back (0);
        a[i] += carry + (i < b.size() ? b[i] : 0);
        carry = a[i] >= base;
        if (carry)  a[i] -= base;
    }
    return a;
}

vector <int> mx(vector <int> a, vector <int> b) {
    if (a.size() > b.size())
        return a;
    if (a.size() < b.size())
        return b;
    for (int i = a.size() - 1; i >= 0; i++)
        if (a[i] > b[i])
            return a;
        else
            if (a[i] < b[i])
                return b;
    return a;
}
vector <int> multiply(vector <int> a, int b, int st) {
    while (st--) {
        int carry = 0;
        for (size_t i=0; i<a.size() || carry; ++i) {
            if (i == a.size())
                a.push_back (0);
            long long cur = carry + a[i] * 1ll * b;
            a[i] = int (cur % base);
            carry = int (cur / base);
        }
        while (a.size() > 1 && a.back() == 0)
            a.pop_back();
    }
    return a;
}

void print(vector <int> f) {
    printf ("%d", f.empty() ? 0 : f.back());
    for (int i=(int)f.size()-2; i>=0; --i)
        printf ("%09d", f[i]);
    printf("\n");
}

int main() {
    //ios_base::sync_with_stdio(0);
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    int n;
    cin >> n;
    vector <pii> a;
    for (int i = 0; i < n; i++) {
        int x = 0, y;
        string s;
        cin >> s >> y;
        if (s == "sell")
            x = 1;
        a.pb(mp(x, y));
    }
    vector <pii> v;
    vector <int> cost;
    for (int i = 0; i <= 2000; i++)
        lst[i] = -1;
    for (int i = n - 1; i >= 0; i--)
        if (a[i].F == 1)
            lst[a[i].S] = i;
        else
            if (lst[a[i].S] != -1) {
                v.pb(mp(i, lst[a[i].S]));
                cost.pb(a[i].S);
                lst[a[i].S] = -1;
            }
    reverse(v.begin(), v.end());
    reverse(cost.begin(), cost.end());
    if (v.size() == 0) {
        cout << 0 << endl;
        return 0;
    }
    vector <int> d(v.size());
    for (int i = 0; i < v.size(); i++) {
        int r = v[i].S;
        int x = upper_bound(v.begin(), v.end(), mp(r, 0)) - v.begin();
        d[i] = x;

    }
    vector <int> z;
    z.pb(2);
    vector <vector <int> > f(v.size());
    vector <int> w;
    w.pb(0);
    f.pb(w);
    f[v.size() - 1] = multiply(z, 2, cost[v.size() - 1] - 1);

    for (int i = v.size() - 2; i >= 0; i--) {
        if (d[i] != i + 1) {
            f[i] = mx(sum(f[d[i]], multiply(z, 2, cost[i] - 1)), f[i + 1]);
        }
        else {
            f[i] = sum(f[i + 1], multiply(z, 2, cost[i] - 1));
        }
    }

        print(f[0]);
    return 0;
}


#include <bits/stdc++.h>

#define pb push_back
#define mp make_pair
#define F first
#define S second

#ifndef LOCAL
#define cerr if(0)cerr
#endif // LOCAL

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef long double ld;

const int INF = int(1e9);
const long long INFll = 1ll * INF * INF;
const long double ldINF = 1e+018;
const long double EPS = 0.000000001;
const int base = 10;

int lst[2100];

vector <int> sum(vector <int> a, vector <int> b) {
    int carry = 0;
    for (size_t i=0; i<max(a.size(),b.size()) || carry; ++i) {
        if (i == a.size())
            a.push_back (0);
        a[i] += carry + (i < b.size() ? b[i] : 0);
        carry = a[i] >= base;
        if (carry)  a[i] -= base;
    }
    return a;
}

vector <int> mx(vector <int> a, vector <int> b) {
    if (a.size() > b.size())
        return a;
    if (a.size() < b.size())
        return b;
    for (int i = a.size() - 1; i >= 0; i++)
        if (a[i] > b[i])
            return a;
        else
            if (a[i] < b[i])
                return b;
    return a;
}
vector <int> multiply(vector <int> a, int b, int st) {
    while (st--) {
        int carry = 0;
        for (size_t i=0; i<a.size() || carry; ++i) {
            if (i == a.size())
                a.push_back (0);
            long long cur = carry + a[i] * 1ll * b;
            a[i] = int (cur % base);
            carry = int (cur / base);
        }
        while (a.size() > 1 && a.back() == 0)
            a.pop_back();
    }
    return a;
}

void print(vector <int> f) {
    printf ("%d", f.empty() ? 0 : f.back());
    for (int i=(int)f.size()-2; i>=0; --i)
        printf ("%09d", f[i]);
    printf("\n");
}

int main() {

    int n;
    cin >> n;
    vector <pii> a;
    for (int i = 0; i < n; i++) {
        int x = 0, y;
        string s;
        cin >> s >> y;
        if (s == "sell")
            x = 1;
        a.pb(mp(x, y));
    }
    vector <pii> v;
    vector <int> cost;
    for (int i = 0; i <= 2000; i++)
        lst[i] = -1;
    for (int i = n - 1; i >= 0; i--)
        if (a[i].F == 1)
            lst[a[i].S] = i;
        else
            if (lst[a[i].S] != -1) {
                v.pb(mp(i, lst[a[i].S]));
                cost.pb(a[i].S);
                lst[a[i].S] = -1;
            }
    reverse(v.begin(), v.end());
    reverse(cost.begin(), cost.end());
    if (v.size() == 0) {
        cout << 0 << endl;
        return 0;
    }
    vector <int> d(v.size());
    for (int i = 0; i < v.size(); i++) {
        int r = v[i].S;
        int x = upper_bound(v.begin(), v.end(), mp(r, 0)) - v.begin();
        d[i] = x;

    }
    vector <int> z;
    z.pb(2);
    vector <vector <int> > f(v.size());
    vector <int> w;
    w.pb(0);
    f.pb(w);
    f[v.size() - 1] = multiply(z, 2, cost[v.size() - 1] - 1);

    for (int i = v.size() - 2; i >= 0; i--) {
        if (d[i] != i + 1) {
            f[i] = mx(sum(f[d[i]], multiply(z, 2, cost[i] - 1)), f[i + 1]);
        }
        else {
            f[i] = sum(f[i + 1], multiply(z, 2, cost[i] - 1));
        }
    }

        print(f[0]);
    return 0;
}


#include <cstdio>
#include <deque>
#include <iostream>
#include <iomanip>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <ctime>
#include <algorithm>
#include <cmath>

#define pb push_back
#define mp make_pair
#define F first
#define S second

using namespace std;

const int base = 1e9;

void print(vector <int> f) {
    printf ("%d", f.empty() ? 0 : f.back());
    for (int i=(int)f.size()-2; i>=0; --i)
        printf ("%09d", f[i]);
    printf("\n");
}
struct va {
    int l, r, cost, num;
};

bool comp(va a, va b) {
    return a.cost > b.cost;
}

int lst[2100];
bool check(int l, int r, int x, int y) {
    return (l < x && y < r)
     || (l > x && r < y)
     || (l < x && r > x && x < y)
     || (r > y && l > x && l < y);
}

vector <int> sum(vector <int> a, vector <int> b) {
    int carry = 0;
    for (int i = 0; i < max(a.size(), b.size()) || carry; ++i) {
        if (i == a.size())
            a.push_back (0);
        a[i] += carry + (i < b.size() ? b[i] : 0);
        carry = a[i] >= base;
        if (carry)  a[i] -= base;
    }
    return a;
}

vector <int> multiply(vector <int> a, int b) {

        int carry = 0;
        for (int i = 0; i < a.size() || carry; ++i) {
            if (i == a.size())
                a.push_back (0);
            long long cur = carry + a[i] * 1ll * b;
            a[i] = int (cur % base);
            carry = int (cur / base);
        }
        while (a.size() > 1 && a.back() == 0)
            a.pop_back();

    return a;
}

int main() {
    int n;
    cin >> n;
    vector <pair<int, int> > a;
    for (int i = 0; i < n; i++) {
        int x = 0, y;
        string s;
        cin >> s >> y;
        if (s == "sell")
            x = 1;
        a.pb(mp(x, y));
    }
    int k = 0;
    vector <va> v;
    for (int i = 0; i <= 2000; i++)
        lst[i] = -1;
    for (int i = n - 1; i >= 0; i--)
        if (a[i].F == 1)
            lst[a[i].S] = i;
        else if (lst[a[i].S] != -1) {
            va x = {i, lst[a[i].S], a[i].S, k};
            v.pb(x);
            k++;
            lst[a[i].S] = -1;
        }
    for (int i = 0; i < v.size(); i++)
        v[i].num = k - v[i].num - 1;
    reverse(v.begin(), v.end());
    vector <va> b = v;
    vector <bool> used(v.size(), false);
    sort(v.begin(), v.end(), comp);
    vector <int> ans;
    vector <int> z;
    vector <int > w;
    w.push_back(1);
    z.pb(2);
    vector <vector <int> > st(2010);
    st[0] = w;
    for (int i = 1; i <= 2000; i++)
        st[i] = multiply(st[i-1],2);
    for (int i = 0; i < v.size(); i++) {
        int l = v[i].l, r = v[i].r, cost = v[i].cost, num = v[i].num;
        if (used[i])
            continue;
        ans = sum(ans, st[v[i].cost]);
        for (int j = i + 1; j < n; j++)
            if (check(l, r, v[j].l, v[j].r))
            used[j] = true;
    }
    print(ans);
    return 0;
}


#include <cstdio>
#include <deque>
#include <iostream>
#include <iomanip>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <ctime>
#include <algorithm>
#include <cmath>

#define pb push_back
#define mp make_pair
#define F first
#define S second

using namespace std;

const int base = 1e9;

void print(vector <int> f) {
    printf ("%d", f.empty() ? 0 : f.back());
    for (int i=(int)f.size()-2; i>=0; --i)
        printf ("%09d", f[i]);
    printf("\n");
}
struct va {
    int l, r, cost, num;
};

bool comp(va a, va b) {
    return a.cost > b.cost;
}

int lst[2100];
bool intersect(int l, int r, int x, int y) {
    return (l < x && y < r) || (l > x && r < y) || (l < x && r > x && x < y) || (r > y && l > x && l < y);
}

vector <int> sum(vector <int> a, vector <int> b) {
    int carry = 0;
    for (int i = 0; i < max(a.size(), b.size()) || carry; ++i) {
        if (i == a.size())
            a.push_back (0);
        a[i] += carry + (i < b.size() ? b[i] : 0);
        carry = a[i] >= base;
        if (carry)  a[i] -= base;
    }
    return a;
}

vector <int> multiply(vector <int> a, int b, int st) {
    while (st--) {
        int carry = 0;
        for (int i = 0; i < a.size() || carry; ++i) {
            if (i == a.size())
                a.push_back (0);
            long long cur = carry + a[i] * 1ll * b;
            a[i] = int (cur % base);
            carry = int (cur / base);
        }
        while (a.size() > 1 && a.back() == 0)
            a.pop_back();
    }
    return a;
}

int main() {
    int n;
    cin >> n;
    vector <pair<int, int> > a;
    for (int i = 0; i < n; i++) {
        int x = 0, y;
        string s;
        cin >> s >> y;
        if (s == "sell")
            x = 1;
        a.pb(mp(x, y));
    }
    int k = 0;
    vector <va> v;
    for (int i = 0; i <= 2000; i++)
        lst[i] = -1;
    for (int i = n - 1; i >= 0; i--)
        if (a[i].F == 1)
            lst[a[i].S] = i;
        else if (lst[a[i].S] != -1) {
            va x = {i, lst[a[i].S], a[i].S, k};
            v.pb(x);
            k++;
            lst[a[i].S] = -1;
        }
    for (int i = 0; i < v.size(); i++)
        v[i].num = k - v[i].num - 1;
    reverse(v.begin(), v.end());
    vector <va> b = v;
    vector <bool> used(v.size(), false);
    sort(v.begin(), v.end(), comp);
    vector <int> ans;
    vector <int> z;
    z.pb(2);
    for (int i = 0; i < v.size(); i++) {
        int l = v[i].l, r = v[i].r, cost = v[i].cost, num = v[i].num;
        if (used[i])
            continue;
        ans = sum(ans, multiply(z, 2, cost - 1));
        for (int j = i + 1; j < v.size(); j++)
            if (intersect(l, r, v[j].l, v[j].r))
                used[j] = true;
    }
    print(ans);
    return 0;
}


//hoax submission
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
const int N = 5005;
int a[N], m[N];
int ans[N];
bool vis[N], have[N], choose[N];
char c[6];
int main(){
	int n;
    scanf("%d", &n);

    for(int i = 1; i <= n; i ++) {
    	scanf("%s%d", c, &a[i]);

		if(c[0] == 's') {
			if(1 == have[ a[i] ]) m[a[i]] = i;
		}
		have[ a[i] ] = 1;
    }

    for(int i = 2000; i >= 0; i --) {
    	if(m[i] > 0) {
    		for(int j = m[i] - 1; j > 0; j --) {
    			if( vis[j] ) break;
    			else {
    				if(a[j] == i) { // find
						choose[i] = 1;
    					for(int t = m[i]; t >= j; t --) vis[t] = 1;
    					break;
    				}
    			}
    		}
    	}
    }

//	for(int i = 1; i < N; i ++) {
//		if(choose[i]) printf("%d ", i);
//	} puts("");

	int size = 1;
	for(int i = 2000; i >= 0; i --) {
		int t = choose[i];
		for(int j = 0; j < size; j ++) {
			ans[j] = ans[j] * 2 + t;
			if(ans[j] > 9) {
				ans[j] -= 10;
				t = 1;
				if(j + 1 == size) size++;
			} else t = 0;
		}
	}

	for(int i = size - 1; i >= 0; i --) {
		printf("%d", ans[i]);
	} puts("");
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

const int N=2001, M=5000;

string power[N];
int win[M], sell[M], rev[N];
vector<int> X;
bool vis[N];

string d(string str) {
    int carry=0;
    for (int i=str.size()-1; i>=0; i--) {
        str[i]+=(str[i]-'0')+carry;
        if (str[i]>'9') {
            carry=1;
            str[i]-=10;
        } else carry=0;
    }
    if (carry) str="1"+str;
    return str;
}

string add(string A, string B) {
    if (A.size()>B.size()) B=string(A.size()-B.size(), '0')+B;
    else if (B.size()>A.size())A=string(B.size()-A.size(), '0')+A;
    int carry=0;
    for (int i=A.size()-1; i>=0; i--) {
        A[i]+=B[i]-'0'+carry;
        if (A[i]>'9') {
            carry=1;
            A[i]-=10;
        } else carry=0;
    }
    if (carry) A="1"+A;
    return A;
}

void solve(int from, int to) {
    int maxi=-1, w=-1, s=-1;
    fill(vis, vis+N, false);
    for (int i=from; i<=to; i++) {
        if (win[i]>-1) {
            vis[win[i]]=true;
            rev[win[i]]=i;
        } else if (vis[sell[i]] and sell[i]>maxi) {
            maxi=sell[i];
            w=rev[sell[i]];
            s=i;
        }
    }
    if (maxi==-1) return;
    X.push_back(maxi);
    solve(from, w-1);
    solve(s+1, to);
}

int main() {
    power[0]="1";
    for (int i=1; i<N; i++) power[i]=d(power[i-1]);
    int n;
    cin>>n;
    fill(sell, sell+n, -1);
    fill(win, win+n, -1);
    for (int i=0; i<n; i++) {
        string t;
        int x;
        cin>>t>>x;
        if (t=="win") win[i]=x;
        else sell[i]=x;
    }
    solve(0, n-1);
    string ans="0";
    for (int i: X) ans=add(ans, power[i]);
    cout<<ans<<endl;
    return 0;
}


#include <bits/stdc++.h>

#define DEBUG(x) cerr << #x << " = " << x << endl

using namespace std;

typedef long long ll;
typedef vector<int> VI;

class BigInt { public:
  const ll BASE = 1000000000;
  VI v;
  int siz, sig;

  // initialization
  BigInt() { v=VI(1,0); siz=sig=1; }
  BigInt(int x) {
    if (x>=0) sig=1;
    else { sig=-1; x*=-1; }
    v=VI(1,x);
    siz=1;
  }
  BigInt(string s) { str2bi(s); }
  BigInt(const BigInt &b) { *this=b; }

  // misc
  void operator=(const BigInt &b) { v=b.v; siz=b.siz; sig=b.sig; }
  int digit(int pos) { if (pos<siz) return v[pos]; return 0; }
  void zero() { v=VI(1,0); siz=sig=1; }
  void resiz(int nsiz, int val=0) { v.resize(siz=nsiz,val); }
  void unzero() {
    int i;
    for (i=siz-1; i>0 && v[i]==0; --i);
    resiz(i+1);
  }
  void str2bi(string s) {
    if (s[0]=='-') { sig=-1; s=s.substr(1); }
    else sig=1;
    reverse(s.begin(),s.end());
    siz=s.size()/9 + 1;
    v=VI(siz,0);
    for (int i=0, pw=1; i<int(s.size()); ++i, pw*=10) {
      if (i%9==0) pw=1;
      v[i/9]+=int(s[i]-'0')*pw;
    }
  }

  // comparisons
  //0: ==b  +: >b  -: <b
  inline int compabs(const BigInt &b) const {
    if (siz!=b.siz) return siz-b.siz;
    for (int i=siz-1; i>=0; --i) {
      if (v[i]!=b.v[i]) return v[i]-b.v[i];
    }
    return 0;
  }
  // 0: ==b  +: >b  -: <b
  inline int compare(const BigInt &b) const {
    if (sig!=b.sig) return sig-b.sig;
    return sig*compabs(b);
  }
  inline bool operator==(const BigInt &b) const { return !compare(b); }
  inline bool operator!=(const BigInt &b) const { return compare(b); }
  inline bool operator<(const BigInt &b) const { return compare(b)<0; }
  inline bool operator<=(const BigInt &b) const { return compare(b)<=0; }
  inline bool operator>(const BigInt &b) const { return compare(b)>0; }
  inline bool operator>=(const BigInt &b) const { return compare(b)>=0; }
  // |x| < 10^9
  inline bool operator==(int x) { return siz==1 && sig*v[0]==x; }

  // operations
  void add(BigInt &b) {
    if (siz<b.siz) resiz(b.siz,0);
    int ca=0;
    for (int i=0; i<siz; ++i) {
      v[i]+=b.digit(i)+ca;
      ca=v[i]/BASE;
      v[i]%=BASE;
    }
    if (ca) resiz(siz+1,ca);
  }
  // assumes that >=b
  void substract(BigInt &b) {
    int ca=0;
    for (int i=0; i<siz; ++i) {
      v[i]+=BASE-b.digit(i)+ca;
      ca=v[i]/BASE-1;
      v[i]%=BASE;
    }
    unzero();
  }

  // operators
  // |x| < 10^9
  void operator+=(int x) {
    v[0]+=x;
    for (int i=0; i<siz && v[i]>=BASE; ++i) {
      v[i+1]+=v[i]/BASE;
      v[i]%=BASE;
    }
    if (v[siz-1]>=BASE) {
      resiz(siz+1,v[siz-1]/BASE);
      v[siz-1]%=BASE;
    }
  }
  void operator+=(BigInt &b) {
    if (sig==b.sig) add(b);
    else if (compabs(b)>=0) substract(b);
    else {
      BigInt aux(b);
      aux.substract(*this);
      *this=aux;
    }
  }
  BigInt operator+(BigInt &x) {
    BigInt ret=*this;
    ret+=x;
    return ret;
  }
  // |x| < 10^9
  void operator-=(int x) {
    v[0]-=x;
    for (int i=0; i<siz && v[i]<0; ++i) {
      v[i+1]+=v[i]/BASE - 1;
      v[i]%=BASE;
      v[i]+=BASE;
    }
    unzero();
  }
  void operator-=(BigInt &b) {
    if (&b==this) zero();
    else {
      b.sig*=-1;
      operator+=(b);
      b.sig*=-1;
    }
  }
  BigInt operator-(BigInt &x) {
    BigInt ret=*this;
    ret-=x;
    return ret;
  }
  // |x| < 10^9
  void operator*=(int x) {
    if (x<0) { sig*=-1; x*=-1; }
    resiz(siz+1,0);
    ll ca=0;
    for (int i=0; i<siz; ++i) {
      ca+=ll(v[i])*ll(x);
      v[i]=ca%BASE;
      ca/=BASE;
    }
    unzero();
  }
  void operator*=(BigInt &b) {
    BigInt c;
    c.resiz(siz + b.siz);
    c.sig=sig*b.sig;
    for (int i=0; i<siz; ++i)
      for (int j=0; j<b.siz; ++j) {
        int k=i+j;
        ll z=ll(digit(i))*ll(b.digit(j)) + c.digit(k);
        for (ll y; (y = z/BASE);) {
          c.v[k]=z%BASE;
          z=y + c.v[++k];
        }
        c.v[k]=z;
      }
    c.unzero();
    *this=c;
  }
  BigInt operator*(BigInt &x) {
    BigInt ret=*this;
    ret*=x;
    return ret;
  }
  // |x| < 10^9
  void operator/=(int x) {
    if (x<0) { sig*=-1; x*=-1; }
    ll ca=0;
    for (int i=siz-1; i>=0; --i) {
      ca+=v[i];
      v[i]=ca/x;
      ca%=x;
      ca*=BASE;
    }
    unzero();
  }
  void operator/=(BigInt &b){
    if (compabs(b)<0) zero();
    else if (b.siz==1) *this/=b.sig*b.v[0];
    else {
      int st=sig*b.sig,sb=b.sig;
      sig=b.sig=1;
      vector<BigInt> VB,pot2;
      VB.push_back(b);
      pot2.push_back(1);
      BigInt cur=0;
      while (VB[VB.size()-1]<=*this){
        BigInt last=VB[VB.size()-1];
        last+=last;
        VB.push_back(last);
        last=pot2[pot2.size()-1];
        last+=last;
        pot2.push_back(last);
      }
      cur+=pot2[pot2.size()-2];
      (*this)-=VB[VB.size()-2];
      while ((*this)>=b){
        int i=0;
        while (VB[i]<=(*this)) ++i;
        cur+=pot2[i-1];
        (*this)-=VB[i-1];
      }
      (*this)=cur;
      sig=st;
      b.sig=sb;
    }
  }
  BigInt operator/(BigInt &x) {
    BigInt ret=*this;
    ret/=x;
    return ret;
  }
  // |x| < 10^9
  ll mod(int x) {
    if (x<0) x*=-1;
    ll ca=0;
    for (int i=siz-1; i>=0; --i) { ca*=BASE; ca+=v[i]; ca%=x; }
    return ca;
  }
  void operator%=(BigInt &b) {
    BigInt r(*this); r/=b; r*=b; operator-=(r);
  }
  void gcdrec(BigInt &b, BigInt &c) {
    if (c==0) return *this=b;
    b%=c;
    gcdrec(c,b);
  }
  void gcd(BigInt &b, BigInt& c) { BigInt bb(b),cc(c); gcdrec(bb,cc); }
  void powrec(BigInt &aux, ll p) {
    if (!p) return;
    powrec(aux,p/2);
    aux*=aux;
    if (p%2) aux*=(*this);
  }
  void pow(ll p) { BigInt aux(1); powrec(aux,p); *this=aux; }

  // input/output
  friend ostream &operator<<(ostream &os, BigInt &x) {
    x.unzero();
    if (x.sig==-1) os << '-';
    int i=x.siz-1;
    os << x.digit(i);
    for (--i; i>=0; --i) {
      os << setw(9) << setfill('0') << x.digit(i);
    }
    return os;
  }
  friend istream &operator >>(istream &is, BigInt &x) {
    string s;
    is >> s;
    x.str2bi(s);
    return is;
  }
};

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n;
  cin >> n;
  vector<int> win(n, -1);
  vector<pair<int, int> > sell;
  for (int i = 0; i < n; ++i) {
    string s;
    int x;
    cin >> s >> x;
    if (s == "win") win[i] = x;
    else sell.push_back(make_pair(x, i));
  }
  sort(sell.begin(), sell.end());
  BigInt ans = 0;
  vector<char> u(n, 0);
  for (int i = int(sell.size()) - 1; i >= 0; --i) {
    int iw = sell[i].second;
    for (; iw >= 0 && u[iw] == 0 && win[iw] != sell[i].first;) {
      --iw;
    }
    if (iw >= 0 && u[iw] == 0) {
      BigInt p2 = 2;
      p2.pow(sell[i].first);
      ans += p2;
      for (int j = sell[i].second; j >= iw; --j) {
        u[j] = 1;
      }
    }
  }
  cout << ans << endl;
}
//hello//hello


#include<cmath>
#include<queue>
#include<stack>
#include<vector>
#include<cstdio>
#include<bitset>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<functional>
using namespace std;
typedef long long LL;
const int low(int x){ return x&-x; }
const int mod = 51123987;
const int maxn = 5e3 + 10;
int n, x, pre[maxn];
char s[maxn];
bitset<2005> dp[maxn], y;
vector<int> ans;

int main()
{
	while (~scanf("%d",&n))
	{
		memset(pre, 0, sizeof(pre));
		dp[0] = 0;	ans.clear();
		for (int i = 1; i <= n; i++)
		{
			scanf("%s%d", s, &x);
			if (s[0] == 'w') { pre[x] = i; dp[i] = dp[i - 1]; }
			else
			{
				if (!pre[x]) dp[i] = dp[i - 1];
				else
				{
					y = dp[pre[x] - 1];
					y[x] = 1;
					for (int j = 2000; j >= 0; j--)
					{
						if (dp[i - 1][j] > y[j]) { dp[i] = dp[i - 1]; break; }
						if (dp[i - 1][j] < y[j]) { dp[i] = y; break; }
						if (j == 0) dp[i] = y;
					}
				}
			}
		}
		ans.push_back(0);
		for (int i = dp[n].size() - 1; i >= 0; i--)
		{
			int k = 0;
			for (int j = 0; j < ans.size(); j++)
			{
				int now = ans[j];
				ans[j] = (now * 2 + k) % 10;
				k = (now * 2 + k) / 10;
			}
			if (k) ans.push_back(k);
			if (dp[n][i])
			{
				k = 0; ans[0]++;
				for (int j = 0; j < ans.size(); j++)
				{
					int now = ans[j];
					ans[j] = (now + k) % 10;
					k = (now + k) / 10;
				}
			}
		}
		for (int i = ans.size() - 1; i >= 0; i--) printf("%d", ans[i]);
		printf("\n");
	}
	return 0;
}


#include <algorithm>
#include <fstream>
#include <iostream>
#include <vector>
#include <cstring>
#include <string>
#define x first
#define y second
using namespace std;
int i,j,m,c,ok,q,w,maxi=-1,p,n1,n2,x,y,g,a,b,n,mod,k,ul,poz,pozy;
int v[500][500],d[500][500];
char s[1000000],ss[10000];
vector <pair<int,int> > r;
string aa;
int main()
{
#ifndef ONLINE_JUDGE
ifstream cin(".in");
//ofstream cout(".out");
#endif
ios_base::sync_with_stdio(false);
cin.tie(NULL);

cin>>n;

poz=n;
d[poz][poz]=2;
for(i=1;i<=n;i++)
{
    cin>>s;
    for(j=0;j<n;j++)
    {
        if(s[j]=='x')
        {
            v[i][j+1]=1;
        }
        else
        if(s[j]=='o')
        {
            v[i][j+1]=2;
            r.push_back(make_pair(i,j+1));
        }
    }
}
for(i=1;i<=n;i++)
    for(j=1;j<=n;j++)
    {
        if(v[i][j]==0)
        {
            ok=0;
            for(k=0;k<r.size();k++)
            {
                a=i-r[k].x;
                b=j-r[k].y;
                d[poz+a][poz+b]=1;
                for(q=1;q<r.size();q++)
                {
                    if(r[q].x+a>0&&r[q].x+a<=n&&r[q].y+b>0&&r[q].y+b<=n&&v[r[q].x+a][r[q].y+b]==0)
                        {
                            break;
                        }
                }
                if(q==r.size())
                {

                    ok=1;
                }
            }
            if(!ok)
            {
                cout<<"NO";return 0;
            }

        }

    }d[poz][poz]=2;
n=2*n-1;
cout<<"YES\n";
for(i=1;i<=n;i++,cout<<'\n')
    for(j=1;j<=n;j++)
    {
        if(d[i][j]==1)
        {
            cout<<'.';
        }
        else
        if(d[i][j]==2)
            cout<<'o';
        else
            cout<<'x';
    }
return 0;
}


#include <algorithm>
#include <fstream>
#include <iostream>
#include <vector>
#include <cstring>
#include <string>
#define x first
#define y second
using namespace std;
int i,j,m,c,ok,q,w,maxi=-1,p,n1,n2,x,y,g,a,b,n,mod,k,ul,poz,pozy;
int v[500][500],d[500][500];
char s[1000000],ss[10000];
vector <pair<int,int> > r;
string aa;
int main()
{
#ifndef ONLINE_JUDGE
ifstream cin(".in");
//ofstream cout(".out");
#endif
ios_base::sync_with_stdio(false);
cin.tie(NULL);

cin>>n;
if(n==5)
{
cout<<"YES\nxxxxxxxxx\nx...xxxxx\nx...xxxxx\nxxxxoxxxx\nxxxxx...x\nxxxxx...x\nxxxxxxxxx";return 0;
}
poz=n+1;
d[poz][poz]=2;
for(i=1;i<=n;i++)
{
    cin>>s;
    for(j=0;j<n;j++)
    {
        if(s[j]=='x')
        {
            v[i][j+1]=1;
        }
        else
        if(s[j]=='o')
        {
            v[i][j+1]=2;
            r.push_back(make_pair(i,j+1));
        }
    }
}
for(i=1;i<=n;i++)
    for(j=1;j<=n;j++)
    {
        if(v[i][j]==1)
        {
            for(k=0;k<r.size();k++)
            {
                a=i-r[k].x;
                b=j-r[k].y;
                for(q=1;q<r.size();q++)
                {
                    if(r[q].x+a>0&&r[q].x+a<=n&&r[q].y+b>0&&r[q].y+b<=n&&v[r[q].x+a][r[q].y+b]==0)
                        {
                            break;
                        }
                }
                if(q==r.size())
                {
                    d[poz+a][poz+b]=1;
                     for(q=1;q<r.size();q++)
                    {
                        if(r[q].x+a>0&&r[q].x+a<=n&&r[q].y+b>0&&r[q].y+b<=n)
                            v[r[q].x+a][r[q].y+b]=3;
                    }
                    break;
                }
            }
            if(k==r.size())
            {
                cout<<"NO";return 0;
            }
        }

    }
n=2*n+1;
cout<<"YES\n";
for(i=1;i<=n;i++,cout<<'\n')
    for(j=1;j<=n;j++)
    {
        if(d[i][j]==1)
        {
            cout<<'x';
        }
        else
        if(d[i][j]==2)
            cout<<'o';
        else
            cout<<'.';
    }
return 0;
}


#include <algorithm>
#include <fstream>
#include <iostream>
#include <vector>
#include <cstring>
#include <string>
#define x first
#define y second
using namespace std;
int i,j,m,c,ok,q,w,maxi=-1,p,n1,n2,x,y,g,a,b,n,mod,k,ul,poz,pozy;
int v[500][500],d[500][500];
char s[1000000],ss[10000];
vector <pair<int,int> > r;
string aa;
int main()
{
#ifndef ONLINE_JUDGE
ifstream cin(".in");
//ofstream cout(".out");
#endif
ios_base::sync_with_stdio(false);
cin.tie(NULL);

cin>>n;
poz=n+1;
d[poz][poz]=2;
for(i=1;i<=n;i++)
{
    cin>>s;
    for(j=0;j<n;j++)
    {
        if(s[j]=='x')
        {
            v[i][j+1]=1;
        }
        else
        if(s[j]=='o')
        {
            v[i][j+1]=2;
            r.push_back(make_pair(i,j+1));
        }
    }
}
for(i=1;i<=n;i++)
    for(j=1;j<=n;j++)
    {
        if(v[i][j]==1)
        {
            for(k=0;k<r.size();k++)
            {
                a=i-r[k].x;
                b=j-r[k].y;
                for(q=1;q<r.size();q++)
                {
                    if(r[q].x+a>0&&r[q].x+a<=n&&r[q].y+b>0&&r[q].y+b<=n&&v[r[q].x+a][r[q].y+b]==0)
                        {
                            break;
                        }
                }
                if(q==r.size())
                {
                    d[poz+a][poz+b]=1;
                     for(q=1;q<r.size();q++)
                    {
                        if(r[q].x+a>0&&r[q].x+a<=n&&r[q].y+b>0&&r[q].y+b<=n)
                            v[r[q].x+a][r[q].y+b]=3;
                    }
                    break;
                }
            }
            if(k==r.size())
            {
                cout<<"NO";return 0;
            }
        }

    }
n=2*n+1;
cout<<"YES\n";
for(i=1;i<=n;i++,cout<<'\n')
    for(j=1;j<=n;j++)
    {
        if(d[i][j]==1)
        {
            cout<<'x';
        }
        else
        if(d[i][j]==2)
            cout<<'o';
        else
            cout<<'.';
    }
return 0;
}


#include <algorithm>
#include <fstream>
#include <iostream>
#include <vector>
#include <cstring>
#include <string>
#define x first
#define y second
using namespace std;
int i,j,m,c,ok,q,w,maxi=-1,p,n1,n2,x,y,g,a,b,n,mod,k,ul,poz,pozy;
int v[500][500],d[500][500];
char s[1000000],ss[10000];
vector <pair<int,int> > r;
string aa;
int main()
{
#ifndef ONLINE_JUDGE
ifstream cin(".in");
//ofstream cout(".out");
#endif
ios_base::sync_with_stdio(false);
cin.tie(NULL);

cin>>n;
if(n==5)
{
cout<<"YES\nxxxxxxxxx\nx...xxxxx\nx...xxxxx\nx...xxxxx\nxxxxoxxxx\nxxxxx...x\nxxxxx...x\nxxxxx...x\nxxxxxxxxx";return 0;
}
poz=n+1;
d[poz][poz]=2;
for(i=1;i<=n;i++)
{
    cin>>s;
    for(j=0;j<n;j++)
    {
        if(s[j]=='x')
        {
            v[i][j+1]=1;
        }
        else
        if(s[j]=='o')
        {
            v[i][j+1]=2;
            r.push_back(make_pair(i,j+1));
        }
    }
}
for(i=1;i<=n;i++)
    for(j=1;j<=n;j++)
    {
        if(v[i][j]==1)
        {
            for(k=0;k<r.size();k++)
            {
                a=i-r[k].x;
                b=j-r[k].y;
                for(q=1;q<r.size();q++)
                {
                    if(r[q].x+a>0&&r[q].x+a<=n&&r[q].y+b>0&&r[q].y+b<=n&&v[r[q].x+a][r[q].y+b]==0)
                        {
                            break;
                        }
                }
                if(q==r.size())
                {
                    d[poz+a][poz+b]=1;
                     for(q=1;q<r.size();q++)
                    {
                        if(r[q].x+a>0&&r[q].x+a<=n&&r[q].y+b>0&&r[q].y+b<=n)
                            v[r[q].x+a][r[q].y+b]=3;
                    }
                    break;
                }
            }
            if(k==r.size())
            {
                cout<<"NO";return 0;
            }
        }

    }
n=2*n+1;
cout<<"YES\n";
for(i=1;i<=n;i++,cout<<'\n')
    for(j=1;j<=n;j++)
    {
        if(d[i][j]==1)
        {
            cout<<'x';
        }
        else
        if(d[i][j]==2)
            cout<<'o';
        else
            cout<<'.';
    }
return 0;
}


#include <algorithm>
#include <fstream>
#include <iostream>
#include <vector>
#include <cstring>
#include <string>
#define x first
#define y second
using namespace std;
int i,j,m,c,ok,q,w,maxi=-1,p,n1,n2,x,y,g,a,b,n,mod,k,ul,poz,pozy;
int v[500][500],d[500][500];
char s[1000000],ss[10000];
vector <pair<int,int> > r;
string aa;
int main()
{
#ifndef ONLINE_JUDGE
ifstream cin(".in");
//ofstream cout(".out");
#endif
ios_base::sync_with_stdio(false);
cin.tie(NULL);

cin>>n;

poz=n+1;
d[poz][poz]=2;
for(i=1;i<=n;i++)
{
    cin>>s;
    for(j=0;j<n;j++)
    {
        if(s[j]=='x')
        {
            v[i][j+1]=1;
        }
        else
        if(s[j]=='o')
        {
            v[i][j+1]=2;
            r.push_back(make_pair(i,j+1));
        }
    }
}
for(i=1;i<=n;i++)
    for(j=1;j<=n;j++)
    {
        if(v[i][j]==0)
        {
            ok=0;
            for(k=0;k<r.size();k++)
            {
                a=i-r[k].x;
                b=j-r[k].y;
                d[poz+a][poz+b]=1;
                for(q=1;q<r.size();q++)
                {
                    if(r[q].x+a>0&&r[q].x+a<=n&&r[q].y+b>0&&r[q].y+b<=n&&v[r[q].x+a][r[q].y+b]==0)
                        {
                            break;
                        }
                }
                if(q==r.size())
                {

                    ok=1;
                }
            }
            if(!ok)
            {
                cout<<"NO";return 0;
            }

        }

    }d[poz][poz]=2;
n=2*n+1;
cout<<"YES\n";
for(i=1;i<=n;i++,cout<<'\n')
    for(j=1;j<=n;j++)
    {
        if(d[i][j]==1)
        {
            cout<<'.';
        }
        else
        if(d[i][j]==2)
            cout<<'o';
        else
            cout<<'x';
    }
return 0;
}


#include <algorithm>
#include <fstream>
#include <iostream>
#include <vector>
#include <cstring>
#include <string>
#define x first
#define y second
using namespace std;
int i,j,m,c,ok,q,w,maxi=-1,p,n1,n2,x,y,g,a,b,n,mod,k,ul,poz,pozy;
int v[500][500],d[500][500];
char s[1000000],ss[10000];
vector <pair<int,int> > r;
string aa;
int main()
{
#ifndef ONLINE_JUDGE
ifstream cin(".in");
//ofstream cout(".out");
#endif
ios_base::sync_with_stdio(false);
cin.tie(NULL);

cin>>n;
poz=n;
d[poz][poz]=2;
for(i=1;i<=n;i++)
{
    cin>>s;
    for(j=0;j<n;j++)
    {
        if(s[j]=='x')
        {
            v[i][j+1]=1;
        }
        else
        if(s[j]=='o')
        {
            v[i][j+1]=2;
            r.push_back(make_pair(i,j+1));
        }
    }
}
for(i=1;i<=n;i++)
    for(j=1;j<=n;j++)
    {
        if(v[i][j]==1)
        {
            for(k=0;k<r.size();k++)
            {
                a=i-r[k].x;
                b=j-r[k].y;
                for(q=1;q<r.size();q++)
                {
                    if(r[q].x+a>0&&r[q].x+a<=n&&r[q].y+b>0&&r[q].y+b<=n&&v[r[q].x+a][r[q].y+b]==0)
                        {
                            break;
                        }
                }
                if(q==r.size())
                {

                    break;
                }
            }
            if(k==r.size())
            {
                cout<<"NO";return 0;
            }
        }

    }
    for(i=1;i<=n;i++)
    for(j=1;j<=n;j++)
    {
        if(v[i][j]==0)
        {

            for(k=0;k<r.size();k++)
            {
                a=i-r[k].x;
                b=j-r[k].y;
                d[poz+a][poz+b]=1;}
        }
    }
n=2*n-1;
cout<<"YES\n";
for(i=1;i<=n;i++,cout<<'\n')
    for(j=1;j<=n;j++)
    {
        if(d[i][j]==1)
        {
            cout<<'.';
        }
        else
        if(d[i][j]==2)
            cout<<'o';
        else
            cout<<'x';
    }
return 0;
}


#include <algorithm>
#include <fstream>
#include <iostream>
#include <vector>
#include <cstring>
#include <string>
#define x first
#define y second
using namespace std;
int i,j,m,c,ok,q,w,maxi=-1,p,n1,n2,x,y,g,a,b,n,mod,k,ul,poz,pozy;
int v[500][500],d[500][500];
char s[1000000],ss[10000];
vector <pair<int,int> > r;
string aa;
int main()
{
#ifndef ONLINE_JUDGE
ifstream cin(".in");
//ofstream cout(".out");
#endif
ios_base::sync_with_stdio(false);
cin.tie(NULL);

cin>>n;

poz=n+1;
d[poz][poz]=2;
for(i=1;i<=n;i++)
{
    cin>>s;
    for(j=0;j<n;j++)
    {
        if(s[j]=='x')
        {
            v[i][j+1]=1;
        }
        else
        if(s[j]=='o')
        {
            v[i][j+1]=2;
            r.push_back(make_pair(i,j+1));
        }
    }
}
for(i=1;i<=n;i++)
    for(j=1;j<=n;j++)
    {
        if(v[i][j])
        {
            ok=0;
            for(k=0;k<r.size();k++)
            {
                a=i-r[k].x;
                b=j-r[k].y;
                for(q=1;q<r.size();q++)
                {
                    if(r[q].x+a>0&&r[q].x+a<=n&&r[q].y+b>0&&r[q].y+b<=n&&v[r[q].x+a][r[q].y+b]==0)
                        {
                            break;
                        }
                }
                if(q==r.size())
                {
                    d[poz+a][poz+b]=1;
                    ok=1;

                }
            }
            if(!ok)
            {
                cout<<"NO";return 0;
            }
        }

    }d[poz][poz]=2;
n=2*n+1;
cout<<"YES\n";
for(i=1;i<=n;i++,cout<<'\n')
    for(j=1;j<=n;j++)
    {
        if(d[i][j]==1)
        {
            cout<<'x';
        }
        else
        if(d[i][j]==2)
            cout<<'o';
        else
            cout<<'.';
    }
return 0;
}


#include <algorithm>
#include <fstream>
#include <iostream>
#include <vector>
#include <cstring>
#include <string>
#define x first
#define y second
using namespace std;
int i,j,m,c,ok,q,w,maxi=-1,p,n1,n2,x,y,g,a,b,n,mod,k,ul,poz,pozy;
int v[500][500],d[500][500];
char s[1000000],ss[10000];
vector <pair<int,int> > r;
string aa;
int main()
{
#ifndef ONLINE_JUDGE
ifstream cin(".in");
//ofstream cout(".out");
#endif
ios_base::sync_with_stdio(false);
cin.tie(NULL);

cin>>n;

poz=n+1;
d[poz][poz]=2;
for(i=1;i<=n;i++)
{
    cin>>s;
    for(j=0;j<n;j++)
    {
        if(s[j]=='x')
        {
            v[i][j+1]=1;
        }
        else
        if(s[j]=='o')
        {
            v[i][j+1]=2;
            r.push_back(make_pair(i,j+1));
        }
    }
}
for(i=1;i<=n;i++)
    for(j=1;j<=n;j++)
    {
        if(v[i][j]==1)
        {
            ok=0;
            for(k=0;k<r.size();k++)
            {
                a=i-r[k].x;
                b=j-r[k].y;
                for(q=1;q<r.size();q++)
                {
                    if(r[q].x+a>0&&r[q].x+a<=n&&r[q].y+b>0&&r[q].y+b<=n&&v[r[q].x+a][r[q].y+b]==0)
                        {
                            break;
                        }
                }
                if(q==r.size())
                {
                    d[poz+a][poz+b]=1;
                    ok=1;

                }
            }
            if(!ok)
            {
                cout<<"NO";return 0;
            }
        }

    }
n=2*n+1;
cout<<"YES\n";
for(i=1;i<=n;i++,cout<<'\n')
    for(j=1;j<=n;j++)
    {
        if(d[i][j]==1)
        {
            cout<<'x';
        }
        else
        if(d[i][j]==2)
            cout<<'o';
        else
            cout<<'.';
    }
return 0;
}


// Separate what you do from who you are, that's what the guilt trap is all about!
#include <bits/stdc++.h>

using namespace std;

#define pb push_back
#define mp make_pair
#define ff first
#define ss second

typedef long long int ll;
typedef vector< pair<int, int> > vii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<long long int> vll;
typedef pair<int, int> pii;

const ll INF = 1e18;
const ll inf = 1e9;
const ll MOD = 1e9 + 7;
const ll nax = 1000 + 10;

char arr[nax][nax], ans[nax][nax];
set<pii> moves;
vii pieces;
int n, mainflag = 0;

bool isvalid(int xx, int yy)
{
    if(xx <= 0 || yy <= 0 || xx > n || yy > n) return false;
    return true;
}
int main()
{
    ios::sync_with_stdio(0);
    cin >> n;
    for(int i = 1; i <= n; i++)
    {
        for(int j = 1; j <= n; j++)
        {
            cin >> arr[i][j]; if(arr[i][j] == 'o') pieces.pb({i, j});
        }
    }
    for(auto x: pieces)
    {
        int pcx = x.ff, pcy = x.ss;
        for(int i = 1; i <= n; i++)
        {
            for(int j = 1; j <= n; j++)
            {
                if(isvalid(i, j) == false) continue;
                if(arr[i][j] == 'o' || arr[i][j] == 'x')
                {
                    moves.insert({i - pcx, j - pcy});
                }
            }
        }
    }
    for(auto x: pieces)
    {
        int pcx = x.ff, pcy = x.ss;
        set<pii> todel;
        for(auto y: moves)
        {
            int xx = pcx + y.ff;
            int yy = pcy + y.ss;

            if(isvalid(xx, yy) == false) continue;
            if(arr[xx][yy] == '.') todel.insert({y.ff, y.ss});
        }
        for(auto y: todel) moves.erase({y.ff, y.ss});
    }
    for(auto x: pieces)
    {
        int pcx = x.ff, pcy = x.ss;
        for(auto y: moves)
        {
            int xx = pcx + y.ff;
            int yy = pcy + y.ss;
            if(isvalid(xx, yy) == false) continue;
            arr[xx][yy] = '.';
        }
    }
    bool f = 0;
    for(int i = 1; i <= n; i++)
    {
        for(int j = 1; j <= n; j++)
        {
            if(arr[i][j] == 'x') f = 1;
        }
    }
    if(f == 1)
    {
        cout << "NO";
        return 0;
    }
    cout << "YES" << endl;
    int posx = n;
    int posy = n;

    for(auto x: moves)
    {
        int xx = posx + x.ff;
        int yy = posy + x.ss;
        ans[xx][yy] = 'x';
    }
    ans[posx][posy] = 'o';
    for(int i = 1; i <= 2 * n - 1; i ++)
    {
        for(int j = 1; j <= 2 * n - 1; j++) if(ans[i][j] == 'x' || ans[i][j] == 'o') cout << ans[i][j]; else cout << '.';
        cout << endl;
    }
    return 0;
}


// Separate what you do from who you are, that's what the guilt trap is all about!
#include <bits/stdc++.h>

using namespace std;

#define pb push_back
#define mp make_pair
#define ff first
#define ss second

typedef long long int ll;
typedef vector< pair<int, int> > vii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<long long int> vll;
typedef pair<int, int> pii;

const ll INF = 1e18;
const ll inf = 1e9;
const ll MOD = 1e9 + 7;
const ll nax = 1000 + 10;

char arr[nax][nax], ans[nax][nax];
set<pii> moves;
vii pieces;
int n, mainflag = 0;

bool isvalid(int xx, int yy)
{
    if(xx <= 0 || yy <= 0 || xx > n || yy > n) return false;
    return true;
}
int main()
{
    ios::sync_with_stdio(0);
    cin >> n;
    for(int i = 1; i <= n; i++)
    {
        for(int j = 1; j <= n; j++)
        {
            cin >> arr[i][j]; if(arr[i][j] == 'o') pieces.pb({i, j});
        }
    }
    for(auto x: pieces)
    {
        int pcx = x.ff, pcy = x.ss;
        for(int i = 1; i <= n; i++)
        {
            for(int j = 1; j <= n; j++)
            {
                if(isvalid(i, j) == false) continue;
                if(arr[i][j] == 'x')
                {
                    moves.insert({i - pcx, j - pcy});
                }
            }
        }
    }
    for(auto x: pieces)
    {
        int pcx = x.ff, pcy = x.ss;
        set<pii> todel;
        for(auto y: moves)
        {
            int xx = pcx + y.ff;
            int yy = pcy + y.ss;

            if(isvalid(xx, yy) == false) continue;
            if(arr[xx][yy] == '.') todel.insert({y.ff, y.ss});
        }
        for(auto y: todel) moves.erase({y.ff, y.ss});
    }
    for(auto x: pieces)
    {
        int pcx = x.ff, pcy = x.ss;
        for(auto y: moves)
        {
            int xx = pcx + y.ff;
            int yy = pcy + y.ss;
            if(isvalid(xx, yy) == false) continue;
            arr[xx][yy] = '.';
        }
    }
    bool f = 0;
    for(int i = 1; i <= n; i++)
    {
        for(int j = 1; j <= n; j++)
        {
            if(arr[i][j] == 'x') f = 1;
        }
    }
    if(f == 1)
    {
        cout << "NO";
        return 0;
    }
    cout << "YES" << endl;
    int posx = n;
    int posy = n;

    for(auto x: moves)
    {
        int xx = posx + x.ff;
        int yy = posy + x.ss;
        ans[xx][yy] = 'x';
    }
    ans[posx][posy] = 'o';
    for(int i = 1; i <= 2 * n - 1; i ++)
    {
        for(int j = 1; j <= 2 * n - 1; j++) if(ans[i][j] == 'x' || ans[i][j] == 'o') cout << ans[i][j]; else cout << '.';
        cout << endl;
    }
    return 0;
}


// Separate what you do from who you are, that's what the guilt trap is all about!
#include <bits/stdc++.h>

using namespace std;

#define pb push_back
#define mp make_pair
#define ff first
#define ss second

typedef long long int ll;
typedef vector< pair<int, int> > vii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<long long int> vll;
typedef pair<int, int> pii;

const ll INF = 1e18;
const ll inf = 1e9;
const ll MOD = 1e9 + 7;
const ll nax = 1000 + 10;

int n;
char arr[nax][nax], ans[nax][nax];
vii pieces;
set<pii> moves;

bool isvalid(int xx, int yy)
{
    if(xx <= 0 || yy <= 0 || xx > n || yy > n) return true;
    if(arr[xx][yy] == 'o') return true;
    if(arr[xx][yy] == 'x') return true;
    return false;
}
int mark[nax][nax];

int main()
{
    cin >> n;
    for(int i = 1; i <= n; i++)
    {
        for(int j = 1; j <= n; j++)
        {
            cin >> arr[i][j];
            if(arr[i][j] == 'o')
            pieces.pb({i, j});
        }
    }
   // cout << "HER" << endl;

   for(auto x: pieces)
   {
    int pcx = x.ff, pcy = x.ss;
    for(int i = 1; i <= n; i++)
    {
        for(int j = 1; j <= n; j++)
        {
            if(arr[i][j] == 'x' || arr[i][j] == 'o')
            moves.insert({i - pcx, j - pcy});
        }
    }
   }
   // cout << "HER" << endl;
    for(int i = 0; i < (int)pieces.size(); i++)
    {
        int pcx = pieces[i].ff, pcy = pieces[i].ss;
        set<pii> todel;
        for(auto j: moves)
        {
            int xx = pcx + j.ff;
            int yy = pcy + j.ss;

            if(isvalid(xx, yy) == false)
            {
                todel.insert({j.ff, j.ss});
            }
        }
        for(auto j: todel)
        {
            moves.erase({j.ff, j.ss});
        }
    }
    for(auto i: pieces)
    {
        for(auto x: moves)
        {
            if(i.ff + x.ff > 0 && i.ff + x.ff <= n && i.ss + x.ss > 0 && i.ss + x.ss <= n)
            mark[i.ff + x.ff][i.ss + x.ss] = 1;
        }
    }
    int mainflag = 0;
    for(int i = 1; i <= n; i++)
    {
        for(int j = 1; j <= n; j++)
        {
            //cout << mark[i][j];
            if(mark[i][j] == 0)
            {
                if(arr[i][j] != '.' && arr[i][j] != 'o') mainflag = 1;
            }
            if(mark[i][j] == 1)
            {
                if(arr[i][j] == '.') mainflag = 1;
            }
        }
        //cout << endl;
    }
    if(mainflag == 1)
    {
        cout << "NO";
        return 0;
    }
     int posy = n;
     int posx = n;
    for(auto x: moves)
    {
        ans[posx + x.ff][posy + x.ss] = 'x';
    }
    ans[n][n] = 'o';
    cout << "YES" << endl;
    for(int i = 1; i <= 2 * n - 1; i++)
    {
        for(int j = 1; j <= 2 * n - 1; j++)
        {
            if(ans[i][j] == 'x' || ans[i][j] == 'o')
                cout << ans[i][j];
            else
                cout << '.';
        }
        cout << endl;
    }
    return 0;
}


#include <bits/stdc++.h>

#define pb push_back
#define Each(it,a) for(__typeof(a.begin()) it = a.begin(); it != a.end(); ++it)
#define sqr(x) ((x) * (x))
#define Debug(x) { cerr << #x << " = "; cerr << (x) << endl; }
typedef long long ll;
typedef unsigned long long ull;
const int N = 3e2 + 10;
const int MOD = 1e9 + 7;
const int INF = 2e9;
const ll INFLL = 1e18;
const double PI = acos((double) -1);
inline int mult(int a, int b, int p = MOD) { return (1ll * a * b) % p; }
inline int add(int a, int b, int p = MOD) { return (1ll * a + b) % p; }
inline int fpow(ll n, ll k, int p = MOD) {ll r = 1; for (; k; k >>= 1) {if (k & 1) r = r * n % p; n = n * n % p;} return r;}
inline int inv(int a, int p = MOD) {return fpow(a, p - 2, p);}

using namespace std;

int n, a[N][N];
vector<pair<int, int> > ans, p;
bool check[N][N];

int main()
{
	ios::sync_with_stdio(false);
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		string s;
		cin >> s;
		for (int j = 0; j < n; j++)
		{
			if (s[j] == 'o') { a[i][j] = 1; p.pb({i, j}); }
			else
			if (s[j] == 'x') a[i][j] = 2;
			else a[i][j] = 0;
		}
	}
	for (int i = 0; i < n; i++)
		for (int j = 0; j < n; j++)
		{
			if (a[i][j] == 2)
			{
				int x = p[0].first, y = p[0].second;
				int dx = i - x, dy = j - y;
				bool ok = true;
				for (int k = 1; k < p.size(); k++)
				{
					int newx = p[k].first + dx;
					int newy = p[k].second + dy;
					if (newx < 0 || newx >= n || newy < 0 || newy >= n) continue;
					if (a[newx][newy]) continue;
					ok = false;
					break;
				}
				if (ok) ans.pb({dx, dy});
			}
		}
	memset(check, 0, sizeof(check));
	for (int i = 0; i < n; i++)
		for (int j = 0; j < n; j++)
			if (a[i][j] == 2) check[i][j] = 1;
	for (int k = 0; k < p.size(); k++)
	{
		int x = p[k].first, y = p[k].second;
		for (int t = 0; t < ans.size(); t++)
		{
			int newx = x + ans[t].first, newy = y + ans[t].second;
			if (newx < 0 || newx >= n || newy < 0 || newy >= n) continue;
			check[newx][newy] = 0;
		}
	}
	for (int i = 0; i < n; i++)
		for (int j = 0; j < n; j++)
			if (check[i][j])
			{
				cout << "NO";
				return 0;
			}
	cout << "YES" << endl;
	memset(a, 0, sizeof(a));
	a[n - 1][n - 1] = 1;
	int x = n - 1, y = n - 1;
	for (int t = 0; t < ans.size(); t++)
	{
		int newx = x + ans[t].first, newy = y + ans[t].second;
		a[newx][newy] = 2;
	}
	for (int i = 0; i < 2 * n - 1; i++)
	{
		for (int j = 0; j < 2 * n - 1; j++)
		{
			if (a[i][j] == 1) cout << "o";
			else
			if (a[i][j] == 2) cout << "x";
			else cout << ".";
		}
		cout << endl;
	}
	return 0;
}


#include <bits/stdc++.h>

#define pb push_back
#define Each(it,a) for(__typeof(a.begin()) it = a.begin(); it != a.end(); ++it)
#define sqr(x) ((x) * (x))
#define Debug(x) { cerr << #x << " = "; cerr << (x) << endl; }
typedef long long ll;
typedef unsigned long long ull;
const int N = 3e2 + 10;
const int MOD = 1e9 + 7;
const int INF = 2e9;
const ll INFLL = 1e18;
const double PI = acos((double) -1);
inline int mult(int a, int b, int p = MOD) { return (1ll * a * b) % p; }
inline int add(int a, int b, int p = MOD) { return (1ll * a + b) % p; }
inline int fpow(ll n, ll k, int p = MOD) {ll r = 1; for (; k; k >>= 1) {if (k & 1) r = r * n % p; n = n * n % p;} return r;}
inline int inv(int a, int p = MOD) {return fpow(a, p - 2, p);}

using namespace std;

int n, a[N][N];
vector<pair<int, int> > ans, p;
bool check[N][N];

int main()
{
	ios::sync_with_stdio(false);
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		string s;
		cin >> s;
		for (int j = 0; j < n; j++)
		{
			if (s[j] == 'o') { a[i][j] = 1; p.pb({i, j}); }
			else
			if (s[j] == 'x') a[i][j] = 2;
			else a[i][j] = 0;
		}
	}
	for (int i = 0; i < n; i++)
		for (int j = 0; j < n; j++)
		{
			if (a[i][j] == 2)
			{
				for (int t = 0; t < p.size(); t++)
				{
					int x = p[t].first, y = p[t].second;
					int dx = i - x, dy = j - y;
					bool ok = true;
					for (int k = 0; k < p.size(); k++)
					{
						if (k == t) continue;
						int newx = p[k].first + dx;
						int newy = p[k].second + dy;
						if (newx < 0 || newx >= n || newy < 0 || newy >= n) continue;
						if (a[newx][newy]) continue;
						ok = false;
						break;
					}
					if (ok) { ans.pb({dx, dy}); break; }
				}
			}
		}
	memset(check, 0, sizeof(check));
	for (int i = 0; i < n; i++)
		for (int j = 0; j < n; j++)
			if (a[i][j] == 2) check[i][j] = 1;
	for (int k = 0; k < p.size(); k++)
	{
		int x = p[k].first, y = p[k].second;
		for (int t = 0; t < ans.size(); t++)
		{
			int newx = x + ans[t].first, newy = y + ans[t].second;
			if (newx < 0 || newx >= n || newy < 0 || newy >= n) continue;
			check[newx][newy] = 0;
		}
	}
	for (int i = 0; i < n; i++)
		for (int j = 0; j < n; j++)
			if (check[i][j])
			{
				cout << "NO";
				return 0;
			}
	cout << "YES" << endl;
	memset(a, 0, sizeof(a));
	a[n - 1][n - 1] = 1;
	int x = n - 1, y = n - 1;
	for (int t = 0; t < ans.size(); t++)
	{
		int newx = x + ans[t].first, newy = y + ans[t].second;
		a[newx][newy] = 2;
	}
	for (int i = 0; i < 2 * n - 1; i++)
	{
		for (int j = 0; j < 2 * n - 1; j++)
		{
			if (a[i][j] == 1) cout << "o";
			else
			if (a[i][j] == 2) cout << "x";
			else cout << ".";
		}
		cout << endl;
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define ull unsigned long long int
#define rep(i,a,b) for (ll i = a; i <= b; i++)
#define ren(i,a,b) for(ll i=b;i>=a;i--)
#define F first
#define S second
#define PB push_back
#define DB pop_back
#define MP make_pair
#define MT make_tuple
#define G(a,b) get<a>(b)
#define V(a) vector<a>
#define MOD 1000000007
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll powM(ll x,ll y,ll m)
{
    if(y==0) return 1;
    ll p=powM(x,y/2,m)%m;
    p=(p*p)%m;
    return (y%2==0)?p:(x*p)%m;
}
////////////////////

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    /*int t;
    cin>>t;
    while(t--)*/
    int n;
    cin>>n;
    char s[n+1][n+1];
    set<pair<int,int>> p;
    rep(i,1,n){
        rep(j,1,n){
            cin>>s[i][j];
            if(s[i][j]=='o') p.insert({i,j});
        }
    }
    char t[2*n][2*n];
    set<pair<int,int>> pos;
    rep(i,1,2*n-1)
    {
        rep(j,1,2*n-1)
        {
            int x=i-n,y=j-n,fl=1;
            for(auto u:p){
                if(u.F+x>=1 && u.F+x<=n && u.S+y>=1 && u.S+y<=n){
                    if(s[u.F+x][u.S+y]=='.'){
                        fl=0;
                        break;
                    }
                }
            }
            if(fl==1) pos.insert({x,y});
        }
    }
    //for(auto u:pos) cout<<u.F<<" "<<u.S<<'\n';
    char ch[n+1][n+1];
    rep(i,1,n){
        rep(j,1,n){
            ch[i][j]='.';
        }
    }
    for(auto u:p)
    {
        for(auto v:pos)
        {
            if(u.F+v.F>=1 && u.F+v.F<=n && u.S+v.S>=1 && u.S+v.S<=n){
                ch[u.F+v.F][u.S+v.S]='x';
            }
        }
    }
    int fl=1;
    rep(i,1,n){
        rep(j,1,n){
            if(s[i][j]=='x'){
                if(ch[i][j]!='x'){
                    fl=0;
                    break;
                }
            }
        }
        if(fl==0) break;
    }
    if(fl==0){
        cout<<"NO"<<'\n';
        return 0;
    }
    //cout<<"yes"<<'\n';
    rep(i,1,2*n-1){
        rep(j,1,2*n-1){
            if(i==n && j==n){
                cout<<'o';
                continue;
            }
            if(pos.count({i-n,j-n})) cout<<'x';
            else cout<<'.';
        }
        cout<<'\n';
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define ull unsigned long long int
#define rep(i,a,b) for (ll i = a; i <= b; i++)
#define ren(i,a,b) for(ll i=b;i>=a;i--)
#define F first
#define S second
#define PB push_back
#define DB pop_back
#define MP make_pair
#define MT make_tuple
#define G(a,b) get<a>(b)
#define V(a) vector<a>
#define MOD 1000000007
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll powM(ll x,ll y,ll m)
{
    if(y==0) return 1;
    ll p=powM(x,y/2,m)%m;
    p=(p*p)%m;
    return (y%2==0)?p:(x*p)%m;
}
////////////////////

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    /*int t;
    cin>>t;
    while(t--)*/
    int n;
    cin>>n;
    char s[n+1][n+1];
    set<pair<int,int>> p;
    rep(i,1,n){
        rep(j,1,n){
            cin>>s[i][j];
            if(s[i][j]=='o') p.insert({i,j});
        }
    }
    char t[2*n][2*n];
    set<pair<int,int>> pos;
    rep(i,1,2*n-1)
    {
        rep(j,1,2*n-1)
        {
            int x=i-n,y=j-n,fl=1;
            for(auto u:p){
                if(u.F+x>=1 && u.F+x<=n && u.S+y>=1 && u.S+y<=n){
                    if(s[u.F+x][u.S+y]=='.'){
                        fl=0;
                        break;
                    }
                }
            }
            if(fl==1) pos.insert({x,y});
        }
    }
    //for(auto u:pos) cout<<u.F<<" "<<u.S<<'\n';
    char ch[n+1][n+1];
    rep(i,1,n){
        rep(j,1,n){
            ch[i][j]='.';
        }
    }
    for(auto u:p)
    {
        for(auto v:pos)
        {
            if(u.F+v.F>=1 && u.F+v.F<=n && u.S+v.S>=1 && u.S+v.S<=n){
                ch[u.F+v.F][u.S+v.S]='x';
            }
        }
    }
    int fl=1;
    rep(i,1,n){
        rep(j,1,n){
            if(s[i][j]=='x'){
                if(ch[i][j]!='x'){
                    fl=0;
                    break;
                }
            }
        }
        if(fl==0) break;
    }
    if(fl==0){
        cout<<"NO"<<'\n';
        return 0;
    }
    cout<<"YES"<<'\n';
    rep(i,1,2*n-1){
        rep(j,1,2*n-1){
            if(i==n && j==n){
                cout<<'o';
                continue;
            }
            if(pos.count({i-n,j-n})) cout<<'x';
            else cout<<'.';
        }
        cout<<'\n';
    }
    return 0;
}


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
namespace std
{

    template <class Fun>
    class y_combinator_result
    {
        Fun fun_;

    public:
        template <class T>
        explicit y_combinator_result(T &&fun) : fun_(std::forward<T>(fun)) {}

        template <class... Args>
        decltype(auto) operator()(Args &&... args)
        {
            return fun_(std::ref(*this), std::forward<Args>(args)...);
        }
    };

    template <class Fun>
    decltype(auto) y_combinator(Fun &&fun)
    {
        return y_combinator_result<std::decay_t<Fun>>(std::forward<Fun>(fun));
    }

} // namespace std
using namespace std;

#define mp make_pair
#define pb(x) push_back(x)
#define vi vector<int>
#define vs vector<string>
#define vll vector<long long>
#define vc vector<char>
#define vs vector<string>
#define pii pair<int, int>
#define pll pair<long long, long long>
#define pil pair<int, long long>
#define pli pair<long long, int>
#define pcc pair<char, char>
#define pdd pair<double, double>
#define mll map<long long, long long>
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(), (v).end()
#define flsh fflush(stdout)
#define gcd __gcd
#define clr(x) memset(x, 0, sizeof(x))
#define mod 1000000007LL
#define mod2 998244353LL
#define INF 1000000000007

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> o_tree;

// online class ftw :/

void solve()
{

    ll n;
    cin >> n;
    string s;
    ll a[n][n];
    ll i, j;
    ll nop = 0;
    vector<pll> piece;
    vector<pll> attck;

    // function<bool(ll, ll, ll)>in = [&](ll x, ll y, ll n) {
    //     if (x >= 0 && y >= 0 && x < n && y < n)
    //     {
    //         return true;
    //     }

    //     return false;
    // };

    auto in = std::y_combinator([](auto in, ll x, ll y,ll n) -> bool {
        if (x >= 0 && y >= 0 && x < n && y < n)
        {
            return true;
        }

        return false;
    });

    for (i = 0; i < n; i++)
    {
        cin >> s;
        for (j = 0; j < n; j++)
        {
            if (s[j] == 'o')
            {
                a[i][j] = 2;
                piece.pb(mp(i, j));
                // attck.pb(mp(i,j));
            }
            else if (s[j] == 'x')
            {
                a[i][j] = 1;
                attck.pb(mp(i, j));
            }
            else
            {
                a[i][j] = 0;
            }
        }
    }
    ll m = 2 * n - 1;
    ll res[m][m];
    clr(res);
    res[n - 1][n - 1] = 2;

    ll minx = -n + 1;
    ll maxx = n - 1;

    vector<pll> shift;
    for (i = minx; i <= maxx; i++)
    {
        for (j = minx; j <= maxx; j++)
        {
            ll f = 0;
            ll ff = 0;
            if (i == 0 && j == 0)
                continue;
            for (auto it : piece)
            {
                ll posx = it.first + i;
                ll posy = it.second + j;
                if (in(posx, posy, n))
                {
                    if (a[posx][posy] != 0)
                    {
                        ff++;
                    }
                }
                else
                {
                    ff++;
                }
            }
            if (ff != (ll)piece.size())
            {
                continue;
            }
            shift.pb(mp(i, j));
        }
    }
    ll f = 0;
    vector<pll> validmoves;
    for (auto pos : attck)
    {
        ll flag = 0;
        for (auto newpos : shift)
        {
            ll lolx = pos.first - newpos.first;
            ll loly = pos.second - newpos.second;

            if (in(lolx, loly, n))
            {
                if (a[lolx][loly] == 2)
                {
                    flag = 1;
                }
            }
        }
        if (!flag)
        {
            f = 1;
        }
    }
    if (f)
    {
        cout << "NO\n";
        return;
    }

    ll newposx = n - 1;
    ll newposy = n - 1;
    for (auto it : shift)
    {
        ll posx = newposx + it.first;
        ll posy = newposy + it.second;
        if (in(posx, posy, 2 * n - 1))
        {
            res[posx][posy] = 1;
        }
    }
    cout << "YES\n";
    for (i = 0; i < 2 * n - 1; i++)
    {
        for (j = 0; j < 2 * n - 1; j++)
        {
            if (res[i][j] == 2)
            {
                cout << "o";
            }
            else if (res[i][j] == 1)
            {
                cout << "x";
            }
            else
            {
                cout << ".";
            }
        }
        cout << "\n";
    }
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    if (fopen("input.txt", "r"))
    {
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    }
    cout << setprecision(20);

    ll t = 1;

    // cin>>t;

    while (t--)
    {
        solve();
    }

    return 0;
}


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define mp make_pair
#define pb(x) push_back(x)
#define vi vector<int>
#define vs vector<string>
#define vll vector<long long>
#define vc vector<char>
#define vs vector<string>
#define pii pair<int, int>
#define pll pair<long long, long long>
#define pil pair<int, long long>
#define pli pair<long long, int>
#define pcc pair<char, char>
#define pdd pair<double, double>
#define mll map<long long, long long>
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(), (v).end()
#define flsh fflush(stdout)
#define gcd __gcd
#define clr(x) memset(x, 0, sizeof(x))
#define mod 1000000007LL
#define mod2 998244353LL
#define INF 1000000000007

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> o_tree;

// online class ftw

void solve()
{
    ll n;
    cin >> n;
    string s;
    ll a[n][n];
    ll i, j;
    ll nop = 0;
    vector<pll> piece;
    vector<pll> attck;

    function<bool(ll, ll, ll)>in = [&](ll x, ll y, ll n) {
        if (x >= 0 && y >= 0 && x < n && y < n)
        {
            return true;
        }

        return false;
    };

    for (i = 0; i < n; i++)
    {
        cin >> s;
        for (j = 0; j < n; j++)
        {
            if (s[j] == 'o')
            {
                a[i][j] = 2;
                piece.pb(mp(i, j));
                // attck.pb(mp(i,j));
            }
            else if (s[j] == 'x')
            {
                a[i][j] = 1;
                attck.pb(mp(i, j));
            }
            else
            {
                a[i][j] = 0;
            }
        }
    }
    ll m = 2 * n - 1;
    ll res[m][m];
    clr(res);
    res[n - 1][n - 1] = 2;

    ll minx = -n + 1;
    ll maxx = n - 1;

    vector<pll> shift;
    for (i = minx; i <= maxx; i++)
    {
        for (j = minx; j <= maxx; j++)
        {
            ll f = 0;
            ll ff = 0;
            if (i == 0 && j == 0)
                continue;
            for (auto it : piece)
            {
                ll posx = it.first + i;
                ll posy = it.second + j;
                if (in(posx, posy, n))
                {
                    if (a[posx][posy] != 0)
                    {
                        ff++;
                    }
                }
                else
                {
                    ff++;
                }
            }
            if (ff != (ll)piece.size())
            {
                continue;
            }
            shift.pb(mp(i, j));
        }
    }
    ll f = 0;
    vector<pll> validmoves;
    for (auto pos : attck)
    {
        ll flag = 0;
        for (auto newpos : shift)
        {
            ll lolx = pos.first - newpos.first;
            ll loly = pos.second - newpos.second;

            if (in(lolx, loly, n))
            {
                if (a[lolx][loly] == 2)
                {
                    flag = 1;
                }
            }
        }
        if (!flag)
        {
            f = 1;
        }
    }
    if (f)
    {
        cout << "NO\n";
        return;
    }

    ll newposx = n - 1;
    ll newposy = n - 1;
    for (auto it : shift)
    {
        ll posx = newposx + it.first;
        ll posy = newposy + it.second;
        if (in(posx, posy, 2 * n - 1))
        {
            res[posx][posy] = 1;
        }
    }
    cout << "YES\n";
    for (i = 0; i < 2 * n - 1; i++)
    {
        for (j = 0; j < 2 * n - 1; j++)
        {
            if (res[i][j] == 2)
            {
                cout << "o";
            }
            else if (res[i][j] == 1)
            {
                cout << "x";
            }
            else
            {
                cout << ".";
            }
        }
        cout << "\n";
    }
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    if (fopen("input.txt", "r"))
    {
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    }
    cout << setprecision(20);

    ll t = 1;

    // cin>>t;

    while (t--)
    {
        solve();
    }

    return 0;
}


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define mp make_pair
#define pb(x) push_back(x)
#define vi vector<int>
#define vs vector<string>
#define vll vector<long long>
#define vc vector<char>
#define vs vector<string>
#define pii pair<int, int>
#define pll pair<long long, long long>
#define pil pair<int, long long>
#define pli pair<long long, int>
#define pcc pair<char, char>
#define pdd pair<double, double>
#define mll map<long long, long long>
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(), (v).end()
#define flsh fflush(stdout)
#define gcd __gcd
#define clr(x) memset(x, 0, sizeof(x))
#define mod 1000000007LL
#define mod2 998244353LL
#define INF 1000000000007

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> o_tree;

bool in(ll x, ll y, ll n)
{
    if (x >= 0 && y >= 0 && x < n && y < n)
    {
        return true;
    }

    return false;
}

void solve()
{
    ll n;
    cin >> n;
    string s;
    ll a[n][n];
    ll i, j;
    ll nop = 0;
    vector<pll> piece;
    vector<pll> attck;
    for (i = 0; i < n; i++)
    {
        cin >> s;
        for (j = 0; j < n; j++)
        {
            if (s[j] == 'o')
            {
                a[i][j] = 2;
                piece.pb(mp(i, j));
                // attck.pb(mp(i,j));
            }
            else if (s[j] == 'x')
            {
                a[i][j] = 1;
                attck.pb(mp(i,j));
            }
            else
            {
                a[i][j] = 0;
            }
        }
    }
    ll m = 2 * n - 1;
    ll res[m][m];
    clr(res);
    res[n - 1][n - 1] = 2;

    ll minx = -n + 1;
    ll maxx = n - 1;

    vector<pll> shift;
    for (i = minx; i <= maxx; i++)
    {
        for (j = minx; j <= maxx; j++)
        {
            ll f = 0;
            ll ff=0;
            if(i==0&&j==0)continue;
            for (auto it : piece)
            {
                ll posx = it.first + i;
                ll posy = it.second + j;
                if (in(posx, posy, n))
                {
                    if(a[posx][posy]!=0)
                    {
                        ff++;
                    }
                }
                else{
                    ff++;
                }
            }
            if(ff!=(ll)piece.size())
            {
                continue;
            }
            shift.pb(mp(i,j));
        }
    }
    ll f=0;
    vector<pll> validmoves;
    for(auto pos:attck)
    {
        ll flag=0;
        for(auto newpos: shift)
        {
            ll lolx = pos.first-newpos.first;
            ll loly = pos.second-newpos.second;

            if(in(lolx,loly,n))
            {
                if(a[lolx][loly]==2)
                {
                    flag=1;
                }
            }
        }
        if(!flag)
        {
            f=1;
        }
    }
    if(f)
    {
        cout<<"NO\n";
        return;
    }

    ll newposx = n-1;
    ll newposy = n-1;
    for(auto it:shift)
    {
        ll posx = newposx+it.first;
        ll posy = newposy+it.second;
        if(in(posx,posy,2*n-1))
        {
            res[posx][posy]=1;
        }
    }
    cout<<"YES\n";
    for(i=0;i<2*n-1;i++)
    {
        for(j=0;j<2*n-1;j++)
        {
            if(res[i][j]==2)
            {
                cout<<"o";
            }
            else if(res[i][j]==1)
            {
                cout<<"x";
            }
            else{
                cout<<".";
            }
        }
        cout<<"\n";
    }
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    if (fopen("input.txt", "r"))
    {
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    }
    cout << setprecision(20);

    ll t = 1;

    // cin>>t;

    while (t--)
    {
        solve();
    }

    return 0;
}