#include <cstdio>
#include <bitset>
#include <iostream>
#include <set>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <map>
#include <queue>
#include<stdio.h>
#include<string.h>
#include <vector>
using namespace std;
#define INF 0x3f3f3f3f
#define ll long long

const int maxn=1000000;
int n;
char s[3000];
bool cmp(const int &e1,const int &e2){
    return e1>e2;
}
int head[3000];
int tot;
void init(){
    for(int i=0;i<30;i++)head[i]=-1;
    tot=0;
}
struct Edge{
    int to,next,w;
}e[maxn];
void addedge(int from,int to,int w){
    e[tot].to=to;e[tot].next=head[from];e[tot].w=w;head[from]=tot++;
}
int que[100000];
int main() {
    if(fopen("H:\\acm.txt", "r")!=NULL){
     freopen("H:\\acm.txt","r",stdin);
     }

    while(scanf("%d",&n)!=EOF){

        int vis[50];memset(vis,0,sizeof(vis));
        scanf("%s",s+1);
        init();
        for(int i=0;i<26;i++){
            char x=i+'a';
            for(int j=1;j<=n;j++){
                    int sb=j;
                if(s[j]=='a'+i){
                    int w=1;
                    while(j+1<=n&&s[j+1]=='a'+i){
                        w++; j++;
                    }
                    addedge(i,sb,w);
                }
            }
        }
        for(int i=0;i<26;i++){

            int u=head[i]; head[i]=-1;
            for(;u!=-1;u=e[u].next){
                addedge(i,e[u].to,e[u].w);
            }
        }
        int qn,q;char g[10];
        cin>>qn;
        for(int ii=1;ii<=qn;ii++){

            cin>>q>>g;
            int stq=q;
            int st=0,ed=0;
            int now,res=0;
             int u=g[0]-'a';
            if(head[u]==-1){
                printf("%d\n",min(q,n) );continue;
            }
            int final_res=0;

            int ei=head[u];
            res+=e[ei].w;
            int k=e[ei].next;
            que[ed++]=ei;
            final_res=max(final_res,res);
            final_res=max(final_res,min(res+q,n));
            for( ;k!=-1;k=e[k].next ){

                 int len=e[k].to-(e[que[ed-1]].to+e[que[ed-1]].w );
                 if(len<=q){
                    q-=len;
                      res+=len+e[k].w;
                         que[ed++]=k;
                        final_res=max(final_res,res);
                        final_res=max(final_res,min(res+q,n));
                        continue;

                 }

                 while(ed-st>=2){
                      int tlen=e[que[st+1]].to-(e[que[st]].to+e[que[st]].w) ;
                      q+=tlen;
                      st++;
                      res-=tlen+e[que[st]].w;
                      if(len<=q){
                        break;
                      }
                 }

                 if(len<=q){
                        q-=len;
                        res+=len+e[k].w;
                        que[ed++]=k;
                        final_res=max(final_res,res);
                        continue;
                 }else{
                        final_res=max(final_res,min(res+q,n) );
                        res=0;st=0,ed=0;q=stq;
                            res+=e[k].w;
                            que[ed++]=k;
                            final_res=max(final_res,res);
                            final_res=max(final_res,min(res+q,n) );
                 }
            }

                if(q>0){
                    final_res=max(final_res,min(res+q,n) );
                }
                printf("%d\n",final_res);
        }
    }

    return 0;
}


#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstring>
using namespace std;
const int MAXN = 2000;
int n, q, dp[30][MAXN], sum[30][MAXN], m;
char s[MAXN], col[20];

int main()
{
    scanf("%d%s", &n, s+1);
    for(int i=1; i<=n; ++i)
    {
        for(int j=0; j<26; ++j)
            sum[j][i] = sum[j][i-1];
        sum[s[i]-'a'][i] += 1;
    }
    memset(dp, 0, sizeof(dp));
    for(int i=1; i<=n; ++i)
    {
        for(int j=i; j<=n; ++j)
        {
            for(int k=0; k<26; ++k)
            {
                dp[k][ j-i+1 - (sum[k][j]-sum[k][i-1]) ]
                    = max(dp[k][ j-i+1 - (sum[k][j]-sum[k][i-1]) ], j-i+1);
            }
        }
    }
    for(int i=1; i<=n; ++i)
        for(int j=0; j<26; ++j) dp[j][i] = max(dp[j][i], dp[j][i-1]+1);

    scanf("%d", &q);
    for(int i=0; i<q; ++i)
    {
        scanf("%d%s", &m, col);
        printf("%d\n", dp[col[0]-'a'][m] > n ? n : dp[col[0]-'a'][m]);
    }

    return 0;
}


#include <cstdio>
#include <bitset>
#include <iostream>
#include <set>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <map>
#include <queue>
#include<stdio.h>
#include<string.h>
#include <vector>
using namespace std;
#define INF 0x3f3f3f3f
#define ll long long

const int maxn=1000000;
int n;
char s[3000];
bool cmp(const int &e1,const int &e2){
    return e1>e2;
}
int head[3000];
int tot;
void init(){
    for(int i=0;i<30;i++)head[i]=-1;
    tot=0;
}
struct Edge{
    int to,next,w;
}e[maxn];
void addedge(int from,int to,int w){
    e[tot].to=to;e[tot].next=head[from];e[tot].w=w;head[from]=tot++;
}
int que[100000];
int main() {
    if(fopen("H:\\acm.txt", "r")!=NULL){
     freopen("H:\\acm.txt","r",stdin);
     }

    while(scanf("%d",&n)!=EOF){

        int vis[50];memset(vis,0,sizeof(vis));
        scanf("%s",s+1);
        init();
        for(int i=0;i<26;i++){
            char x=i+'a';
            for(int j=1;j<=n;j++){
                    int sb=j;
                if(s[j]=='a'+i){
                    int w=1;
                    while(j+1<=n&&s[j+1]=='a'+i){
                        w++; j++;
                    }
                    addedge(i,sb,w);
                }
            }
        }
        for(int i=0;i<26;i++){

            int u=head[i]; head[i]=-1;
            for(;u!=-1;u=e[u].next){
                addedge(i,e[u].to,e[u].w);
            }
        }
        int qn,q;char g[10];
        cin>>qn;
        for(int ii=1;ii<=qn;ii++){

            cin>>q>>g;
            int stq=q;
            int st=0,ed=0;
            int now,res=0;
             int u=g[0]-'a';
            if(head[u]==-1){
                printf("%d\n",min(q,n) );continue;
            }
            int final_res=0;

            int ei=head[u];
            res+=e[ei].w;
            int k=e[ei].next;
            que[ed++]=ei;
            final_res=max(final_res,res);
            final_res=max(final_res,min(res+q,n));
            for( ;k!=-1;k=e[k].next ){

                 int len=e[k].to-(e[que[ed-1]].to+e[que[ed-1]].w );
                 if(len<=q){
                    q-=len;
                      res+=len+e[k].w;
                         que[ed++]=k;
                        final_res=max(final_res,res);
                        final_res=max(final_res,min(res+q,n));
                        continue;

                 }

                 while(ed-st>=2){
                      int tlen=e[que[st+1]].to-(e[que[st]].to+e[que[st]].w) ;
                      q+=tlen;

                      res-=tlen+e[que[st]].w;
                        st++;
                      if(len<=q){
                        break;
                      }
                 }

                 if(len<=q){
                        q-=len;
                        res+=len+e[k].w;
                        que[ed++]=k;
                        final_res=max(final_res,res);
                        continue;
                 }else{
                        final_res=max(final_res,min(res+q,n) );
                        res=0;st=0,ed=0;q=stq;
                            res+=e[k].w;
                            que[ed++]=k;
                            final_res=max(final_res,res);
                            final_res=max(final_res,min(res+q,n) );
                 }
            }

                if(q>0){
                    final_res=max(final_res,min(res+q,n) );
                }
                printf("%d\n",final_res);
        }
    }

    return 0;
}


#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstring>
using namespace std;
const int MAXN = 2000;
int n, q, dp[30][MAXN], sum[30][MAXN], m;
char s[MAXN], col[20];

int main()
{
    scanf("%d%s", &n, s+1);
    for(int i=1; i<=n; ++i)
    {
        for(int j=0; j<26; ++j)
            sum[j][i] = sum[j][i-1];
        sum[s[i]-'a'][i] += 1;
    }
    memset(dp, 0, sizeof(dp));
    for(int i=1; i<=n; ++i)
    {
        for(int j=i; j<=n; ++j)
        {
            for(int k=0; k<26; ++k)
            {
                dp[k][ j-i+1 - (sum[k][j]-sum[k][i-1]) ]
                    = max(dp[k][ j-i+1 - (sum[k][j]-sum[k][i-1]) ], j-i+1);
            }
        }
    }
//for(int i=1; i<=n; ++i)
 //       for(int j=0; j<26; ++j) dp[j][i] = max(dp[j][i], dp[j][i-1]+1);

    scanf("%d", &q);
    for(int i=0; i<q; ++i)
    {
        scanf("%d%s", &m, col);
        printf("%d\n", dp[col[0]-'a'][m] > n ? n : dp[col[0]-'a'][m]);
    }

    return 0;
}


#include<bits/stdc++.h>
#define ll long long
using namespace std;
char a[2000];
int n,q,sum[2000][30];
int p[30][2000];
void make(int x)
{
    for(int i=1;i<=n;i++)
    for(int j=i;j<=n;j++)
    {
        int k=sum[j][x]-sum[i-1][x],d=j-i+1;
        p[x][d-k]=max(p[x][d-k],d);
    }
}
int main()
{
    while(~scanf("%d",&n))
    {
        scanf("%s",a);
        memset(sum,0,sizeof sum);
        for(int i=1;i<=n;i++)
        {
            for(int j=0;j<26;j++)
            sum[i][j]=sum[i-1][j];
            sum[i][a[i-1]-'a']++;
        }
        memset(p,0,sizeof p);
        for(int i=0;i<=25;i++)
        make(i);
        scanf("%d",&q);
        while(q--)
        {
            int x,k;
            char c[3];
            scanf("%d%s",&x,c);
            k=c[0]-'a';
            x=min(x,n-sum[n][k]);
            printf("%d\n",p[k][x]);
        }
    }
    return 0;
}


#include <bits/stdc++.h>
#define ll long long int
#define pii pair <int,int>
#define ff first
#define ss second
#define pi acos(-1.0)
#define pb push_back
#define INF (ll)1e17
#define N 1502
#define MOD 1000000007
#define BASE 100003
#define FastRead ios_base::sync_with_stdio(0);cin.tie(0)
using namespace std;

template < class T > inline T gcd(T a, T b) {while(b) {a %= b; swap(a, b);} return a;}
template < class T > inline T lcm(T a, T b) {return a/gcd(a, b)*b;}
inline int nxt() {int wow; scanf("%d", &wow); return wow;}
inline ll lxt() {ll wow; scanf("%lld", &wow); return wow;}
inline double dxt() {double wow; scanf("%lf", &wow); return wow;}

/***************** Fighters Launched *******************/

int main()
{
    FastRead;
    int n, q;
    cin >> n;
    string s;
    cin >> s;
    int lnc[28][N] = {0};
    for (int j='a'; j<='z'; j++){
        int cur = 0;
        for (int i=1; i<=n; i++){
            if (s[i-1] != j) cur++;
            lnc[j-'a'+1][i] = cur;
        }
    }
    cin >> q;
    while (q--){
        int m;
        char c;
        cin >> m >> c;
        string t = "0" + s;
        int ans = 1, cur = 0, i=1, r=1;
        while (i <= n){
        conhan:
            if (i>n || r > n) break;
            while (r <= n){
                if (t[r] != c){
                    if (cur == m){
                        for (int l=i; l<=r; l++){
                            if (t[l] != c){
                                i = l+1;
                                r++;
                                goto conhan;
                            }
                        }
                    }
                    else cur++;
                }
                ans = max(ans, r-i+1);
                r++;
            }
        }
        cout << ans << endl;
    }
    return 0;
}


#include <bits/stdc++.h>
#define ll long long int
#define pii pair <int,int>
#define ff first
#define ss second
#define pi acos(-1.0)
#define pb push_back
#define INF (ll)1e17
#define N 1502
#define MOD 1000000007
#define BASE 100003
#define FastRead ios_base::sync_with_stdio(0);cin.tie(0)
using namespace std;

template < class T > inline T gcd(T a, T b) {while(b) {a %= b; swap(a, b);} return a;}
template < class T > inline T lcm(T a, T b) {return a/gcd(a, b)*b;}
inline int nxt() {int wow; scanf("%d", &wow); return wow;}
inline ll lxt() {ll wow; scanf("%lld", &wow); return wow;}
inline double dxt() {double wow; scanf("%lf", &wow); return wow;}

/***************** Fighters Launched *******************/

int main()
{
    FastRead;
    int n, q;
    cin >> n;
    string s;
    cin >> s;
    int lnc[28][N] = {0};
    for (int j='a'; j<='z'; j++){
        int cur = 0;
        for (int i=1; i<=n; i++){
            if (s[i] != j) cur++;
            lnc[j-'a'+1][i] = cur;
        }
        lnc[j-'a'+1][n+1] = INT_MAX;
    }
    cin >> q;
    while (q--){
        string t = "0" + s;
        int m;
        char c;
        cin >> m >> c;
        int ans = 1;
        for (int i=1; i<=n; i++){
            int low = i, high = n, take = low;
            while (low <= high){
                int mid = (low+high)/2;
                if (lnc[c-'a'+1][mid] - lnc[c-'a'+1][i-1] <= m){
                    take = mid;
                    low = mid+1;
                }
                else high = mid-1;
            }
            int now = take-i+1;
            ans = max(ans, now);
        }
        //printf("ans = ");
        cout << ans << endl;
    }
    return 0;
}


#include <bits/stdc++.h>
#define ll long long int
#define pii pair <int,int>
#define ff first
#define ss second
#define pi acos(-1.0)
#define pb push_back
#define INF (ll)1e17
#define N 1502
#define MOD 1000000007
#define BASE 100003
#define FastRead ios_base::sync_with_stdio(0);cin.tie(0)
using namespace std;

template < class T > inline T gcd(T a, T b) {while(b) {a %= b; swap(a, b);} return a;}
template < class T > inline T lcm(T a, T b) {return a/gcd(a, b)*b;}
inline int nxt() {int wow; scanf("%d", &wow); return wow;}
inline ll lxt() {ll wow; scanf("%lld", &wow); return wow;}
inline double dxt() {double wow; scanf("%lf", &wow); return wow;}

/***************** Fighters Launched *******************/

int main()
{
    FastRead;
    int n, q;
    cin >> n;
    string s;
    cin >> s;
    int lnc[28][N] = {0};
    for (int j='a'; j<='z'; j++){
        int cur = 0;
        for (int i=1; i<=n; i++){
            if (s[i-1] != j) cur++;
            lnc[j-'a'+1][i] = cur;
        }
    }
    cin >> q;
    while (q--){
        int m;
        char c;
        cin >> m >> c;
        string t = "0" + s;
        int ans = 1, cur = 0, i=1, r=1;
        while (i <= n){
        conhan:
            if (i>n || r > n) break;
            while (r <= n){
                if (t[r] != c){
                    if (cur == m){
                        ans = max(ans, r-i);
                        for (int l=i; l<=r; l++){
                            if (t[l] != c){
                                //printf("i = %d, r = %d, ans = %d\n", i, r, ans);
                                i = l+1;
                                r++;
//                                puts("conhan");
//                                printf("i = %d\n", i);
                                goto conhan;
                            }
                        }
                    }
                    else{
                        cur++;
                        ans = max(ans, r-i+1);
                    }
                }
                ans = max(ans, r-i+1);
//                if (r == 4) printf("when r is 4, i was %d\n", i);
//                printf("ans = %d for r = %d\n", ans, r);
                r++;
            }
            i++;
        }
        cout << ans << endl;
    }
    return 0;
}


#include <bits/stdc++.h>
#define ll long long int
#define pii pair <int,int>
#define ff first
#define ss second
#define pi acos(-1.0)
#define pb push_back
#define INF (ll)1e17
#define N 1502
#define MOD 1000000007
#define BASE 100003
#define FastRead ios_base::sync_with_stdio(0);cin.tie(0)
using namespace std;

template < class T > inline T gcd(T a, T b) {while(b) {a %= b; swap(a, b);} return a;}
template < class T > inline T lcm(T a, T b) {return a/gcd(a, b)*b;}
inline int nxt() {int wow; scanf("%d", &wow); return wow;}
inline ll lxt() {ll wow; scanf("%lld", &wow); return wow;}
inline double dxt() {double wow; scanf("%lf", &wow); return wow;}

/***************** Fighters Launched *******************/

int main()
{
    FastRead;
    int n, q;
    cin >> n;
    string s;
    cin >> s;
    int lnc[28][N] = {0};
    for (int j='a'; j<='z'; j++){
        int cur = 0;
        for (int i=1; i<=n; i++){
            if (s[i-1] != j) cur++;
            lnc[j-'a'+1][i] = cur;
        }
    }
    cin >> q;
    while (q--){
        int m;
        char c;
        cin >> m >> c;
        int ans = 1;
        for (int i=1; i<=n; i++){
            int low = i, high = n, take = low;
            while (low <= high){
                int mid = (low+high)/2;
                if (lnc[c-'a'+1][mid] - lnc[c-'a'+1][i-1] <= m){
                    take = mid;
                    low = mid+1;
                }
                else high = mid-1;
            }
            int now = take-i+1;
            ans = max(ans, now);
        }
        cout << ans << endl;
    }
    return 0;
}


#include <bits/stdc++.h>
#define ll long long int
#define pii pair <int,int>
#define ff first
#define ss second
#define pi acos(-1.0)
#define pb push_back
#define INF (ll)1e17
#define N 1502
#define MOD 1000000007
#define BASE 100003
#define FastRead ios_base::sync_with_stdio(0);cin.tie(0)
using namespace std;

template < class T > inline T gcd(T a, T b) {while(b) {a %= b; swap(a, b);} return a;}
template < class T > inline T lcm(T a, T b) {return a/gcd(a, b)*b;}
inline int nxt() {int wow; scanf("%d", &wow); return wow;}
inline ll lxt() {ll wow; scanf("%lld", &wow); return wow;}
inline double dxt() {double wow; scanf("%lf", &wow); return wow;}

/***************** Fighters Launched *******************/

int main()
{
    FastRead;
    int n, q;
    string s;
    cin >> n >> s >> q;
    while (q--){
        int m;
        char c;
        cin >> m >> c;
        int ans = 1, cur = 0, i=1, r=1;
        while (i <= n){
        conhan:
            if (i>n || r>n) break;
            while (r <= n){
                if (s[r-1] != c){
                    if (cur == m){
                        for (int l=i; l<=r; l++){
                            if (s[l-1] != c){
                                i = l+1;
                                r++;
                                goto conhan;
                            }
                        }
                    }
                    else cur++;
                }
                ans = max(ans, r-i+1);
                r++;
            }
        }
        cout << ans << endl;
    }
    return 0;
}


#include <bits/stdc++.h>
#define ll long long int
#define pii pair <int,int>
#define ff first
#define ss second
#define pi acos(-1.0)
#define pb push_back
#define INF (ll)1e17
#define N 1502
#define MOD 1000000007
#define BASE 100003
#define FastRead ios_base::sync_with_stdio(0);cin.tie(0)
using namespace std;

template < class T > inline T gcd(T a, T b) {while(b) {a %= b; swap(a, b);} return a;}
template < class T > inline T lcm(T a, T b) {return a/gcd(a, b)*b;}
inline int nxt() {int wow; scanf("%d", &wow); return wow;}
inline ll lxt() {ll wow; scanf("%lld", &wow); return wow;}
inline double dxt() {double wow; scanf("%lf", &wow); return wow;}

/***************** Fighters Launched *******************/

int main()
{
    FastRead;
    int n, q;
    string s;
    cin >> n >> s >> q;
    while (q--){
        int m;
        char c;
        cin >> m >> c;
        string t = "0" + s;
        int ans = 1, cur = 0, i=1, r=1;
        while (i <= n){
        conhan:
            if (i>n || r>n) break;
            while (r <= n){
                if (t[r] != c){
                    if (cur == m){
                        for (int l=i; l<=r; l++){
                            if (t[l] != c){
                                i = l+1;
                                r++;
                                goto conhan;
                            }
                        }
                    }
                    else cur++;
                }
                ans = max(ans, r-i+1);
                r++;
            }
        }
        cout << ans << endl;
    }
    return 0;
}


# include <iostream>
# include <algorithm>
# include <cmath>
using namespace std;
int i,j,n,m,k,t,mx,x,y,l,r,d,b[200009];
char c[200009],s[1509];
int main()
{

  freopen("input.txt","r",stdin);
  freopen("output.txt","w",stdout);
	cin>>n;
	for (i=1;i<=n;i++) cin>>s[i];
	cin>>m;
	for (i=1;i<=m;i++)
	{

		cin>>b[i]>>c[i];
	}
	for (i=1;i<=m;i++)
	{

		mx=0; l=1; k=0;
		for (r=1;r<=n;r++)
		{
			if (s[r]!=c[i]) k++;
			while (k>b[i])
			{
				if (s[l]!=c[i]) k--;
				l++;
			}
			mx=max(mx,r-l+1);
		}
		cout<<mx<<endl;
	}
}


# include <iostream>
# include <algorithm>
# include <cmath>
using namespace std;
int i,j,n,m,k,t,mx,x,y,l,r,d,b[200009];
char c[200009];
string s[1509];
int main()
{
	cin>>n>>s;
	cin>>m;
	for (i=1;i<=m;i++) cin>>b[i]>>c[i];
	for (i=1;i<=m;i++)
	{
		mx=0; l=1; k=0;
		for (r=1;r<=n;r++)
		{
			if (s[r]!=c[i]) k++;
			while (k>b[i])
			{
				if (s[l]!=c[i]) k--;
				l++;
			}
			mx=max(mx,r-l+1);
		}
		cout<<mx<<endl;
	}
}


# include <iostream>
# include <algorithm>
# include <cmath>
using namespace std;
int i,j,n,m,k,t,mx,x,y,l,r,d,b[200009];
char c[200009];
int main()
{
	scanf ("%d",&n);
	char s[n];
	scanf("%s" ,s);
	scanf ("%d",&m);
	for (i=1;i<=m;i++)
	{

		cin>>b[i]>>c[i];
	}
	for (i=1;i<=m;i++)
	{

		mx=0; l=1; k=0;
		for (r=1;r<=n;r++)
		{
			if (s[r]!=c[i]) k++;
			while (k>b[i])
			{
				if (s[l]!=c[i]) k--;
				l++;
			}
			mx=max(mx,r-l+1);
		}
		printf("%d\n",mx);
	}
}


# include <iostream>
# include <algorithm>
# include <cmath>
using namespace std;
int i,j,n,m,k,mx,x,y,l,r,b;
char c,s[1509];
int main()
{
	scanf("%d",&n);
	scanf("%s",s+1);
	scanf("%d",&m);
	for (i=1;i<=m;i++)
	{
		scanf("%d %c",&b,&c);
		mx=0; l=1; k=0;
		for (r=1;r<=n;r++)
		{
			if (s[r]!=c) k++;
			while (k>b)
			{
				if (s[l]!=c) k--;
				l++;
			}
			mx=max(mx,r-l+1);
		}
		cout<<mx<<endl;
	}
}


# include <iostream>
# include <algorithm>
# include <cmath>
using namespace std;
int i,j,n,m,k,t,mx,x,y,l,r,d,b[200009];
char c[200009];
string s;
int main()
{
	cin>>n;
	cin>>s;
	cin>>m;
	s=' '+s;
	for (i=1;i<=m;i++) cin>>b[i]>>c[i];
	for (i=1;i<=m;i++)
	{
		mx=0; l=1; k=0;
		for (r=1;r<=n;r++)
		{
			if (s[r]!=c[i]) k++;
			while (k>b[i])
			{
				if (s[l]!=c[i]) k--;
				l++;
			}
			mx=max(mx,r-l+1);
		}
		cout<<mx<<endl;
	}
}


# include <iostream>
# include <algorithm>
# include <cmath>
using namespace std;
int i,j,n,m,k,t,mx,x,y,l,r,d,b[200009];
char c[200009];
string s;
int main()
{
	cin>>n>>s;
	cin>>m;
	for (i=1;i<=m;i++) cin>>b[i]>>c[i];
	for (i=1;i<=m;i++)
	{
		mx=0; l=1; k=0;
		for (r=1;r<=n;r++)
		{
			if (s[r]!=c[i]) k++;
			while (k>b[i])
			{
				if (s[l]!=c[i]) k--;
				l++;
			}
			mx=max(mx,r-l+1);
		}
		cout<<mx<<endl;
	}
}


# include <iostream>
# include <algorithm>
# include <cmath>
using namespace std;
long long i,j,n,m,k,t,mx,x,y,l,r,d,b[200009];
char s[1509],c[200009];
int main()
{
	cin>>n;
	for (i=1;i<=n;i++) cin>>s[i];
	cin>>m;
	for (i=1;i<=m;i++) cin>>b[i]>>c[i];
	for (i=1;i<=m;i++)
	{
		mx=0; l=1; k=0;
		for (r=1;r<=n;r++)
		{
			if (s[r]!=c[i]) k++;
			while (k>b[i])
			{
				if (s[l]!=c[i]) k--;
				l++;
			}
			mx=max(mx,r-l+1);
		}
		cout<<mx<<endl;
	}
}


 #include "bits/stdc++.h"
 using namespace std;

 vector<int> Array[26];
 char Str[1505];
 bool Present[26];

 int Binary_Search( int low , int high , int key , int ch , int j ){
     if( low >= high )
      return low;
     else{
      int middle = ( low + high ) >> 1;

         if( Array[ch][middle] - Array[ch][j] - middle + j <= key )
          return Binary_Search( middle + 1 , high , key , ch , j );
         else
          return Binary_Search( low , middle - 1 , key , ch , j );
    }
}

 int main(){
  int N , m , i , q , j;
  char ch;
  scanf( "%d" , &N );
  scanf( "%s" , Str + 1 );

     for( i = 1 ; i <= N ; i++ ){
      Present[Str[i] - 'a'] = 1;
      Array[Str[i] - 'a'].emplace_back( i );
    }

  scanf( "%d" , &q );
  int index , Temp , Ans = 0;

     for( i = 1 ; i <= q ; i++ ){
      scanf( "%d" , &m );
      scanf( "%c" , &ch );
      Ans = 0;

         while( ch < 'a' || ch > 'z' )
          scanf( "%c" , &ch );

         if( Present[ch - 'a'] == 0 )
          printf( "%d\n" , m );
         else{
             for( j = 0 ; j < Array[ch - 'a'].size() ; j++ ){
              index = Binary_Search( j , Array[ch - 'a'].size() - 1 , m , ch - 'a' , j );

                 if( Array[ch - 'a'][index] - Array[ch - 'a'][j] - index + j <= m ){
                  Temp = Array[ch - 'a'][index] - Array[ch - 'a'][j] - index + j;
                  Ans = max( m - Temp + Array[ch - 'a'][index] - Array[ch - 'a'][j] + 1 , Ans );
                }
                 else{
                  Temp = Array[ch - 'a'][index - 1] - Array[ch - 'a'][j] - index + 1 + j;
                  Ans = max( m - Temp + Array[ch - 'a'][index - 1] - Array[ch - 'a'][j] + 1 , Ans );
                }

              //cout << j << " " << index << " " << Ans << endl;
            }

          Ans = min( Ans , N );
          printf( "%d\n" , Ans );
        }
    }

  return 0;
}


 #include "bits/stdc++.h"
 using namespace std;

 vector<int> Array[26];
 char Str[1505];
 bool Present[26];

 int Binary_Search( int low , int high , int key , int ch , int j ){
     if( low >= high )
      return low;
     else{
      int middle = ( low + high ) >> 1;

         if( Array[ch][middle] - Array[ch][j] - middle + j <= key )
          return Binary_Search( middle + 1 , high , key , ch , j );
         else
          return Binary_Search( low , middle - 1 , key , ch , j );
    }
}

 int main(){
  int N , m , i , q , j;
  char ch;
  scanf( "%d" , &N );
  scanf( "%s" , Str + 1 );

     for( i = 1 ; i <= N ; i++ ){
      Present[Str[i] - 'a'] = 1;
      Array[Str[i] - 'a'].emplace_back( i );
    }

  scanf( "%d" , &q );
  int index , Temp , Ans = 0;

     for( i = 1 ; i <= q ; i++ ){
      scanf( "%d" , &m );
      scanf( "%c" , &ch );
      Ans = 0;

         while( ch < 'a' || ch > 'z' )
          scanf( "%c" , &ch );

         if( Present[ch - 'a'] == 0 )
          printf( "%d\n" , m );
         else{
             for( j = 0 ; j < Array[ch - 'a'].size() ; j++ ){
              index = Binary_Search( j , Array[ch - 'a'].size() - 1 , m , ch - 'a' , j );

                 if( Array[ch - 'a'][index] - Array[ch - 'a'][j] - index + j <= m ){
                  Temp = Array[ch - 'a'][index] - Array[ch - 'a'][j] - index + j;
                  Ans = max( m - Temp + Array[ch - 'a'][index] - Array[ch - 'a'][j] + 1 , Ans );
                }
                 else{
                  Temp = Array[ch - 'a'][index - 1] - Array[ch - 'a'][j] - index + 1 + j;
                  Ans = max( m - Temp + Array[ch - 'a'][index - 1] - Array[ch - 'a'][j] + 1 , Ans );
                }

                 if( Ans >= N ){
                  printf( "%d\n" , N );
                  endl;
                }
            }

          Ans = min( Ans , N );
          printf( "%d\n" , Ans );
        }
    }

  return 0;
}


 #include "bits/stdc++.h"
 using namespace std;

 vector<int> Array[26];
 char Str[1505];
 bool Present[26];

 int Binary_Search( int low , int high , int key , int ch , int j ){
     if( low >= high )
      return low;
     else{
      int middle = ( low + high ) >> 1;

         if( Array[ch][middle] - Array[ch][j] - middle + j <= key )
          return Binary_Search( middle + 1 , high , key , ch , j );
         else
          return Binary_Search( low , middle - 1 , key , ch , j );
    }
}

 int main(){
  int N , m , i , q , j;
  char ch;
  scanf( "%d" , &N );
  scanf( "%s" , Str + 1 );

     for( i = 1 ; i <= N ; i++ ){
      Present[Str[i] - 'a'] = 1;
      Array[Str[i] - 'a'].emplace_back( i );
    }

  scanf( "%d" , &q );
  int index , Temp , Ans = 0;
  bool Check;

     for( i = 1 ; i <= q ; i++ ){
      scanf( "%d" , &m );
      scanf( "%c" , &ch );
      Ans = 0;
      Check = 0;

         while( ch < 'a' || ch > 'z' )
          scanf( "%c" , &ch );

         if( Present[ch - 'a'] == 0 )
          printf( "%d\n" , m );
         else{
             for( j = 0 ; j < Array[ch - 'a'].size() ; j++ ){
              index = Binary_Search( j , Array[ch - 'a'].size() - 1 , m , ch - 'a' , j );

                 if( Array[ch - 'a'][index] - Array[ch - 'a'][j] - index + j <= m ){
                  Temp = Array[ch - 'a'][index] - Array[ch - 'a'][j] - index + j;
                  Ans = max( m - Temp + Array[ch - 'a'][index] - Array[ch - 'a'][j] + 1 , Ans );
                }
                 else{
                  Temp = Array[ch - 'a'][index - 1] - Array[ch - 'a'][j] - index + 1 + j;
                  Ans = max( m - Temp + Array[ch - 'a'][index - 1] - Array[ch - 'a'][j] + 1 , Ans );
                }

                 if( Ans >= N ){
                  printf( "%d\n" , N );
                  Check = 1;
                  break;
                }
            }

               if( Check )
                continue;

          Ans = min( Ans , N );
          printf( "%d\n" , Ans );
        }
    }

  return 0;
}


 #include "bits/stdc++.h"
 using namespace std;

 vector<int> Array[26];
 char Str[1505];
 bool Present[26];

 int Binary_Search( int low , int high , int key , int ch , int j ){
     if( low >= high )
      return low;
     else{
      int middle = ( low + high ) >> 1;

         if( Array[ch][middle] - Array[ch][j] - high + j <= key )
          return Binary_Search( middle + 1 , high , key , ch , j );
         else
          return Binary_Search( low , middle - 1 , key , ch , j );
    }
}

 int main(){
  int N , m , i , q , j;
  char ch;
  scanf( "%d" , &N );
  scanf( "%s" , Str + 1 );

     for( i = 1 ; i <= N ; i++ ){
      Present[Str[i] - 'a'] = 1;
      Array[Str[i] - 'a'].emplace_back( i );
    }

  scanf( "%d" , &q );
  int index , Temp , Ans = 0;

     for( i = 1 ; i <= q ; i++ ){
      scanf( "%d" , &m );
      scanf( "%c" , &ch );
      Ans = 0;

         while( ch < 'a' || ch > 'z' )
          scanf( "%c" , &ch );

         if( Present[ch - 'a'] == 0 )
          printf( "%d\n" , m );
         else{
             for( j = 0 ; j < Array[ch - 'a'].size() ; j++ ){
              index = Binary_Search( j , Array[ch - 'a'].size() - 1 , m , ch - 'a' , j );

                 if( Array[ch - 'a'][index] - Array[ch - 'a'][j] - index + j <= m ){
                  Temp = Array[ch - 'a'][index] - Array[ch - 'a'][j] - index + j;
                  Ans = max( m - Temp + Array[ch - 'a'][index] - Array[ch - 'a'][j] + 1 , Ans );
                }
                 else{
                  Temp = Array[ch - 'a'][index - 1] - Array[ch - 'a'][j] - index + 1 + j;
                  Ans = max( m - Temp + Array[ch - 'a'][index - 1] - Array[ch - 'a'][j] + 1 , Ans );
                }
            }

          Ans = max( Ans , N );
          printf( "%d\n" , Ans );
        }
    }

  return 0;
}


 #include "bits/stdc++.h"
 using namespace std;

 vector<int> Array[26];
 char Str[1505];
 bool Present[26];

 int Binary_Search( int low , int high , int key , int ch , int j ){
     if( low >= high )
      return low;
     else{
      int middle = ( low + high ) >> 1;

         if( Array[ch][middle] - Array[ch][j] - high + j <= key )
          return Binary_Search( middle + 1 , high , key , ch , j );
         else
          return Binary_Search( low , middle - 1 , key , ch , j );
    }
}

 int main(){
  int N , m , i , q , j;
  char ch;
  scanf( "%d" , &N );
  scanf( "%s" , Str + 1 );

     for( i = 1 ; i <= N ; i++ ){
      Present[Str[i] - 'a'] = 1;
      Array[Str[i] - 'a'].emplace_back( i );
    }

  scanf( "%d" , &q );
  int index , Temp , Ans = 0;

     for( i = 1 ; i <= q ; i++ ){
      scanf( "%d" , &m );
      scanf( "%c" , &ch );
      Ans = 0;

         while( ch < 'a' || ch > 'z' )
          scanf( "%c" , &ch );

         if( Present[ch - 'a'] == 0 )
          printf( "%d\n" , m );
         else{
             for( j = 0 ; j < Array[ch - 'a'].size() ; j++ ){
              index = Binary_Search( j , Array[ch - 'a'].size() - 1 , m , ch - 'a' , j );

                 if( Array[ch - 'a'][index] - Array[ch - 'a'][j] - index + j <= m ){
                  Temp = Array[ch - 'a'][index] - Array[ch - 'a'][j] - index + j;
                  Ans = max( m - Temp + Array[ch - 'a'][index] - Array[ch - 'a'][j] + 1 , Ans );
                }
                 else{
                  Temp = Array[ch - 'a'][index - 1] - Array[ch - 'a'][j] - index + 1 + j;
                  Ans = max( m - Temp + Array[ch - 'a'][index - 1] - Array[ch - 'a'][j] + 1 , Ans );
                }
            }

          Ans = min( Ans , N );
          printf( "%d\n" , Ans );
        }
    }

  return 0;
}


 #include "bits/stdc++.h"
 using namespace std;

 vector<int> Array[26];
 char Str[1505];
 bool Present[26];

 int Binary_Search( int low , int high , int key , int ch , int j ){
     if( low >= high )
      return low;
     else{
      int middle = ( low + high ) >> 1;

         if( Array[ch][middle] - Array[ch][j] - high + j <= key )
          return Binary_Search( middle + 1 , high , key , ch , j );
         else
          return Binary_Search( low , middle - 1 , key , ch , j );
    }
}

 int main(){
  int N , m , i , q , j;
  char ch;
  scanf( "%d" , &N );
  scanf( "%s" , Str + 1 );

     for( i = 1 ; i <= N ; i++ ){
      Present[Str[i] - 'a'] = 1;
      Array[Str[i] - 'a'].emplace_back( i );
    }

  scanf( "%d" , &q );
  int index , Temp , Ans = 0;

     for( i = 1 ; i <= q ; i++ ){
      scanf( "%d" , &m );
      scanf( "%c" , &ch );
      Ans = 0;

         while( ch < 'a' || ch > 'z' )
          scanf( "%c" , &ch );

         if( Present[ch - 'a'] == 0 )
          printf( "%d\n" , m );
         else{
             for( j = 0 ; j < Array[ch - 'a'].size() ; j++ ){
              index = Binary_Search( j , Array[ch - 'a'].size() - 1 , m , ch - 'a' , j );

                 if( Array[ch - 'a'][index] - Array[ch - 'a'][j] - index + j <= m ){
                  Temp = Array[ch - 'a'][index] - Array[ch - 'a'][j] - index + j;
                  Ans = max( m - Temp + Array[ch - 'a'][index] - Array[ch - 'a'][j] + 1 , Ans );
                }
                 else{
                  Temp = Array[ch - 'a'][index - 1] - Array[ch - 'a'][j] - index + 1 + j;
                  Ans = max( m - Temp + Array[ch - 'a'][index - 1] - Array[ch - 'a'][j] + 1 , Ans );
                }
            }

          printf( "%d\n" , Ans );
        }
    }

  return 0;
}


 #include "bits/stdc++.h"
 using namespace std;

 vector<int> Array[26];
 char Str[1505];
 bool Present[26];

 int Binary_Search( int low , int high , int key , int ch , int j ){
     if( low >= high )
      return low;
     else{
      int middle = ( low + high ) >> 1;

         if( Array[ch][middle] - Array[ch][j] - middle + j <= key )
          return Binary_Search( middle + 1 , high , key , ch , j );
         else
          return Binary_Search( low , middle - 1 , key , ch , j );
    }
}

 int main(){
  int N , m , i , q , j;
  char ch;
  scanf( "%d" , &N );
  scanf( "%s" , Str + 1 );

     for( i = 1 ; i <= N ; i++ ){
      Present[Str[i] - 'a'] = 1;
      Array[Str[i] - 'a'].emplace_back( i );
    }

  scanf( "%d" , &q );
  int index , Temp , Ans = 0;

     for( i = 1 ; i <= q ; i++ ){
      scanf( "%d" , &m );
      scanf( "%c" , &ch );
      Ans = 0;

         while( ch < 'a' || ch > 'z' )
          scanf( "%c" , &ch );

         if( Present[ch - 'a'] == 0 )
          printf( "%d\n" , m );
         else{
             for( j = 0 ; j < Array[ch - 'a'].size() ; j++ ){
              index = Binary_Search( j , Array[ch - 'a'].size() - 1 , m , ch - 'a' , j );

                 if( Array[ch - 'a'][index] - Array[ch - 'a'][j] - index + j <= m ){
                  Temp = Array[ch - 'a'][index] - Array[ch - 'a'][j] - index + j;
                  Ans = max( m - Temp + Array[ch - 'a'][index] - Array[ch - 'a'][j] + 1 , Ans );
                }
                 else{
                  Temp = Array[ch - 'a'][index - 1] - Array[ch - 'a'][j] - index + 1 + j;
                  Ans = max( m - Temp + Array[ch - 'a'][index - 1] - Array[ch - 'a'][j] + 1 , Ans );
                }

                 if( Ans >= N ){
                  printf( "%d\n" , N );
                  return 0;
                }
            }

          Ans = min( Ans , N );
          printf( "%d\n" , Ans );
        }
    }

  return 0;
}


#include<iostream>
#include<cstdio>
using namespace std;
int main()
{
    FILE *fp=fopen("input.txt","r");
    FILE *fp1=fopen("output.txt","w");
    int n,m;
    fscanf(fp,"%d%d",&n,&m);
    if(n<=m) {
        while(n||m) {
            if(m){fprintf(fp1,"G");m--;}
            if(n){fprintf(fp1,"B");n--;}
        }
    }else {
        while(n||m) {
            if(n){fprintf(fp1,"B");n--;}
            if(m){fprintf(fp1,"G");m--;}
        }
    }
    fprintf(fp1,"\n");
    fclose(fp1);
    fclose(fp);
    return 0;
}


#include<iostream>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<string>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<cstdlib>
#include<cassert>
#include<climits>
using namespace std;

#define s(a) scanf("%d",&a)
#define sl(a) scanf("%lld",&a)
#define sd(a) scanf("%lf",&a)
#define ss(a) scanf("%s",a)
#define p(a) printf("%d\n",a)
#define pl(a) printf("%lld\n",a)
#define pd(a) printf("%lf\n",a)
#define ps(a) printf("%s\n",a)

int main()
{
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    int a,b;
    s(a);s(b);
    if(a==b) {
        for(int i=0;i<(a+b);i++)
            if(i%2)printf("B");
            else printf("G");
    } else if(a>b) {
        for(int i=0;i<(2*b);i++)
            if(i%2)printf("G");
            else printf("B");
        for(int i=0;i<(a-b);i++)
            printf("B");
    } else {
        for(int i=0;i<(2*a);i++)
            if(i%2)printf("B");
            else printf("G");
        for(int i=0;i<(b-a);i++)
            printf("G");
    }
    printf("\n");
    return 0;
}


#include<iostream>
using namespace std;
int main()
{
    int n,m;
    cin>>n>>m;
    for(int i=0,j=0;i<n||j<m;i++,j++) {
        if(j<m)cout<<"G";
        if(i<n)cout<<"B";
    }
    cout<<endl;
    return 0;
}


#include<iostream>
using namespace std;
int main()
{
    int n,m;
    cin>>n>>m;
    for(int i=0,j=0;i<n||j<m;i++,j++) {
        if(i<n)cout<<"B";
        if(j<m)cout<<"G";
    }
    cout<<endl;
    return 0;
}


#include<iostream>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<string>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<cstdlib>
#include<cassert>
#include<climits>
using namespace std;

#define s(a) scanf("%d",&a)
#define sl(a) scanf("%lld",&a)
#define sd(a) scanf("%lf",&a)
#define ss(a) scanf("%s",a)
#define p(a) printf("%d\n",a)
#define pl(a) printf("%lld\n",a)
#define pd(a) printf("%lf\n",a)
#define ps(a) printf("%s\n",a)

int main()
{
    int a,b;
    s(a);s(b);
    if(a==b) {
        for(int i=0;i<a+b;i++)
            if(i%2)printf("B");
            else printf("G");
    } else if(a>b) {
        for(int i=0;i<2*b;i++)
            if(i%2)printf("G");
            else printf("B");
        for(int i=0;i<a-b;i++)
            printf("B");
    } else {
        for(int i=0;i<2*a;i++)
            if(i%2)printf("B");
            else printf("G");
        for(int i=0;i<b-a;i++)
            printf("G");
    }
    //cout<<endl;
    return 0;
}


#include<iostream>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<string>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<cstdlib>
#include<cassert>
#include<climits>
using namespace std;
/*
#define s(a) scanf("%d",&a)
#define sl(a) scanf("%lld",&a)
#define sd(a) scanf("%lf",&a)
#define ss(a) scanf("%s",a)
#define p(a) printf("%d\n",a)
#define pl(a) printf("%lld\n",a)
#define pd(a) printf("%lf\n",a)
#define ps(a) printf("%s\n",a)*/

int main()
{
    int a,b;
    cin>>a>>b;
    if(a==b) {
        for(int i=0;i<(a+b);i++)
            if(i%2)printf("B");
            else printf("G");
    } else if(a>b) {
        for(int i=0;i<(2*b);i++)
            if(i%2)printf("G");
            else printf("B");
        for(int i=0;i<(a-b);i++)
            printf("B");
    } else {
        for(int i=0;i<(2*a);i++)
            if(i%2)printf("B");
            else printf("G");
        for(int i=0;i<(b-a);i++)
            printf("G");
    }
    printf("\n");
    return 0;
}


#include<iostream>
using namespace std;
int main()
{
    int n,m;
    cin>>n>>m;
    if(n<=m) {
        while(n||m) {
            if(m){cout<<"G";m--;}
            if(n){cout<<"B";n--;}
        }
    }else {
        while(n||m) {
            if(n){cout<<"B";n--;}
            if(m){cout<<"G";m--;}
        }
    }
    cout<<endl;
    return 0;
}


#include<iostream>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<string>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<cstdlib>
#include<cassert>
#include<climits>
using namespace std;

#define s(a) scanf("%d",&a)
#define sl(a) scanf("%lld",&a)
#define sd(a) scanf("%lf",&a)
#define ss(a) scanf("%s",a)
#define p(a) printf("%d\n",a)
#define pl(a) printf("%lld\n",a)
#define pd(a) printf("%lf\n",a)
#define ps(a) printf("%s\n",a)

int main()
{
    int a,b;
    s(a);s(b);
    if(a==b) {
        for(int i=0;i<a+b;i++)
            if(i%2)cout<<"B";
            else cout<<"G";
    } else if(a>b) {
        for(int i=0;i<2*b;i++)
            if(i%2)cout<<"G";
            else cout<<"B";
        for(int i=0;i<a-b;i++)
            cout<<"B";
    } else {
        for(int i=0;i<2*a;i++)
            if(i%2)cout<<"B";
            else cout<<"G";
        for(int i=0;i<b-a;i++)
            cout<<"G";
    }
    cout<<endl;
    return 0;
}


#include<iostream>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<string>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<cstdlib>
#include<cassert>
#include<climits>
using namespace std;

#define s(a) scanf("%d",&a)
#define sl(a) scanf("%lld",&a)
#define sd(a) scanf("%lf",&a)
#define ss(a) scanf("%s",a)
#define p(a) printf("%d\n",a)
#define pl(a) printf("%lld\n",a)
#define pd(a) printf("%lf\n",a)
#define ps(a) printf("%s\n",a)

int main()
{
    int a,b;
    s(a);s(b);
    if(a==b) {
        for(int i=0;i<a+b;i++)
            if(i%2)cout<<"B";
            else cout<<"G";
    } else if(a>b) {
        for(int i=0;i<2*b;i++)
            if(i%2)cout<<"G";
            else cout<<"B";
        for(int i=0;i<a-b;i++)
            cout<<"B";
    } else {
        for(int i=0;i<2*a;i++)
            if(i%2)cout<<"B";
            else cout<<"G";
        for(int i=0;i<b-a;i++)
            cout<<"G";
    }
    //cout<<endl;
    return 0;
}


#include<iostream>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<string>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<cstdlib>
#include<cassert>
#include<climits>
using namespace std;
/*
#define s(a) scanf("%d",&a)
#define sl(a) scanf("%lld",&a)
#define sd(a) scanf("%lf",&a)
#define ss(a) scanf("%s",a)
#define p(a) printf("%d\n",a)
#define pl(a) printf("%lld\n",a)
#define pd(a) printf("%lf\n",a)
#define ps(a) printf("%s\n",a)*/

int main()
{
    int a,b;
    scanf("%d%d",&a,&b);
    if(a==b) {
        for(int i=0;i<(a+b);i++)
            if(i%2)printf("B");
            else printf("G");
    } else if(a>b) {
        for(int i=0;i<(2*b);i++)
            if(i%2)printf("G");
            else printf("B");
        for(int i=0;i<(a-b);i++)
            printf("B");
    } else {
        for(int i=0;i<(2*a);i++)
            if(i%2)printf("B");
            else printf("G");
        for(int i=0;i<(b-a);i++)
            printf("G");
    }
    printf("\n");
    return 0;
}


#include<iostream>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<string>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<cstdlib>
#include<cassert>
#include<climits>
using namespace std;
/*
#define s(a) scanf("%d",&a)
#define sl(a) scanf("%lld",&a)
#define sd(a) scanf("%lf",&a)
#define ss(a) scanf("%s",a)
#define p(a) printf("%d\n",a)
#define pl(a) printf("%lld\n",a)
#define pd(a) printf("%lf\n",a)
#define ps(a) printf("%s\n",a)*/

int main()
{
    int a,b;
    scanf("%d %d",&a,&b);
    if(a==b) {
        for(int i=0;i<(a+b);i++)
            if(i%2)printf("B");
            else printf("G");
    } else if(a>b) {
        for(int i=0;i<(2*b);i++)
            if(i%2)printf("G");
            else printf("B");
        for(int i=0;i<(a-b);i++)
            printf("B");
    } else {
        for(int i=0;i<(2*a);i++)
            if(i%2)printf("B");
            else printf("G");
        for(int i=0;i<(b-a);i++)
            printf("G");
    }
    printf("\n");
    return 0;
}


#include<iostream>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<string>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<cstdlib>
#include<cassert>
#include<climits>
using namespace std;
/*
#define s(a) scanf("%d",&a)
#define sl(a) scanf("%lld",&a)
#define sd(a) scanf("%lf",&a)
#define ss(a) scanf("%s",a)
#define p(a) printf("%d\n",a)
#define pl(a) printf("%lld\n",a)
#define pd(a) printf("%lf\n",a)
#define ps(a) printf("%s\n",a)*/

int main()
{
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    int a,b;
    cin>>a>>b;
    if(a==b) {
        for(int i=0;i<(a+b);i++)
            if(i%2)printf("B");
            else printf("G");
    } else if(a>b) {
        for(int i=0;i<(2*b);i++)
            if(i%2)printf("G");
            else printf("B");
        for(int i=0;i<(a-b);i++)
            printf("B");
    } else {
        for(int i=0;i<(2*a);i++)
            if(i%2)printf("B");
            else printf("G");
        for(int i=0;i<(b-a);i++)
            printf("G");
    }
    printf("\n");
    return 0;
}


#include<stdio.h>
int m,f,k;
int main()
{
    FILE *i,*o;
    i=fopen("input.txt","r+");
    o=fopen("output.txt","w+");
    fscanf(i,"%d %d",&m,&f);
    if(m==f)
        for(k=1; k<=m; k++)
        {
            fprintf(o,"BG");
        }
    else if(m>f)
    {
        for(k=1; k<=f; k++)
        {
            fprintf(o,"BG");
        }
        for(k=1; k<=(m-f); k++)
        {
            fprintf(o,"B");
        }
    }
    else if(m<f)
    {
        for(k=1; k<=m; k++)
        {
            fprintf(o,"GB");
        }
        for(k=1; k<=(f-m); k++)
        {
            fprintf(o,"G");
        }
    }
    fclose(i);
    fclose(o);
    return 0;
}


#include<stdio.h>
#include<string.h>
int main()
{
    FILE *k,*o;
    int n,m,i,j;
    k=fopen("input.txt","r+");
    o=fopen("output.txt","w+");
    while(fscanf(k,"%d %d",&n,&m)!=EOF)
    {
        char b[n],g[m];
        memset(b,0,sizeof b);
        memset(g,0,sizeof g);
        for(i=1; i<=n; i++)
        {
            b[i]='B';
        }
        for(i=1; i<=m; i++)
        {
            g[i]='G';
        }
        if(n==m)
        {
            i=1;
            while(i<=n)
            {
                fprintf(o,"%c%c",b[i],g[i]);
                i++;
            }
        }
        else if(n>m)
        {
            for(i=1; i<=m; i++)
                fprintf(o,"%c%c",b[i],g[i]);
            for(j=i; j<=n; j++)
                fprintf(o,"%c",b[j]);
        }
        else
        {
            for(i=1; i<=n; i++)
                fprintf(o,"%c%c",g[i],b[i]);
            for(j=i; j<=m; j++)
                fprintf(o,"%c",g[j]);
        }
        fprintf(o,"\n");
    }
    fclose(k);
    fclose(o);
    return 0;
}


#include<stdio.h>
#include<string.h>
int n,m,i,j;
int main()
{
    FILE *k,*o;
    k=fopen("input.txt","r+");
    o=fopen("output.txt","w+");
    fscanf(k," %d %d",&n,&m);
    char b[n],g[m];
    memset(b,0,sizeof b);
    memset(g,0,sizeof g);
    for(i=1; i<=n; i++)
    {
        b[i]='B';
    }
    for(i=1; i<=m; i++)
    {
        g[i]='G';
    }
    if(n==m)
    {
        i=1;
        while(i<=n)
        {
            fprintf(o,"%c%c",b[i],g[i]);
            i++;
        }
    }
    else if(n>m)
    {
        for(i=1; i<=m; i++)
            fprintf(o,"%c%c",b[i],g[i]);
        for(j=i; j<=n; j++)
            fprintf(o,"%c",b[j]);
    }
    else
    {
        for(i=1; i<=n; i++)
            fprintf(o,"%c%c",g[i],b[i]);
        for(j=i; j<=m; j++)
            fprintf(o,"%c",g[j]);
    }
    return 0;
}


#include<stdio.h>
int n,m,i,j;
int main()
{
    FILE *k,*o;
    k=fopen("input.txt","r+");
    o=fopen("output.txt","w+");
    fscanf(k,"%d %d",&n,&m);
    char b[n],g[m];
    for(i=1; i<=n; i++)
    {
        b[i]='B';
    }
    for(i=1; i<=m; i++)
    {
        g[i]='G';
    }
    if(n==m)
    {
        i=1;
        while(i<=n)
        {
            fprintf(o,"%c%c",b[i],g[i]);
            i++;
        }
    }
    else if(n>m)
    {
        for(i=1; i<=m; i++)
            fprintf(o,"%c%c",b[i],g[i]);
        for(j=i; j<=n; j++)
            fprintf(o,"%c",b[j]);
    }
    else if(n<m)
    {
        for(i=1; i<=n; i++)
            fprintf(o,"%c%c",g[i],b[i]);
        for(j=i; j<=m; j++)
            fprintf(o,"%c",g[j]);
    }
    fclose(k);
    fclose(o);
    return 0;
}


#include<stdio.h>
#include<string.h>
int n,m,i,j;
FILE *k,*o;
int main()
{
    k=fopen("input.txt","r+");
    o=fopen("output.txt","w+");
    fscanf(k,"%d %d",&n,&m);
    char b[n],g[m];
    memset(b,0,sizeof b);
    memset(g,0,sizeof g);
    for(i=1; i<=n; i++)
    {
        b[i]='B';
    }
    for(i=1; i<=m; i++)
    {
        g[i]='G';
    }
    if(n==m)
    {
        i=1;
        while(i<=n)
        {
            fprintf(o,"%c%c",b[i],g[i]);
            i++;
        }
    }
    else if(n>m)
    {
        for(i=1; i<=m; i++)
            fprintf(o,"%c%c",b[i],g[i]);
        for(j=i; j<=n; j++)
            fprintf(o,"%c",b[j]);
    }
    else
    {
        for(i=1; i<=n; i++)
            fprintf(o,"%c%c",g[i],b[i]);
        for(j=i; j<=m; j++)
            fprintf(o,"%c",g[j]);
    }
    fclose(k);
    fclose(o);
    return 0;
}


#include<stdio.h>
int m,f,k;
int main()
{
    FILE *i,*o;
    i=fopen("input.txt","r+");
    o=fopen("output.txt","w+");
    while(fscanf(i,"%d %d",&m,&f) !=EOF)
    {
        if(m==f)
            for(k=1; k<=m; k++)
            {
                fprintf(o,"BG");
            }
        else if(m>f)
        {
            for(k=1; k<=f; k++)
            {
                fprintf(o,"BG");
            }
            for(k=1; k<=(m-f); k++)
            {
                fprintf(o,"B");
            }
        }
        else if(m<f)
        {
            for(k=1; k<=m; k++)
            {
                fprintf(o,"GB");
            }
            for(k=1; k<=(f-m); k++)
            {
                fprintf(o,"G");
            }
        }
        fclose(i);
        fclose(o);
    }
    return 0;
}


#include<stdio.h>
int m,f,k;
int main()
{
    FILE *i,*o;
    i=fopen("input.txt","r+");
    o=fopen("output.txt","w+");
    fscanf(i,"%d %d",&m,&f);
    if(m==f)
    {
        for(k=1; k<=m; k++)
        {
            fprintf(o,"BG");
        }
    }
    else if(m>f)
    {
        for(k=1; k<=f; k++)
        {
            fprintf(o,"BG");
        }
        for(k=1; k<=(m-f); k++)
        {
            fprintf(o,"B");
        }
    }
    else if(m<f)
    {
        for(k=1; k<=m; k++)
        {
            fprintf(o,"GB");
        }
        for(k=1; k<=(f-m); k++)
        {
            fprintf(o,"G");
        }
    }
    return 0;
}


#include<stdio.h>
int m,f,k;
int main()
{
    FILE *i,*o;
    i=fopen("input.txt","r");
    o=fopen("output.txt","w");
    fscanf(i," %d %d",&m,&f);
    if(m==f)
    {
        for(k=1; k<=m; k++)
        {
            fprintf(o,"BG");
        }
    }
    else if(m>f)
    {
        for(k=1; k<=f; k++)
        {
            fprintf(o,"BG");
        }
        for(k=1; k<=(m-f); k++)
        {
            fprintf(o,"B");
        }
    }
    else if(m<f)
    {
        for(k=1; k<=m; k++)
        {
            fprintf(o,"GB");
        }
        for(k=1; k<=(f-m); k++)
        {
            fprintf(o,"G");
        }
    }
    return 0;
}


#include<stdio.h>
#include<string.h>
int n,m,i,j;
int main()
{
    FILE *k,*o;
    k=fopen("input.txt","r+");
    o=fopen("output.txt","w+");
    fscanf(k," %d %d",&n,&m);
    char b[n],g[m];
    memset(b,0,sizeof b);
    memset(g,0,sizeof g);
    for(i=1; i<=n; i++)
    {
        b[i]='B';
    }
    for(i=1; i<=m; i++)
    {
        g[i]='G';
    }
    if(n==m)
    {
        i=1;
        while(i<=n)
        {
            fprintf(o,"%c%c",b[i],g[i]);
            i++;
        }
    }
    if(n>m)
    {
        for(i=1; i<=m; i++)
            fprintf(o,"%c%c",b[i],g[i]);
        for(j=i; j<=n; j++)
            fprintf(o,"%c",b[j]);
    }
    if(n<m)
    {
        for(i=1; i<=n; i++)
            fprintf(o,"%c%c",g[i],b[i]);
        for(j=i; j<=m; j++)
            fprintf(o,"%c",g[j]);
    }
    fclose(k);
    fclose(o);
    return 0;
}


#include<stdio.h>
#include<string.h>
int n,m,i,j;
int main()
{
    FILE *k,*o;
    k=fopen("input.txt","r+");
    o=fopen("output.txt","w+");
    fscanf(k,"%d %d",&n,&m);
    char b[n],g[m];
    memset(b,0,sizeof b);
    memset(g,0,sizeof g);
    for(i=1; i<=n; i++)
    {
        b[i]='B';
    }
    for(i=1; i<=m; i++)
    {
        g[i]='G';
    }
    if(n==m)
    {
        i=1;
        while(i<=n)
        {
            fprintf(o,"%c%c",b[i],g[i]);
            i++;
        }
    }
    else if(n>m)
    {
        for(i=1; i<=m; i++)
            fprintf(o,"%c%c",b[i],g[i]);
        for(j=i; j<=n; j++)
            fprintf(o,"%c",b[j]);
    }
    else if(n<m)
    {
        for(i=1; i<=n; i++)
            fprintf(o,"%c%c",g[i],b[i]);
        for(j=i; j<=m; j++)
            fprintf(o,"%c",g[j]);
    }
    fclose(k);
    fclose(o);
    return 0;
}


#include<stdio.h>
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
    int n,m;
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    while (scanf("%d%d",&n,&m) != EOF)
    {
        if (n < m)
        {
            for (int i = 0;i < n;i++)
                printf("GB");
            for (int i = n;i < m;i++)
                printf("G");
        }
        else
        {
            for (int i = 0;i < m;i++)
                printf("BG");
            for (int i = m;i < n;i++)
                printf("B");
        }
        printf("\n");
    }
    return 0;

}


#include <algorithm>
#include <cstdio>
#include<iostream>
#include<cstring>
#include <sstream>
#include <string>
using namespace std;

int main()
{
int n,d,i,j,k,l,m,count=0;
cin>>n>>m;
if(n==m)
{
    for(i=0;i<n;i++)
    {
        cout<<"BG";
    }
}
else if(n<m)
{
    cout<<"G";
    for(i=0;i<n;i++)
    {
        cout<<"BG";
    }
    for(j=i+1;j<m;j++)
    {
        cout<<"G";
    }

}
else
{
      cout<<"B";
    for(i=0;i<m;i++)
    {
        cout<<"GB";
    }
    for(j=i+1;j<n;j++)
    {
        cout<<"B";
    }

}

    return 0;
}


#include <algorithm>
#include <cstdio>
#include<iostream>
#include<cstring>
#include <sstream>
#include <string>
using namespace std;

int main()
{
long long int n,d,i,j,k,l,m;
cin>>n>>m;
cout<<"BG";
    return 0;
}


#include<iostream>

using namespace std;

int main()
{
int n,d,i,j,k,l,m,count=0;
string out="";
cin>>n>>m;
if(n==m)
{
    for(i=0;i<n;i++)
    {
        out+="BG";
    }
}
else if(n<m)
{
    out+="G";
    for(i=0;i<n;i++)
    {
        out+="BG";
    }
    for(j=i+1;j<m;j++)
    {
        out+="G";
    }

}
else
{
     out+="B";
    for(i=0;i<m;i++)
    {
        out+="GB";
    }
    for(j=i+1;j<n;j++)
    {
        out+="B";
    }

}
cout<<out<<"\n";

    return 0;
}


#include <algorithm>
#include <cstdio>
#include<iostream>
#include<cstring>
#include <sstream>
#include <string>
using namespace std;

int main()
{
long long int n,d,i,j,k,l,m;
cin>>n>;
cin>>m;
cout<<"BG";
    return 0;
}


#include<iostream>

using namespace std;

int main()
{
int n,d,i,j,k,l,m,count=0;
string out="";
cin>>n>>m;
cout<<"P";
if(n==m)
{
    for(i=0;i<n;i++)
    {
        out+="BG";
    }
}
else if(n<m)
{
    out+="G";
    for(i=0;i<n;i++)
    {
        out+="BG";
    }
    for(j=i+1;j<m;j++)
    {
        out+="G";
    }

}
else
{
     out+="B";
    for(i=0;i<m;i++)
    {
        out+="GB";
    }
    for(j=i+1;j<n;j++)
    {
        out+="B";
    }

}
cout<<out;

    return 0;
}


#include <iostream>

using namespace std;

int main()
{
int n,d,i,j,k,l,m,count=0;
 freopen ( "input.txt", "r", stdin );
    freopen ( "output.txt", "w", stdout );
string out="123";
cin>>n>>m;

cout<<out;

    return 0;
}


#include <algorithm>
#include <cstdio>
#include<iostream>
#include<cstring>
#include <sstream>
#include <string>
using namespace std;

int main()
{
long long int n,d,i,j,k,l,m;
int a[11000];
cin>>n;
for(i=0;i<n;i++)
cin>>a[i];
int count=0;
for(i=0;i<n;i++)
{
    count=count|a[i];
}
cout<<count;
    return 0;
}


#include <algorithm>
#include <cstdio>
#include<iostream>
#include<cstring>
#include <sstream>
#include <string>
using namespace std;

int main()
{
long long int n,d,i,j,k,l,m;
cin>>n;
cin>>m;
cout<<"BG";
    return 0;
}


#include<iostream>

using namespace std;

int main()
{
int n,d,i,j,k,l,m,count=0;
string out="";
cin>>n>>m;
if(n==m)
{
    for(i=0;i<n;i++)
    {
        out+="BG";
    }
}
else if(n<m)
{
    out+="G";
    for(i=0;i<n;i++)
    {
        out+="BG";
    }
    for(j=i+1;j<m;j++)
    {
        out+="G";
    }

}
else
{
     out+="B";
    for(i=0;i<m;i++)
    {
        out+="GB";
    }
    for(j=i+1;j<n;j++)
    {
        out+="B";
    }

}
cout<<out;

    return 0;
}


#include<iostream>

using namespace std;

int main()
{
int n,d,i,j,k,l,m,count=0;
string out="123";
cin>>n>>m;

cout<<out;

    return 0;
}


#include<stdio.h>
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
    int n,m;

  scanf("%d%d",&n,&m) ;

        if (n < m)
        {
            for (int i = 0;i < n;i++)
                printf("GB");
            for (int i = n;i < m;i++)
                printf("G");
        }
        else
        {
            for (int i = 0;i < m;i++)
                printf("BG");
            for (int i = m;i < n;i++)
                printf("B");
        }
        printf("\n");

    return 0;

}


#include <algorithm>
#include <cstdio>
#include<iostream>
#include<cstring>
#include <sstream>
#include <string>
using namespace std;

int main()
{
long long int n,d,i,j,k,l,m,count=0;
cin>>n>>m;
if(n==m)
{
    for(i=0;i<n;i++)
    {
        cout<<"BG";
    }
}else if(n<m)
{
    cout<<"G";
    for(i=0;i<n;i++)
    {
        cout<<"BG";
    }
    for(j=i+1;j<m;j++)
    {
        cout<<"G";
    }

}
else
{
      cout<<"B";
    for(i=0;i<m;i++)
    {
        cout<<"GB";
    }
    for(j=i+1;j<n;j++)
    {
        cout<<"B";
    }

}

    return 0;
}


#include <iostream>
#include <algorithm>
#include <cstdio>
using namespace std;

int main()
{
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    int a,b;
    cin>>a>>b;
    while(a+b>0)
    {
        if(a>0) cout<<"B",a--;
        if(b>0) cout<<"G",b--;
    }
    cout<<endl;
    return 0;
}


#include <iostream>
#include <algorithm>
#include <cstdio>
using namespace std;

int main()
{
    freopen("input.txt.in","r",stdin);
    freopen("output.txt.out","w",stdout);
    int a,b;
    cin>>a>>b;
    while(a+b>0)
    {
        if(a>0) cout<<"B",a--;
        if(b>0) cout<<"G",b--;
    }
    cout<<endl;
    return 0;
}


#include <iostream>
#include <algorithm>
using namespace std;

int main()
{
    int a,b,c;
    cin>>a>>b;
    while(a>0 || b>0)
    {
        if(a>0) cout<<"B";
        if(b>0) cout<<"G";
        a--;b--;
    }
    cout<<endl;
    return 0;
}


#include <iostream>
#include <algorithm>
using namespace std;

int main()
{
    int a,b,c,g=0,v=0;
    cin>>a>>b;
    while(a+b>0)
    {
        if(a>0) cout<<"B",a--;
        if(b>0) cout<<"G",b--;
    }
    cout<<endl;
    return 0;
}


#include <iostream>
#include <algorithm>
#include <cstdio>
using namespace std;

int main()
{
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    int a,b,g,h;
    cin>>a>>b;
    g=a;h=b;
    while(a+b>0)
    {
        if(g>h)
        {
            if(a>0) cout<<"B",a--;
            if(b>0) cout<<"G",b--;
        }
        else
        {
            if(b>0) cout<<"G",b--;
            if(a>0) cout<<"B",a--;
        }
    }
    cout<<endl;
    return 0;
}


#include <iostream>
#include <algorithm>
#include <cstdio>
using namespace std;

int main()
{
    freopen("input.in","r",stdin);
    freopen("output.out","w",stdout);
    int a,b;
    cin>>a>>b;
    while(a+b>0)
    {
        if(a>0) cout<<"B",a--;
        if(b>0) cout<<"G",b--;
    }
    cout<<endl;
    return 0;
}


#include <iostream>
#include <algorithm>
#include <cstdio>
using namespace std;

int main()
{
    freopen("input","r",stdin);
    freopen("output","w",stdout);
    int a,b;
    cin>>a>>b;
    while(a+b>0)
    {
        if(a>0) cout<<"B",a--;
        if(b>0) cout<<"G",b--;
    }
    cout<<endl;
    return 0;
}


#include <iostream>
#include <algorithm>
using namespace std;

int main()
{
    int a,b;
    cin>>a>>b;
    while(a+b>0)
    {
        if(a>0) cout<<"B",a--;
        if(b>0) cout<<"G",b--;
    }
    cout<<endl;
    return 0;
}


#include <iostream>

using namespace std;

int main()
{
    int a,b,c;
    cin>>a>>b;
    while(a>0 || b>0)
    {
        if(a>0) cout<<"B";
        if(b>0) cout<<"G";
        a--;b--;
    }
    cout<<endl;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;

int main()
{
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    int n, m;
    scanf("%d %d", &n, &m);
    if(n > m)
    {
        for(int i = 1; i <= 2*m; i++)
            printf("%c", (i%2==1)?'B':'G');
        for(int i = 1; i <= n-m; i++)
            printf("B");
        puts("");
    }
    else
    {
        for(int i = 1; i <= 2*n; i++)
            printf("%c", (i%2==1)?'G':'B');
        for(int i = 1; i <= m-n; i++)
            printf("G");
        puts("");
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;

int main()
{
    freopen("input.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
    int n, m;
    scanf("%d %d", &n, &m);
    if(n > m)
    {
        for(int i = 1; i <= 2*m; i++)
            printf("%c", (i%2==1)?'B':'G');
        for(int i = 1; i <= n-m; i++)
            printf("B");
        puts("");
    }
    else
    {
        for(int i = 1; i <= 2*n; i++)
            printf("%c", (i%2==1)?'G':'B');
        for(int i = 1; i <= m-n; i++)
            printf("G");
        puts("");
    }
}


#include <bits/stdc++.h>
using namespace std;

int main()
{
    int n, m;
    while(~scanf("%d %d", &n, &m))
    {
        freopen("input.txt", "r", stdin);
        freopen("out.txt", "w", stdout);
        if(n > m)
        {
            for(int i = 1;i <= 2*m;i++)
                printf("%c", (i%2==1)?'B':'G');
            for(int i = 1;i <= n-m;i++)
                printf("B");
            puts("");
        }else
        {
            for(int i = 1;i <= 2*n;i++)
                printf("%c", (i%2==1)?'G':'B');
            for(int i = 1;i <= m-n;i++)
                printf("G");
            puts("");
        }
        fclose(stdin);
        fclose(stdout);
    }
}


#include <bits/stdc++.h>
using namespace std;

int main()
{
    int n, m;
    while(~scanf("%d %d", &n, &m))
    {
        if(n > m)
        {
            for(int i = 1;i <= 2*m;i++)
                printf("%c", (i%2==1)?'B':'G');
            for(int i = 1;i <= n-m;i++)
                printf("B");
            puts("");
        }else
        {
            for(int i = 1;i <= 2*n;i++)
                printf("%c", (i%2==1)?'G':'B');
            for(int i = 1;i <= m-n;i++)
                printf("G");
            puts("");
        }
    }
}


#include <bits/stdc++.h>
using namespace std;

int main()
{
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    int n, m;
    scanf("%d%d",&n,&m);
    if (n > m)
    {
        int diff = n - m;
        while (m--)
        {
            putchar('B');
            putchar('G');
        }
        while (diff--) putchar('B');
    }
    else
    {
        int diff = m - n;
        while (n--)
        {
            putchar('G');
            putchar('B');
        }
        while (diff--) putchar('G');
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;

int main()
{
    freopen("input.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
    int n, m;
    scanf("%d %d", &n, &m);
    if(n > m)
    {
        for(int i = 1; i <= 2*m; i++)
            printf("%c", (i%2==1)?'B':'G');
        for(int i = 1; i <= n-m; i++)
            printf("B");
        puts("");
    }
    else
    {
        for(int i = 1; i <= 2*n; i++)
            printf("%c", (i%2==1)?'G':'B');
        for(int i = 1; i <= m-n; i++)
            printf("G");
        puts("");
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;

int main()
{
    int n, m;
    freopen("input.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
    if(n > m)
    {
        for(int i = 1; i <= 2*m; i++)
            printf("%c", (i%2==1)?'B':'G');
        for(int i = 1; i <= n-m; i++)
            printf("B");
        puts("");
    }
    else
    {
        for(int i = 1; i <= 2*n; i++)
            printf("%c", (i%2==1)?'G':'B');
        for(int i = 1; i <= m-n; i++)
            printf("G");
        puts("");
    }
    fclose(stdin);
    fclose(stdout);
}


#include <bits/stdc++.h>
using namespace std;

int main()
{
    int n, m;
    while(~scanf("%d %d", &n, &m))
    {
        freopen("out.txt", "w", stdout);
        if(n > m)
        {
            for(int i = 1;i <= 2*m;i++)
                printf("%c", (i%2==1)?'B':'G');
            for(int i = 1;i <= n-m;i++)
                printf("B");
            puts("");
        }else
        {
            for(int i = 1;i <= 2*n;i++)
                printf("%c", (i%2==1)?'G':'B');
            for(int i = 1;i <= m-n;i++)
                printf("G");
            puts("");
        }
        fclose(stdout);
    }
}


#include <bits/stdc++.h>
using namespace std;

int main()
{
    int n, m;
    freopen("input.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
    if(n > m)
    {
        for(int i = 1; i <= 2*m; i++)
            printf("%c", (i%2==1)?'B':'G');
        for(int i = 1; i <= n-m; i++)
            printf("B");
        puts("");
    }
    else
    {
        for(int i = 1; i <= 2*n; i++)
            printf("%c", (i%2==1)?'G':'B');
        for(int i = 1; i <= m-n; i++)
            printf("G");
        puts("");
    }
}


#include <string>
#include <iostream>

using namespace std;

int main()
{
    int n, m;

    cin >> n >> m;

    string ans;

    while (n != 0 || m != 0) {
        if (n > 0) {
            n--;
            ans.append("B");
        }

        if (m > 0) {
            m--;
            ans.append("G");
        }
    }

    cout << ans << endl;
    return 0;
}


#include <string>
#include <iostream>
#include <stdio.h>

using namespace std;

int main()
{
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);

    int n, m;

    cin >> n >> m;

    string ans;

        if (m > n) {
            while (n != 0 || m != 0) {
            if (m > 0) {
                m--;
                ans.append("G");
            }

            if (n > 0) {
                n--;
                ans.append("B");
            }
        }
    } else if (n >= m) {
        while (n != 0 || m != 0) {
            if (n > 0) {
                n--;
                ans.append("B");
            }

            if (m > 0) {
                m--;
                ans.append("G");
            }
        }
    }

    cout << ans << endl;
    return 0;
}


#include <string>
#include <iostream>
#include <stdio.h>

using namespace std;

int main()
{
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);

    int n, m;

    cin >> n >> m;

    string ans;

    while (n != 0 || m != 0) {
        if (m > 0) {
            m--;
            ans.append("G");
        }

        if (n > 0) {
            n--;
            ans.append("B");
        }

    }

    cout << ans << endl;
    return 0;
}


#include <string>
#include <iostream>
#include <stdio.h>

using namespace std;

int main()
{
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);

    int n, m;

    cin >> n >> m;

    string ans;

    while (n != 0 || m != 0) {
        if (n > 0) {
            n--;
            ans.append("B");
        }

        if (m > 0) {
            m--;
            ans.append("G");
        }
    }

    cout << ans << endl;
    return 0;
}


#include <string>
#include <iostream>
#include <stdio.h>

using namespace std;

int main()
{
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);

    int n, m;

    cin >> n >> m;

    string ans;

    while (n != 0 || m != 0) {
        if (m > n) {
            if (m > 0) {
                m--;
                ans.append("G");
            }

            if (n > 0) {
                n--;
                ans.append("B");
            }
        }
        else if (n > m) {
            if (n > 0) {
                n--;
                ans.append("B");
            }

            if (m > 0) {
                m--;
                ans.append("G");
            }
        }
    }

    cout << ans << endl;
    return 0;
}


#include <string>
#include <iostream>
#include <stdio.h>

using namespace std;

int main()
{
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);

    int n, m;

    cin >> n >> m;

    string ans;

        if (m > n) {
            while (n != 0 || m != 0) {
            if (m > 0) {
                m--;
                ans.append("G");
            }

            if (n > 0) {
                n--;
                ans.append("B");
            }
        }
    } else if (n > m) {
        while (n != 0 || m != 0) {
            if (n > 0) {
                n--;
                ans.append("B");
            }

            if (m > 0) {
                m--;
                ans.append("G");
            }
        }
    }

    cout << ans << endl;
    return 0;
}


#include <string>
#include <iostream>

using namespace std;

int main()
{
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);

    int n, m;

    cin >> n >> m;

    string ans;

    while (n != 0 || m != 0) {
        if (n > 0) {
            n--;
            ans.append("B");
        }

        if (m > 0) {
            m--;
            ans.append("G");
        }
    }

    cout << ans << endl;
    return 0;
}


#include <string>
#include <iostream>
#include <stdio.h>

using namespace std;

int main()
{
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);

    int n, m;

    cin >> n >> m;

    string ans;

    while (n != 0 || m != 0) {
        if (m > 0) {
            n--;
            ans.append("B");
        }

        if (n > 0) {
            m--;
            ans.append("G");
        }
    }

    cout << ans << endl;
    return 0;
}


#include <string>
#include <iostream>
#include <stdio.h>

using namespace std;

int main()
{
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);

    int n, m;

    cin >> n >> m;

    string ans;

    while (n != 0 || m != 0) {
        if (m > 0) {
            m--;
            ans.append("B");
        }

        if (n > 0) {
            n--;
            ans.append("G");
        }
    }

    cout << ans << endl;
    return 0;
}


#include<iostream>
#include<cstdio>
using namespace std;

int main() {

	int b,g,i;
	cin>>b>>g;
	if(b==g)
	{
		for(i=0; i<b; i++)
			cout<<"BG";
		return 0;
	}
	if(b>g)
	{
		for(i=0; i<g; i++)
			cout<<"BG";
		for(i=0; i<b-g; i++)
			cout<<"B";
		return 0;
	}
		for(i=0; i<b; i++)
			cout<<"BG";
		for(i=0; i<g-b; i++)
			cout<<"B";

	return 0;
}


#include<iostream>
#include<cstdio>
using namespace std;

	int b,g,i;
int main() {

	cin>>b>>g;
	if(b==g)
	{
		for(i=0; i<b; i++)
			printf("GB");
		return 0;
	}
	if(b>g)
	{
		for(i=0; i<g; i++)
			printf("GB");
		for(i=0; i<b-g; i++)
			printf("B");
		return 0;
	}
		for(i=0; i<b; i++)
			printf("GB");
		for(i=0; i<g-b; i++)
			printf("G");

	return 0;
}


#include<iostream>
#include<cstdio>
using namespace std;

	int b,g,i;
int main() {

	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);

	cin>>b>>g;
	if(b==g)
	{
		for(i=0; i<b; i++)
			printf("GB");
		return 0;
	}
	if(b>g)
	{
		for(i=0; i<g; i++)
			printf("BG");
		for(i=0; i<b-g; i++)
			printf("B");
		return 0;
	}
		for(i=0; i<b; i++)
			printf("GB");
		for(i=0; i<g-b; i++)
			printf("G");

	return 0;
}


#include<iostream>
#include<cstdio>
using namespace std;

	int b,g,i;
int main() {

	cin>>b>>g;
	if(b==g)
	{
		for(i=0; i<b; i++)
			cout<<"GB";
		return 0;
	}
	if(b>g)
	{
		for(i=0; i<g; i++)
			cout<<"GB";
		for(i=0; i<b-g; i++)
			cout<<"B";
		return 0;
	}
		for(i=0; i<b; i++)
			cout<<"GB";
		for(i=0; i<g-b; i++)
			cout<<"G";

	return 0;
}


#include<iostream>
#include<cstdio>
using namespace std;

	int b,g,i;
int main() {

	freopen("input.txt","r");
	freopen("output.txt"."w");

	cin>>b>>g;
	if(b==g)
	{
		for(i=0; i<b; i++)
			printf("GB");
		return 0;
	}
	if(b>g)
	{
		for(i=0; i<g; i++)
			printf("GB");
		for(i=0; i<b-g; i++)
			printf("B");
		return 0;
	}
		for(i=0; i<b; i++)
			printf("GB");
		for(i=0; i<g-b; i++)
			printf("G");

	return 0;
}


#include<iostream>
#include<cstdio>
using namespace std;

	int b,g,i;
int main() {

	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);

	cin>>b>>g;
	if(b==g)
	{
		for(i=0; i<b; i++)
			printf("GB");
		return 0;
	}
	if(b>g)
	{
		for(i=0; i<g; i++)
			printf("GB");
		for(i=0; i<b-g; i++)
			printf("B");
		return 0;
	}
		for(i=0; i<b; i++)
			printf("GB");
		for(i=0; i<g-b; i++)
			printf("G");

	return 0;
}


#include<iostream>
#include<cstdio>
using namespace std;

int main() {

	int b,g,i;
	cin>>b>>g;
	if(b==g)
	{
		for(i=0; i<b; i++)
			cout<<"GB";
		return 0;
	}
	if(b>g)
	{
		for(i=0; i<g; i++)
			cout<<"GB";
		for(i=0; i<b-g; i++)
			cout<<"B";
		return 0;
	}
		for(i=0; i<b; i++)
			cout<<"GB";
		for(i=0; i<g-b; i++)
			cout<<"B";

	return 0;
}


#include<iostream>
#include<cstdio>
using namespace std;

	int b,g,i;
int main() {

	freopen("input.txt","r",stdin);
	freopen("output.txt"."w",stdout);

	cin>>b>>g;
	if(b==g)
	{
		for(i=0; i<b; i++)
			printf("GB");
		return 0;
	}
	if(b>g)
	{
		for(i=0; i<g; i++)
			printf("GB");
		for(i=0; i<b-g; i++)
			printf("B");
		return 0;
	}
		for(i=0; i<b; i++)
			printf("GB");
		for(i=0; i<g-b; i++)
			printf("G");

	return 0;
}


#include <stdio.h>
#include <iostream>
#include <string.h>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <string>
using namespace std;
/*my_template*/
/*data type*/
typedef pair<int,int> pii;
typedef long long ll; typedef double dl;
typedef vector<pii> vii;
typedef set<pii> sii;
/*sim_operarion*/
#define sfint(x) scanf("%d",&x)
#define sfint2(x,y) scanf("%d%d",&x,&y)
#define sfint3(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define sfstr(c) scanf("%s",c)
#define pfint(x) printf("%d\n",x)
#define fr(i,s,n) for(int i=s;i<n;++i)
#define _fr(i,n,s) for(int i=n-1;i>=s;--i)
#define cl(a) memset(a,0,sizeof(a))
/*bitmask*/
#define _ni(x) (1<<(x))
#define _niL(x) (1LL<<(x))
#define _has(s,x) ((s&(_ni(x)))!=0)
#define _hasL(s,x) ((s&(_niL(x)))!=0LL)
template<class T> inline T _lowbit(const int &x){ return (x^(x-1))&x; }
template<class T> inline int _bitsize(const T &x){ return (x==0)?0:(1+_bitsize(x&(x-1))); }
/*CONST VALUE*/
const dl _pi=acos(-1.0);
const dl _eps=1e-6;
/*my_template*/
int n,m;

int main(){
#ifdef local

#endif

	sfint2(n,m);
	if (n>m){
		fr(i , 0,m)
		printf("BG");
		fr(i,m,n ) printf("B");
	}
	else{
		fr(i ,0,n){
			printf("GB");
		}
		fr(i , n,m){
			printf("G");
		}
	}
	return 0;
}


#include <iostream>

using namespace std;

int main()
{
    int n,m;
    cin>>n>>m;
    if (n>m)
    {
        for(int i = 0;i<m;i++)
        {
            cout<<"BG";
        }
        for(int i = m;i<n;i++)
        {
            cout<<"B";
        }
    }
    else
    {
        for(int i = 0;i<n;i++)
        {
            cout<<"GB";
        }
        for(int i = n;i<m;i++)
        {
            cout<<"G";
        }
    }
}


#include <stdio.h>
#include <iostream>
#include <string.h>
#include <cmath>
#include <vector>
#include <set>
#include <algorithm>
using namespace std;
/*data type*/
typedef pair<int,int> pii;
typedef long long ll; typedef double dl;
typedef vector<pii> vii;
typedef set<pii> sii;
/*sim_operarion*/
#define sfint(x) scanf("%d",&x)
#define sfint2(x,y) scanf("%d%d",&x,&y)
#define sfint3(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define sfstr(c) scanf("%s",c)
#define pfint(x) printf("%d\n",x)
#define fr(i,s,n) for(i=s;i<n;++i)
#define _fr(i,n,s) for(i=n-1;i>=s;--i)
#define cl(a) memset(a,0,sizeof(a))
/*bitmask*/
template<class T> inline T _lowbit(const int &x){ return (x^(x-1))&x; }
template<class T> inline int _bitsize(const T &x){ return (x==0)?0:(1+_bitsize(x&(x-1))); }
/*CONST VALUE*/
const dl _pi=acos(-1.0);
const dl _eps=1e-6;

int n,m;
int main(){
	int i;
	sfint2(n,m);
	if(n>m){
		fr(i,0,m){
			printf("BG");
		}
		fr(i,m,n){
			printf("B");
		}
	}
	else{
		fr(i,0,n){
			printf("GB");
		}
		fr(i,n,m){
			printf("G");
		}
	}
	return 0;
}


#define local

#define fi freopen("input.txt","r",stdin)
#define fo freopen("ouput.txt","w",stdout)
#include <stdio.h>
#include <iostream>
#include <string.h>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <string>
using namespace std;
/*my_template*/
/*data type*/
typedef pair<int,int> pii;
typedef long long ll; typedef double dl;
typedef vector<pii> vii;
typedef set<pii> sii;
/*sim_operarion*/
#define sfint(x) scanf("%d",&x)
#define sfint2(x,y) scanf("%d%d",&x,&y)
#define sfint3(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define sfstr(c) scanf("%s",c)
#define pfint(x) printf("%d\n",x)
#define fr(i,s,n) for(int i=s;i<n;++i)
#define _fr(i,n,s) for(int i=n-1;i>=s;--i)
#define cl(a) memset(a,0,sizeof(a))
/*bitmask*/
#define _ni(x) (1<<(x))
#define _niL(x) (1LL<<(x))
#define _has(s,x) ((s&(_ni(x)))!=0)
#define _hasL(s,x) ((s&(_niL(x)))!=0LL)
template<class T> inline T _lowbit(const int &x){ return (x^(x-1))&x; }
template<class T> inline int _bitsize(const T &x){ return (x==0)?0:(1+_bitsize(x&(x-1))); }
/*CONST VALUE*/
const dl _pi=acos(-1.0);
const dl _eps=1e-6;
/*my_template*/
int n,m;

int main(){
#ifdef local
	fi;fo;
#endif

	sfint2(n,m);
	if (n>m){
		fr(i , 0,m)
		printf("BG");
		fr(i,m,n ) printf("B");
	}
	else{
		fr(i ,0,n){
			printf("GB");
		}
		fr(i , n,m){
			printf("G");
		}
	}
	return 0;
}


#include <iostream>

using namespace std;

int main()
{
    int n,m;
    cin>>n>>m;
    if (n>m)
    {
        for(int i = 0;i<m;i++)
        {
            cout<<"BG";
        }
        for(int i = m;i<n;i++)
        {
            cout<<"B";
        }
    }
    else
    {
        for(int i = 0;i<n;i++)
        {
            cout<<"GB";
        }
        for(int i = n;i<m;i++)
        {
            cout<<"G";
        }
    }
    return 0;
}


#include <stdio.h>
#include <iostream>
#include <string.h>
#include <cmath>
#include <vector>
#include <set>
#include <algorithm>
using namespace std;
/*data type*/
typedef pair<int,int> pii;
typedef long long ll; typedef double dl;
typedef vector<pii> vii;
typedef set<pii> sii;
/*sim_operarion*/
#define sfint(x) scanf("%d",&x)
#define sfint2(x,y) scanf("%d%d",&x,&y)
#define sfint3(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define sfstr(c) scanf("%s",c)
#define pfint(x) printf("%d\n",x)
#define fr(i,s,n) for(i=s;i<n;++i)
#define _fr(i,n,s) for(i=n-1;i>=s;--i)
#define cl(a) memset(a,0,sizeof(a))
/*bitmask*/
template<class T> inline T _lowbit(const int &x){ return (x^(x-1))&x; }
template<class T> inline int _bitsize(const T &x){ return (x==0)?0:(1+_bitsize(x&(x-1))); }
/*CONST VALUE*/
const dl _pi=acos(-1.0);
const dl _eps=1e-6;

int n,m;
int main(){
	int i;
	sfint2(n,m);
	if(n>m){
		fr(i,0,m){
			printf("BG");
		}
		fr(i,m,n){
			printf("B");
		}
		printf("\n");
	}
	else{
		fr(i,0,n){
			printf("GB");
		}
		fr(i,n,m){
			printf("G");
		}
		printf("\n");
	}
	return 0;
}


	#define fi freopen("input.txt","r",stdin)
	#define fo freopen("output.txt","w",stdin)
	#include <stdio.h>
	#include <iostream>
	#include <string.h>
	#include <cmath>
	#include <vector>
	#include <set>
	#include <algorithm>
	using namespace std;
	/*data type*/
	typedef pair<int,int> pii;
	typedef long long ll; typedef double dl;
	typedef vector<pii> vii;
	typedef set<pii> sii;
	/*sim_operarion*/
	#define sfint(x) scanf("%d",&x)
	#define sfint2(x,y) scanf("%d%d",&x,&y)
	#define sfint3(x,y,z) scanf("%d%d%d",&x,&y,&z)
	#define sfstr(c) scanf("%s",c)
	#define pfint(x) printf("%d\n",x)
	#define fr(i,s,n) for(i=s;i<n;++i)
	#define _fr(i,n,s) for(i=n-1;i>=s;--i)
	#define cl(a) memset(a,0,sizeof(a))
	/*bitmask*/
	template<class T> inline T _lowbit(const int &x){ return (x^(x-1))&x; }
	template<class T> inline int _bitsize(const T &x){ return (x==0)?0:(1+_bitsize(x&(x-1))); }
	/*CONST VALUE*/
	const dl _pi=acos(-1.0);
	const dl _eps=1e-6;

	int n,m;
	int main(){
fi;fo;
		int i;
		sfint2(n,m);
		if(n>m){
			fr(i,0,m){
				printf("BG");
			}
			fr(i,m,n){
				printf("B");
			}
		}
		else{
			fr(i,0,n){
				printf("GB");
			}
			fr(i,n,m){
				printf("G");
			}
		}
		return 0;
	}


	#include "stdafx.h"
	#define local
	#pragma warning(disable:4996)
	#define fi freopen("input.txt","r",stdin)
	#define fo freopen("output.txt","w",stdin)
	#include <stdio.h>
	#include <iostream>
	#include <string.h>
	#include <cmath>
	#include <vector>
	#include <set>
	#include <algorithm>
	using namespace std;
	/*data type*/
	typedef pair<int,int> pii;
	typedef long long ll; typedef double dl;
	typedef vector<pii> vii;
	typedef set<pii> sii;
	/*sim_operarion*/
	#define sfint(x) scanf("%d",&x)
	#define sfint2(x,y) scanf("%d%d",&x,&y)
	#define sfint3(x,y,z) scanf("%d%d%d",&x,&y,&z)
	#define sfstr(c) scanf("%s",c)
	#define pfint(x) printf("%d\n",x)
	#define fr(i,s,n) for(i=s;i<n;++i)
	#define _fr(i,n,s) for(i=n-1;i>=s;--i)
	#define cl(a) memset(a,0,sizeof(a))
	/*bitmask*/
	template<class T> inline T _lowbit(const int &x){ return (x^(x-1))&x; }
	template<class T> inline int _bitsize(const T &x){ return (x==0)?0:(1+_bitsize(x&(x-1))); }
	/*CONST VALUE*/
	const dl _pi=acos(-1.0);
	const dl _eps=1e-6;

	int n,m;
	int main(){
fi;fo;
		int i;
		sfint2(n,m);
		if(n>m){
			fr(i,0,m){
				printf("BG");
			}
			fr(i,m,n){
				printf("B");
			}
		}
		else{
			fr(i,0,n){
				printf("GB");
			}
			fr(i,n,m){
				printf("G");
			}
		}
		return 0;
	}


#define fi freopen("input.txt","r",stdin)
#define fo freopen("output.txt","w",stdout)
#include <stdio.h>
#include <iostream>
#include <string.h>
#include <cmath>
#include <vector>
#include <set>
#include <algorithm>
using namespace std;
/*data type*/
typedef pair<int,int> pii;
typedef long long ll; typedef double dl;
typedef vector<pii> vii;
typedef set<pii> sii;
/*sim_operarion*/
#define sfint(x) scanf("%d",&x)
#define sfint2(x,y) scanf("%d%d",&x,&y)
#define sfint3(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define sfstr(c) scanf("%s",c)
#define pfint(x) printf("%d\n",x)
#define fr(i,s,n) for(i=s;i<n;++i)
#define _fr(i,n,s) for(i=n-1;i>=s;--i)
#define cl(a) memset(a,0,sizeof(a))
/*bitmask*/
template<class T> inline T _lowbit(const int &x){ return (x^(x-1))&x; }
template<class T> inline int _bitsize(const T &x){ return (x==0)?0:(1+_bitsize(x&(x-1))); }
/*CONST VALUE*/
const dl _pi=acos(-1.0);
const dl _eps=1e-6;

int n,m;
int main(){
	fi;fo;
	int i;
	sfint2(n,m);
	if(n>m){
		fr(i,0,m){
			printf("BG");
		}
		fr(i,m,n){
			printf("B");
		}
	}
	else{
		fr(i,0,n){
			printf("GB");
		}
		fr(i,n,m){
			printf("G");
		}
	}
	return 0;
}


#define local

#define fi freopen("input.txt","r",stdin)
#define fo freopen("output.txt","w",stdout)
#include <stdio.h>
#include <iostream>
#include <string.h>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <string>
using namespace std;
/*my_template*/
/*data type*/
typedef pair<int,int> pii;
typedef long long ll; typedef double dl;
typedef vector<pii> vii;
typedef set<pii> sii;
/*sim_operarion*/
#define sfint(x) scanf("%d",&x)
#define sfint2(x,y) scanf("%d%d",&x,&y)
#define sfint3(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define sfstr(c) scanf("%s",c)
#define pfint(x) printf("%d\n",x)
#define fr(i,s,n) for(int i=s;i<n;++i)
#define _fr(i,n,s) for(int i=n-1;i>=s;--i)
#define cl(a) memset(a,0,sizeof(a))
/*bitmask*/
#define _ni(x) (1<<(x))
#define _niL(x) (1LL<<(x))
#define _has(s,x) ((s&(_ni(x)))!=0)
#define _hasL(s,x) ((s&(_niL(x)))!=0LL)
template<class T> inline T _lowbit(const int &x){ return (x^(x-1))&x; }
template<class T> inline int _bitsize(const T &x){ return (x==0)?0:(1+_bitsize(x&(x-1))); }
/*CONST VALUE*/
const dl _pi=acos(-1.0);
const dl _eps=1e-6;
/*my_template*/
int n,m;

int main(){
#ifdef local
	fi;fo;
#endif

	sfint2(n,m);
	if (n>m){
		fr(i , 0,m)
		printf("BG");
		fr(i,m,n ) printf("B");
	}
	else{
		fr(i ,0,n){
			printf("GB");
		}
		fr(i , n,m){
			printf("G");
		}
	}
	return 0;
}


#include <iostream>
#include <cmath>
#include <string>
#include <fstream>
#define cin fin
#define cout fout

using namespace std;

ifstream fin("input.txt");
ofstream fout("output.txt");

int main ()
{
	//cout << "sfgsdfgdsfgd" << endl;
	int a,b;
	cin >> a >> b;
	string c="B";
	if (b>a)
	{
		int p=a;
		a=b;
		b=p;
		c="G";
	}
	//cout << "asfgadsfgsdgdsfg" << endl;
	for (int i=0;i<b;i++)
		cout << "BG";
	for (int i=0;i<a-b;i++)
		cout << c;
	cout << endl;
	fout.close();
	//int pp;
	//cin >> pp;
}


#include <iostream>
#include <cmath>
#include <cstring>

using namespace std;

int main ()
{
	int a,b;
	cin >> a >> b;
	string c="B";
	if (b>a)
	{
		int p=a;
		a=b;
		b=p;
		c="G";
	}
	for (int i=0;i<b;i++)
		cout << "BG";
	for (int i=0;i<a-b;i++)
		cout << c;
	cout << endl;
	//int pp;
	//cin >> pp;
}


#include <iostream>
#include <cmath>
#include <string>

using namespace std;

ifstream fin("input.txt");
ofstream fout("output.txt");

int main ()
{
	//cout << "sfgsdfgdsfgd" << endl;
	int a,b;
	cin >> a >> b;
	string c="B";
	if (b>a)
	{
		int p=a;
		a=b;
		b=p;
		c="G";
	}
	//cout << "asfgadsfgsdgdsfg" << endl;
	for (int i=0;i<b;i++)
		cout << "BG";
	for (int i=0;i<a-b;i++)
		cout << c;
	cout << endl;
	fout.close();
	//int pp;
	//cin >> pp;
}


#include <iostream>
#include <cmath>
#include <string>
#define cin fin
#define cout fout

using namespace std;

ifstream fin("input.txt");
ofstream fout("output.txt");

int main ()
{
	//cout << "sfgsdfgdsfgd" << endl;
	int a,b;
	cin >> a >> b;
	string c="B";
	if (b>a)
	{
		int p=a;
		a=b;
		b=p;
		c="G";
	}
	//cout << "asfgadsfgsdgdsfg" << endl;
	for (int i=0;i<b;i++)
		cout << "BG";
	for (int i=0;i<a-b;i++)
		cout << c;
	cout << endl;
	fout.close();
	//int pp;
	//cin >> pp;
}


#include <iostream>
#include <cmath>
#include <string>

using namespace std;

int main ()
{
	cout << "sfgsdfgdsfgd" << endl;
	int a,b;
	cin >> a >> b;
	string c="B";
	if (b>a)
	{
		int p=a;
		a=b;
		b=p;
		c="G";
	}
	cout << "asfgadsfgsdgdsfg" << endl;
	for (int i=0;i<b;i++)
		cout << "BG";
	for (int i=0;i<a-b;i++)
		cout << c;
	cout << endl;
	int pp;
	//cin >> pp;
}


#include <iostream>
#include <cmath>
#include <cstring>

using namespace std;

int main ()
{
	int a,b;
	cin >> a >> b;
	string c="B";
	if (b>a)
	{
		int p=a;
		a=b;
		b=p;
		c="G";
	}
	cout << "asfgadsfgsdgdsfg" << endl;
	for (int i=0;i<b;i++)
		cout << "BG";
	for (int i=0;i<a-b;i++)
		cout << c;
	cout << endl;
	int pp;
	//cin >> pp;
}


#include <iostream>
#include <cmath>
#include <string>
#include <fstream>
#define cin fin
#define cout fout

using namespace std;

ifstream fin("input.txt");
ofstream fout("output.txt");

int main ()
{
	int a,b;
	cin >> a >> b;
	string c1="B",c2="G";
	if (b>a)
	{
		int p=a;
		a=b;
		b=p;
		c1="G";
		c2="B";
	}
	for (int i=0;i<b;i++)
		cout << c1 << c2;
	for (int i=0;i<a-b;i++)
		cout << c1;
	cout << endl;
	fout.close();
	int pp;
	cin >> pp;
}


#include <iostream>
#include <cmath>
#include <cstring>

using namespace std;

int main ()
{
	int a,b;
	cin >> a >> b;
	string c="B";
	if (b>a)
	{
		int p=a;
		a=b;
		b=p;
		c="G";
	}
	for (int i=0;i<b;i++)
		cout << "BG";
	for (int i=0;i<a-b;i++)
		cout << c;
	//cout << endl;
	//int pp;
	//cin >> pp;
}


#include <iostream>
#include <cmath>
#include <cstring>

using namespace std;

int main ()
{
	int a,b;
	cin >> a >> b;
	/*char c='B';
	if (b>a)
	{
		int p=a;
		a=b;
		b=p;
		c='G';
	}
	for (int i=0;i<b;i++)
		cout << "BG";
	for (int i=0;i<a-b;i++)
		cout << c;
	cout << endl;*/
	//int pp;
	//cin >> pp;
}


#include <iostream>
#include <cmath>
#include <cstring>

using namespace std;

int main ()
{
	int a,b;
	cout << "sfgsdfgdsfgd" << endl;
	cin >> a >> b;
	string c="B";
	if (b>a)
	{
		int p=a;
		a=b;
		b=p;
		c="G";
	}
	cout << "asfgadsfgsdgdsfg" << endl;
	for (int i=0;i<b;i++)
		cout << "BG";
	for (int i=0;i<a-b;i++)
		cout << c;
	cout << endl;
	int pp;
	//cin >> pp;
}


#include <iostream>
#include <cmath>
#include <string>
#include <fstream>
//#define cin fin
//#define cout fout

using namespace std;

//ifstream fin("input.txt");
//ofstream fout("output.txt");

int main ()
{
	int a,b;
	cin >> a >> b;
	string c1="B",c2="G";
	if (b>a)
	{
		int p=a;
		a=b;
		b=p;
		c1="G";
		c2="B";
	}
	for (int i=0;i<b;i++)
		cout << c1 << c2;
	for (int i=0;i<a-b;i++)
		cout << c1;
	cout << endl;
	//fout.close();
	int pp;
	cin >> pp;
}


#include <iostream>
#include <cmath>
#include <cstring>

using namespace std;

int main ()
{
	int a,b;
	cin >> a >> b;
	char c='B';
	if (b>a)
	{
		int p=a;
		a=b;
		b=p;
		c='G';
	}
	for (int i=0;i<b;i++)
		cout << "BG";
	for (int i=0;i<a-b;i++)
		cout << c;
	cout << endl;
	//int pp;
	//cin >> pp;
}


#include <iostream>
#include <cmath>
#include <string>

using namespace std;

int main ()
{
	int a,b;
	cout << "sfgsdfgdsfgd" << endl;
	cin >> a >> b;
	string c="B";
	if (b>a)
	{
		int p=a;
		a=b;
		b=p;
		c="G";
	}
	cout << "asfgadsfgsdgdsfg" << endl;
	for (int i=0;i<b;i++)
		cout << "BG";
	for (int i=0;i<a-b;i++)
		cout << c;
	cout << endl;
	int pp;
	//cin >> pp;
}


#include<cstdio>

int minz(int x, int y)
{
	return x < y ? x : y;
}

int main()
{
	int T, n, i, j;
	int m;
	printf("123");
	scanf("%d%d", &n, &m);
	printf("ADK");
	int t = minz(n, m);
	if(n > m)
	{
		printf("213");
		for(i = 0; i < t; i ++)
			printf("BG");
		for(i = 0; i < n-t; i ++)
			printf("B");
		printf("321");
		printf("\n");
	}
	else
	{
		printf("2");
		for(i = 0; i < t; i ++)
			printf("GB");
		for(i = 0; i < m-t; i ++)
			printf("G");
		printf("A");
		printf("\n");
	}
	return 0;
}


#include <iostream>
using namespace std;
int dfs;
int j[111],a[111],n,used=1,pcnt=0,ncnt=0;
char c[111];
int find(){

}

int main(void){
	char jtmp;
	cin>>jtmp;
	c[1]=1;
	while(1){
		used++;
		a[used]=1;
		cin>>c[used];
		if(c[used]=='-')j[used]=-1,ncnt++;
		else if(c[used]=='+') j[used]=1,pcnt++;
		else break;
		cin>>jtmp;
	}
	cin>>n;
	pcnt++;
	int max=pcnt*n-ncnt;
	int min=pcnt-ncnt*n;
	int d;
	pcnt--;
	//for(int i=1;i<=used;i++)
	//	cout<<" "<<c[i]<<" ";
	//cout<<ncnt<<" "<<pcnt<<endl;
	if(n>=min&&n<=max){
		cout<<"Possible"<<endl;
		d=pcnt-ncnt;
		a[1]=n-d;
		d=0;
		int tmp=1;
		while(a[tmp]>n){
			d=a[tmp]-n;
			a[tmp]=n;
			tmp++;
			while(c[tmp]=='-')tmp++;
			a[tmp]+=d;
		}
		if(a[1]<1){
			d=1-a[1];
			a[1]=1;
			tmp=2;
			while(c[tmp]=='-')tmp++;
			a[tmp]+=d;
			while(a[tmp]>n){
			d=a[tmp]-n;
			a[tmp]=n;
			tmp++;
			while(c[tmp]=='-')tmp++;
			a[tmp]+=d;
		}
		}

		cout<<a[1];
		for(int i=2;i<used;i++)
			cout<<" "<<c[i]<<" "<<a[i];
		cout<<" = "<<n<<endl;
	}
	else{
		cout<<"Impossible"<<endl;
	}
	return 0;
}


#include <iostream>
using namespace std;
int dfs;
int j[111],a[111],n,used=1,pcnt=0,ncnt=0;
char c[111];
int find(){

}

int main(void){
	char jtmp;
	cin>>jtmp;
	c[1]=1;
	while(1){
		used++;
		a[used]=1;
		cin>>c[used];
		if(c[used]=='-')j[used]=-1,ncnt++;
		else if(c[used]=='+') j[used]=1,pcnt++;
		else break;
		cin>>jtmp;
	}
	cin>>n;
	pcnt++;
	int max=pcnt*n-ncnt;
	int min=pcnt-ncnt*n;
	int d;
	pcnt--;
	//for(int i=1;i<=used;i++)
	//	cout<<" "<<c[i]<<" ";
	//cout<<ncnt<<" "<<pcnt<<endl;
	if(n>=min&&n<=max){
		cout<<"Possible"<<endl;
		d=pcnt-ncnt;
		a[1]=n-d;
		d=0;
		int tmp=1;
		while(a[tmp]>n){
			d=a[tmp]-n;
			a[tmp]=n;
			tmp++;
			while(c[tmp]=='-')tmp++;
			a[tmp]+=d;
		}
		if(a[1]<1){
			d=1-a[1];
			a[1]=1;
			tmp=2;
			while(c[tmp]=='+')tmp++;
			a[tmp]+=d;
			while(a[tmp]>n){
				d=a[tmp]-n;
				a[tmp]=n;
				tmp++;
				while(c[tmp]=='+')tmp++;
				a[tmp]+=d;
			}
		}

		cout<<a[1];
		for(int i=2;i<used;i++)
			cout<<" "<<c[i]<<" "<<a[i];
		cout<<" = "<<n<<endl;
	}
	else{
		cout<<"Impossible"<<endl;
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;

//#define PB push_back
#define PB emplace_back
#define F first
#define S second
#define MP make_pair
#define endl '\n'

const double PI = acos(-1);
const double eps = 1e-9;
const int inf = 2000000000;
const ll infLL = 9000000000000000000;
#define MOD 1000000007
//#define harmonic(n) 0.57721566490153286l+log(n)

#define mem(a,b) memset(a, b, sizeof(a) )
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a*(b/gcd(a,b)))
#define sqr(a) ((a) * (a))

#define optimize() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define fraction() cout.unsetf(ios::floatfield); cout.precision(10); cout.setf(ios::fixed,ios::floatfield);

typedef vector<int>::iterator vit;
typedef set<int>::iterator sit;

inline bool checkBit(ll n, int i) { return n&(1LL<<i); }
inline ll setBit(ll n, int i) { return n|(1LL<<i);; }
inline ll resetBit(ll n, int i) { return n&(~(1LL<<i)); }

int dx[] = {0, 0, +1, -1};
int dy[] = {+1, -1, 0, 0};
//int dx[] = {+1, 0, -1, 0, +1, +1, -1, -1};
//int dy[] = {0, +1, 0, -1, +1, -1, +1, -1};

inline bool EQ(double a, double b) { return fabs(a-b) < 1e-9; }
inline bool isLeapYear(ll year) { return (year%400==0) || (year%4==0 && year%100!=0); }
inline void normal(ll &a) { a %= MOD; (a < 0) && (a += MOD); }
inline ll modMul(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a*b)%MOD; }
inline ll modAdd(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a+b)%MOD; }
inline ll modSub(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); a -= b; normal(a); return a; }
inline ll modPow(ll b, ll p) { ll r = 1; while(p) { if(p&1) r = modMul(r, b); b = modMul(b, b); p >>= 1; } return r; }
inline ll modInverse(ll a) { return modPow(a, MOD-2); }
inline ll modDiv(ll a, ll b) { return modMul(a, modInverse(b)); }

/*
bool seive[1010000];
vi prime;

void seiveGen(int limit) {
    limit += 100;
    int sqrtn = sqrt(limit);
    for(int i = 3; i <= sqrtn; i += 2) {
            if(!seive[i>>1]) {
                    for(int j = i * i; j < limit; j += i + i) {
                            seive[j>>1] = 1;
                    }
            }
    }
    prime.PB(2);
    for(int i = 3; i < limit; i += 2) {
            if(!seive[i>>1]) prime.PB(i);
    }
}
*/

//
//debug
#ifdef mohaimin
template < typename F, typename S >
ostream& operator << ( ostream& os, const pair< F, S > & p ) {
            return os << "(" << p.first << ", " << p.second << ")";
}

template < typename T >
ostream &operator << ( ostream & os, const vector< T > &v ) {
            os << "{";
                for(auto it = v.begin(); it != v.end(); ++it) {
                                if( it != v.begin() ) os << ", ";
                                        os << *it;
                                            }
                    return os << "}";
}

template < typename T >
ostream &operator << ( ostream & os, const set< T > &v ) {
            os << "[";
                for(auto it = v.begin(); it != v.end(); ++it) {
                                if( it != v.begin() ) os << ", ";
                                        os << *it;
                                            }
                    return os << "]";
}

template < typename T >
ostream &operator << ( ostream & os, const multiset< T > &v ) {
            os << "[";
                for(auto it = v.begin(); it != v.end(); ++it) {
                                if( it != v.begin() ) os << ", ";
                                        os << *it;
                                            }
                    return os << "]";
}

template < typename F, typename S >
ostream &operator << ( ostream & os, const map< F, S > &v ) {
            os << "[";
                for(auto it = v.begin(); it != v.end(); ++it) {
                                if( it != v.begin() ) os << ", ";
                                        os << it -> first << " = " << it -> second ;
                                            }
                    return os << "]";
}

#define dbg(args...) do {cerr << #args << " : "; faltu(args); } while(0)

clock_t tStart = clock();
#define timeStamp dbg("Execution Time: ", (double)(clock() - tStart)/CLOCKS_PER_SEC)

void faltu () {
            cerr << endl;
}

template <typename T>
void faltu( T a[], int n ) {
            for(int i = 0; i < n; ++i) cerr << a[i] << ' ';
                cerr << endl;
}

template <typename T, typename ... hello>
void faltu( T arg, const hello &... rest) {
            cerr << arg << ' ';
                faltu(rest...);
}
#else
#define dbg(args...)
#endif // mohaimin

int main()
{
	string s;
	getline(cin, s);
	int l = s.length();
	int pos = 1, neg = 0, ques = 0, n = 0;
	for( int i = 0; i < l; ++i )
	{
		if( s[i] == '+' ) ++pos;
		else if( s[i] == '-' ) ++neg;
		else if( s[i] == '?' ) ++ques;
		else if( s[i] == '=' )
		{
			i += 2;
			while( i < l )
			{
				n *= 10;
				n += s[i] - '0';
				++i;
			}
		}
	}
	if( !(pos - n*neg <= n && n <= n*pos - neg) )
	{
		dbg(pos - n*neg, n*pos - neg, n);
		cout << "Impossible";
		return 0;
	}
	cout << "Possible" << endl;
	int sum = 0, sign;
	for( int i = 0; i < l; ++i )
	{
		if( s[i] == '=' )
		{
			cout << "= " << n;
			break;
		}
		if( i == 0 )
		{
			--pos;
			for( int j = 1; j <= n; ++j )
			{
				if( sum + j + pos - n*neg <= n && n <= sum + j + n*pos - neg )
				{
					sum += j;
					cout << j << " ";
					break;
				}
			}
		}
		else if( s[i] != '?' )
		{
			if( s[i] == '+' )
			{
				sign = 1;
				--pos;
				cout << "+" << " ";
			}
			else if( s[i] == '-' )
			{
				sign = -1;
				--neg;
				cout << "- ";
			}
		}
		else if( s[i] == '?' )
		{
			for( int j = 1; j <= n; ++j )
			{
				if( sum + sign*j + pos - n*neg <= n && n <= sum + sign*j + n*pos - neg )
				{
					sum += sign*j;
					cout << j << " ";
					break;
				}
			}
		}
	}
}