#include<bits/stdc++.h>
using namespace std;
int aa[2000600];
int haha[2000600];
int main()
{
    int n;
    scanf("%d",&n);
    int x,y;
    cout<<"YES"<<endl;
    for(int i=0;i<n;i++)
    {
        scanf("%d%d",&x,&y);
        scanf("%d%d",&x,&y);

        if(x%2==0)
        {
            if(y%2==0)
                cout<<4<<endl;
            else
                cout<<3<<endl;
        }
        else
        {
            if(y%2==0)
                cout<<2<<endl;
            else
                cout<<1<<endl;
        }
    }
}


#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>
using namespace std;
typedef long long ll;
int n,x,y;
int main(int argc, const char * argv[]) {
    cin>>n;
    puts("YES");
    for(int i=1;i<=n;i++){
        cin>>x>>y;
        cin>>x>>y;
        x+=1e9;y+=1e9;
        if(x&1){
            if(y&1) puts("1");
            else puts("2");
        }else{
            if(y&1) puts("3");
            else puts("4");
        }
    }
}


#include<bits/stdc++.h>
using namespace std;
int aa[2000600];
int haha[2000600];
int main()
{
    int n;
    scanf("%d",&n);
    int x,y;
    for(int i=0;i<n;i++)
    {
        scanf("%d%d",&x,&y);
        scanf("%d%d",&x,&y);
        if(x%2==0)
        {
            if(y%2==0)
                cout<<4<<endl;
            else
                cout<<3<<endl;
        }
        else
        {
            if(y%2==0)
                cout<<2<<endl;
            else
                cout<<1<<endl;
        }
    }
}


#include<bits/stdc++.h>
using namespace std;
int aa[2000600];
int haha[2000600];
int main()
{
    int n;
    scanf("%d",&n);
    int x,y;
    for(int i=0;i<n;i++)
    {
        scanf("%d%d",&x,&y);
        scanf("%d%d",&x,&y);
        cout<<"YES"<<endl;
        if(x%2==0)
        {
            if(y%2==0)
                cout<<4<<endl;
            else
                cout<<3<<endl;
        }
        else
        {
            if(y%2==0)
                cout<<2<<endl;
            else
                cout<<1<<endl;
        }
    }
}


#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);cout.tie(NULL);
	int n,a,b,c;
	cin>>n;
	cout<<"YES"<<endl;
	for(int i=0;i<n;i++)
	{
		cin>>a>>b>>c>>c;
		cout<<2*(a&1) + (b&1) + 1 <<endl;
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);cout.tie(NULL);
	int n,a,b,c;
	cin>>n;
	cout<<"YES"<<endl;
	for(int i=0;i<n;i++)
	{
		cin>>a>>b>>c>>c;
		cout<<(2*(a&1) + b&1) + 1 <<endl;
	}
	return 0;
}


//Nishant Arora
//I love KS.
#include<bits/stdc++.h>
using namespace std;
int main()
{
//freopen("input.txt","r",stdin);
std::ios::sync_with_stdio(false);
cin.tie(0);
long long n,a,b,c,d;
cout<<"YES\n";
while(n--)
{

	cin>>a>>b>>c>>d;
	cout<<(c%2)+1+2*(d%2);
}
}


//Nishant Arora
//I love KS.
#include<bits/stdc++.h>
using namespace std;
int main()
{
//freopen("input.txt","r",stdin);
std::ios::sync_with_stdio(false);
cin.tie(0);
long long n,a,b,c,d;
cout<<"YES\n";
cin>>n;
while(n--)
{

	cin>>a>>b>>c>>d;
	cout<<abs(c%2)+1+2*abs(d%2)<<"\n";
}
}


//Nishant Arora
//I love KS.
#include<bits/stdc++.h>
using namespace std;
int main()
{
//freopen("input.txt","r",stdin);
std::ios::sync_with_stdio(false);
cin.tie(0);
long long n,a,b,c,d;
cout<<"YES\n";

cin>>n;
while(n--)
{

	cin>>a>>b>>c>>d;
	cout<<(c%2)+1+2*(d%2)<<"\n";
}
}


#include <bits/stdc++.h>
using namespace std;
int main(int n,int x,int y){
	cout<<"YES\n";
	for(cin>>n;n--;cout<<2*(x&1)+(y&1)+1<<'\n') cin>>x>>y>>x>>y;
}


#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <climits>
#include <numeric>

using namespace std;

bool dfs(vector<vector<int>> &d, vector<int> &c, int v) {
        int k = 0;
        bool u[5] = { false, };
        for (auto x: d[v]) {
                if (c[x] > 0 && !u[c[x]]) {
                        u[c[x]] = true;
                        k++;
                }
                if (k == 4)
                        return false;
        }
        for (int i = 1; i <= 4; i++) {
                if (u[i])
                        continue;
                c[v] = i;
                for (auto x: d[v]) {
                        if (c[x])
                                continue;
                        if (!dfs(d, c, x)) {
                                c[v] = 0;
                                break;
                        }
                }
                if (c[v])
                        return true;
        }
        return false;
}

struct rect { int b, t, l, r; };

int main(int argc, char **argv)
{
        ios_base::sync_with_stdio(false);
        cin.tie(0);
        int n;
        cin >> n;
        vector<rect> r(n);
        vector<int> st(n), sb(n), sl(n), sr(n), c(n);
        vector<vector<int>> d(n);
        for (int i = 0; i < n; i++) {
                int x1, y1, x2, y2;
                cin >> x1 >> y1 >> x2 >> y2;
                r[i].b = min(y1, y2);
                r[i].t = max(y1, y2);
                r[i].l = min(x1, x2);
                r[i].r = max(x1, x2);
        }
        iota(sb.begin(), sb.end(), 0);
        sort(sb.begin(), sb.end(), [&](int a, int b) { return r[a].b < r[b].b; });
        iota(st.begin(), st.end(), 0);
        sort(st.begin(), st.end(), [&](int a, int b) { return r[a].t < r[b].t; });
        iota(sl.begin(), sl.end(), 0);
        sort(sl.begin(), sl.end(), [&](int a, int b) { return r[a].l < r[b].l; });
        iota(sr.begin(), sr.end(), 0);
        sort(sr.begin(), sr.end(), [&](int a, int b) { return r[a].r < r[b].r; });
        for (int p = 0, q = 0; p < n; p++) {
                rect &rp = r[sb[p]];
                while (q < n && r[st[q]].t < rp.b)
                        q++;
                int qq = q;
                while (q < n && r[st[q]].t == rp.b) {
                        rect &rq = r[st[q]];
                        if (rp.r > rq.l && rq.r > rp.l) {
                                d[sb[p]].push_back(st[q]);
                                d[st[q]].push_back(sb[p]);
                        }
                        q++;
                }
                if (p < n - 1 && rp.b == r[sb[p + 1]].b)
                        q = qq;
        }
        for (int p = 0, q = 0; p < n; p++) {
                rect &rp = r[sl[p]];
                while (q < n && r[sr[q]].r < rp.l)
                        q++;
                int qq = q;
                while (q < n && r[sr[q]].r == rp.l) {
                        rect &rq = r[sr[q]];
                        if (rp.t > rq.b && rq.t > rp.b) {
                                d[sl[p]].push_back(sr[q]);
                                d[sr[q]].push_back(sl[p]);
                        }
                        q++;
                }
                if (p < n - 1 && rp.l == r[sl[p + 1]].l)
                        q = qq;
        }
#if 0
        for (int i = 0; i < n; i++) {
                cout << i << ":";
                for (auto j: d[i])
                        cout << " " << j;
                cout << endl;
        }
#endif
        for (int i = 0; i < n; i++) {
                if (c[i])
                        continue;
                if (!dfs(d, c, i)) {
                        cout << "NO" << endl;
                        return 0;
                }
        }
        cout << "YES" << endl;
        for (auto x: c)
                cout << x << endl;
        return 0;
}


#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <climits>
#include <numeric>

using namespace std;

int main(int argc, char **argv)
{
        ios_base::sync_with_stdio(false);
        cin.tie(0);
        int n;
        cin >> n;
        cout << "YES" << endl;
        for (int i = 0; i < n; i++) {
                int x1, y1, x2, y2;
                cin >> x1 >> y1 >> x2 >> y2;
                int c = 0;
                if (x1 & 1)
                        c++;
                if (y1 & 1)
                        c++;
                cout << c + 1 << endl;
        }
        return 0;
}


#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <climits>
#include <numeric>

using namespace std;

bool dfs(vector<vector<int>> &d, vector<int> &c, int v) {
        int k = 0;
        bool u[5] = { false, };
        for (auto x: d[v]) {
                if (c[x] > 0 && !u[c[x]]) {
                        u[c[x]] = true;
                        k++;
                }
                if (k == 4)
                        return false;
        }
        for (int i = 1; i <= 4; i++) {
                if (!u[i]) {
                        c[v] = i;
                        break;
                }
        }
        for (auto x: d[v]) {
                if (!c[x]) {
                        if (!dfs(d, c, x)) {
                                c[v] = 0;
                                return false;
                        }
                }
        }
        return true;
}

struct rect { int b, t, l, r; };

int main(int argc, char **argv)
{
        ios_base::sync_with_stdio(false);
        cin.tie(0);
        int n;
        cin >> n;
        vector<rect> r(n);
        vector<int> st(n), sb(n), sl(n), sr(n), c(n);
        vector<vector<int>> d(n);
        for (int i = 0; i < n; i++) {
                int x1, y1, x2, y2;
                cin >> x1 >> y1 >> x2 >> y2;
                r[i].b = min(y1, y2);
                r[i].t = max(y1, y2);
                r[i].l = min(x1, x2);
                r[i].r = max(x1, x2);
        }
        iota(sb.begin(), sb.end(), 0);
        sort(sb.begin(), sb.end(), [&](int a, int b) { return r[a].b < r[b].b; });
        iota(st.begin(), st.end(), 0);
        sort(st.begin(), st.end(), [&](int a, int b) { return r[a].t < r[b].t; });
        iota(sl.begin(), sl.end(), 0);
        sort(sl.begin(), sl.end(), [&](int a, int b) { return r[a].l < r[b].l; });
        iota(sr.begin(), sr.end(), 0);
        sort(sr.begin(), sr.end(), [&](int a, int b) { return r[a].r < r[b].r; });
        for (int p = 0, q = 0; p < n; p++) {
                rect &rp = r[sb[p]];
                while (q < n && r[st[q]].t < rp.b)
                        q++;
                int qq = q;
                while (q < n && r[st[q]].t == rp.b) {
                        rect &rq = r[st[q]];
                        if (rp.r > rq.l && rq.r > rp.l) {
                                d[sb[p]].push_back(st[q]);
                                d[st[q]].push_back(sb[p]);
                        }
                        q++;
                }
                if (p < n - 1 && rp.b == r[sb[p + 1]].b)
                        q = qq;
        }
        for (int p = 0, q = 0; p < n; p++) {
                rect &rp = r[sl[p]];
                while (q < n && r[sr[q]].r < rp.l)
                        q++;
                int qq = q;
                while (q < n && r[sr[q]].r == rp.l) {
                        rect &rq = r[sr[q]];
                        if (rp.t > rq.b && rq.t > rp.b) {
                                d[sl[p]].push_back(sr[q]);
                                d[sr[q]].push_back(sl[p]);
                        }
                        q++;
                }
                if (p < n - 1 && rp.l == r[sl[p + 1]].l)
                        q = qq;
        }
#if 0
        for (int i = 0; i < n; i++) {
                cout << i << ":";
                for (auto j: d[i])
                        cout << " " << j;
                cout << endl;
        }
#endif
        for (int i = 0; i < n; i++) {
                if (c[i])
                        continue;
                if (!dfs(d, c, i)) {
                        cout << "NO" << endl;
                        return 0;
                }
        }
        cout << "YES" << endl;
        for (auto x: c)
                cout << x << endl;
        return 0;
}


#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <climits>
#include <numeric>

using namespace std;

bool dfs(vector<vector<int>> &d, vector<int> &c, int v) {
        int k = 0;
        bool u[5] = { false, };
        for (auto x: d[v]) {
                if (c[x] > 0 && !u[c[x]]) {
                        u[c[x]] = true;
                        k++;
                }
                if (k == 4)
                        return false;
        }
        for (int i = 1; i <= 4; i++) {
                if (!u[i]) {
                        c[v] = i;
                        break;
                }
        }
        for (auto x: d[v]) {
                if (!c[x]) {
                        if (!dfs(d, c, x)) {
                                c[v] = 0;
                                return false;
                        }
                }
        }
        return true;
}

struct rect { int b, t, l, r; };

int main(int argc, char **argv)
{
        ios_base::sync_with_stdio(false);
        cin.tie(0);
        int n;
        cin >> n;
        vector<rect> r(n);
        vector<int> st(n), sb(n), sl(n), sr(n), c(n);
        vector<vector<int>> d(n);
        for (int i = 0; i < n; i++) {
                int x1, y1, x2, y2;
                cin >> x1 >> y1 >> x2 >> y2;
                r[i].b = min(y1, y2);
                r[i].t = max(y1, y2);
                r[i].l = min(x1, x2);
                r[i].r = max(x1, x2);
        }
        iota(sb.begin(), sb.end(), 0);
        sort(sb.begin(), sb.end(), [&](int a, int b) { return r[a].b < r[b].b; });
        iota(st.begin(), st.end(), 0);
        sort(st.begin(), st.end(), [&](int a, int b) { return r[a].t < r[b].t; });
        iota(sl.begin(), sl.end(), 0);
        sort(sl.begin(), sl.end(), [&](int a, int b) { return r[a].l < r[b].l; });
        iota(sr.begin(), sr.end(), 0);
        sort(sr.begin(), sr.end(), [&](int a, int b) { return r[a].r < r[b].r; });
        for (int p = 0, q = 0; p < n; p++) {
                rect &rp = r[sb[p]];
                while (q < n && r[st[q]].t < rp.b)
                        q++;
                int qq = q;
                while (q < n && r[st[q]].t == rp.b) {
                        rect &rq = r[st[q]];
                        if (rp.r > rq.l && rq.r > rp.l) {
                                d[sb[p]].push_back(st[q]);
                                d[st[q]].push_back(sb[p]);
                        }
                        q++;
                }
                q = qq;
        }
        for (int p = 0, q = 0; p < n; p++) {
                rect &rp = r[sr[p]];
                while (q < n && r[sl[q]].l < rp.r)
                        q++;
                int qq = q;
                while (q < n && r[sl[q]].l == rp.r) {
                        rect &rq = r[sl[q]];
                        if (rp.t > rq.b && rq.t > rp.b) {
                                d[sr[p]].push_back(sl[q]);
                                d[sl[q]].push_back(sr[p]);
                        }
                        q++;
                }
                q = qq;
        }
#if 0
        for (int i = 0; i < n; i++) {
                cout << i << ":";
                for (auto j: d[i])
                        cout << " " << j;
                cout << endl;
        }
#endif
        for (int i = 0; i < n; i++) {
                if (c[i])
                        continue;
                if (!dfs(d, c, i)) {
                        cout << "NO" << endl;
                        return 0;
                }
        }
        cout << "YES" << endl;
        for (auto x: c)
                cout << x << endl;
        return 0;
}


#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <climits>
#include <numeric>

using namespace std;

int main(int argc, char **argv)
{
        ios_base::sync_with_stdio(false);
        cin.tie(0);
        int n;
        cin >> n;
        cout << "YES" << endl;
        for (int i = 0; i < n; i++) {
                int x1, y1, x2, y2;
                cin >> x1 >> y1 >> x2 >> y2;
                int c = 0;
                if (x1 & 1)
                        c += 1;
                if (y1 & 1)
                        c += 2;
                cout << c + 1 << endl;
        }
        return 0;
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <double, double> pdd;

const double eps=1E-9;
const double Exp=2.718281828459045;
const double pi=3.14159;
const double E = 2.7182818284590452354;

#define f first
#define s second
#define linf 2000000000000000000LL
#define FILL(a,b) memset(a, b, sizeof(a))
#define pb push_back
#define mp make_pair
#define sc(mas) scanf("%d",&mas)
#define scll(mas) scanf("%lld",&mas)
#define sc2(f1,f2) scanf("%d%d",&f1,&f2)
#define sc3(f1,f2,f3) scanf("%d%d%d",&f1,&f2,&f3)
#define fore(op,po) for (int op=0;op<po;++op)
#define fori(p) for (int i=0;i<p;++i)
#define forj(p) for (int j=0;j<p;++j)
#define rep(a,b) for (int i=a;i<=b;++i)
#define srep(i,n) for (int i=1;i<=n;++i)
#define bit(mask,i) ((mask>>i)&1)
#define pri(ff) printf("%d\n",ff)
#define pr2(f1,f2) printf("%d %d\n",f1,f2)
#define prll(fl) printf("%lld\n",fl)
#define prid(f1) printf("%.15lf\n",f1);
#define prn printf("NO\n")
#define pry printf("YES\n")

const int Max_Bit=63;
const int INF=2000000000;
const ll LINF=1000000000000000007ll;
const int MOD=1000000007;
const int NMAX=100005;
const int MMAX=105;
const int base=1000*1000*1000;

int main() {
	int n;
	cin >> n;
	cout << "YES" << endl;
	for(int i=0;i<n;i++) {
		int x1, y1, x2, y2;
		cin >> x1 >> y1 >> x2 >> y2;
		x1 = abs(x1), x2 = abs(x2);
		if(x1&1 && y1&1) cout << 1 << endl;
		if(x1&1 && !y1&1) cout << 2 << endl;
		if(!x1&1 && y1&1) cout << 3 << endl;
		if(!x1&1 && !y1&1) cout << 4 << endl;
	}
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <double, double> pdd;

const double eps=1E-9;
const double Exp=2.718281828459045;
const double pi=3.14159;
const double E = 2.7182818284590452354;

#define f first
#define s second
#define linf 2000000000000000000LL
#define FILL(a,b) memset(a, b, sizeof(a))
#define pb push_back
#define mp make_pair
#define sc(mas) scanf("%d",&mas)
#define scll(mas) scanf("%lld",&mas)
#define sc2(f1,f2) scanf("%d%d",&f1,&f2)
#define sc3(f1,f2,f3) scanf("%d%d%d",&f1,&f2,&f3)
#define fore(op,po) for (int op=0;op<po;++op)
#define fori(p) for (int i=0;i<p;++i)
#define forj(p) for (int j=0;j<p;++j)
#define rep(a,b) for (int i=a;i<=b;++i)
#define srep(i,n) for (int i=1;i<=n;++i)
#define bit(mask,i) ((mask>>i)&1)
#define pri(ff) printf("%d\n",ff)
#define pr2(f1,f2) printf("%d %d\n",f1,f2)
#define prll(fl) printf("%lld\n",fl)
#define prid(f1) printf("%.15lf\n",f1);
#define prn printf("NO\n")
#define pry printf("YES\n")

const int Max_Bit=63;
const int INF=2000000000;
const ll LINF=1000000000000000007ll;
const int MOD=1000000007;
const int NMAX=100005;
const int MMAX=105;
const int base=1000*1000*1000;

int main() {
	int n;
	scanf("%d", &n);
	pry;
	for(int i=0;i<n;i++) {
		int x1, y1, x2, y2;
		scanf("%d%d%d%d", &x1, &y1, &x2, &y2);
		x1 = abs(x1), y1 = abs(y1);
		if((x1&1) && (y1&1)) puts("1");
		if((x1&1) && !(y1&1)) puts("2");
		if(!(x1&1) && (y1&1)) puts("3");
		if(!(x1&1) && !(y1&1)) puts("4");
	}
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <double, double> pdd;

const double eps=1E-9;
const double Exp=2.718281828459045;
const double pi=3.14159;
const double E = 2.7182818284590452354;

#define f first
#define s second
#define linf 2000000000000000000LL
#define FILL(a,b) memset(a, b, sizeof(a))
#define pb push_back
#define mp make_pair
#define sc(mas) scanf("%d",&mas)
#define scll(mas) scanf("%lld",&mas)
#define sc2(f1,f2) scanf("%d%d",&f1,&f2)
#define sc3(f1,f2,f3) scanf("%d%d%d",&f1,&f2,&f3)
#define fore(op,po) for (int op=0;op<po;++op)
#define fori(p) for (int i=0;i<p;++i)
#define forj(p) for (int j=0;j<p;++j)
#define rep(a,b) for (int i=a;i<=b;++i)
#define srep(i,n) for (int i=1;i<=n;++i)
#define bit(mask,i) ((mask>>i)&1)
#define pri(ff) printf("%d\n",ff)
#define pr2(f1,f2) printf("%d %d\n",f1,f2)
#define prll(fl) printf("%lld\n",fl)
#define prid(f1) printf("%.15lf\n",f1);
#define prn printf("NO\n")
#define pry printf("YES\n")

const int Max_Bit=63;
const int INF=2000000000;
const ll LINF=1000000000000000007ll;
const int MOD=1000000007;
const int NMAX=100005;
const int MMAX=105;
const int base=1000*1000*1000;

int main() {
	int n;
	scanf("%d", &n)
	pry;
	for(int i=0;i<n;i++) {
		int x1, y1, x2, y2;
		scanf("%d%d%d%d", &x1, &y1, &x2, &y2);
		x1 = abs(x1), y1 = abs(y1);
		if((x1&1) && (y1&1)) puts(1);
		if((x1&1) && !(y1&1)) puts(2);
		if(!(x1&1) && (y1&1)) puts(3);
		if(!(x1&1) && !(y1&1)) puts(4);
	}
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <double, double> pdd;

const double eps=1E-9;
const double Exp=2.718281828459045;
const double pi=3.14159;
const double E = 2.7182818284590452354;

#define f first
#define s second
#define linf 2000000000000000000LL
#define FILL(a,b) memset(a, b, sizeof(a))
#define pb push_back
#define mp make_pair
#define sc(mas) scanf("%d",&mas)
#define scll(mas) scanf("%lld",&mas)
#define sc2(f1,f2) scanf("%d%d",&f1,&f2)
#define sc3(f1,f2,f3) scanf("%d%d%d",&f1,&f2,&f3)
#define fore(op,po) for (int op=0;op<po;++op)
#define fori(p) for (int i=0;i<p;++i)
#define forj(p) for (int j=0;j<p;++j)
#define rep(a,b) for (int i=a;i<=b;++i)
#define srep(i,n) for (int i=1;i<=n;++i)
#define bit(mask,i) ((mask>>i)&1)
#define pri(ff) printf("%d\n",ff)
#define pr2(f1,f2) printf("%d %d\n",f1,f2)
#define prll(fl) printf("%lld\n",fl)
#define prid(f1) printf("%.15lf\n",f1);
#define prn printf("NO\n")
#define pry printf("YES\n")

const int Max_Bit=63;
const int INF=2000000000;
const ll LINF=1000000000000000007ll;
const int MOD=1000000007;
const int NMAX=100005;
const int MMAX=105;
const int base=1000*1000*1000;

int main() {
	ios::sync_with_stdio(false);
	cin.tie();
	int n;
	cin >> n;
	cout << "YES" << endl;
	for(int i=0;i<n;i++) {
		int x1, y1, x2, y2;
		cin >> x1 >> y1 >> x2 >> y2;
		x1 = abs(x1), y1 = abs(y1);
		if((x1&1) && (y1&1)) cout << 1 << endl;
		if((x1&1) && !(y1&1)) cout << 2 << endl;
		if(!(x1&1) && (y1&1)) cout << 3 << endl;
		if(!(x1&1) && !(y1&1)) cout << 4 << endl;
	}
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <double, double> pdd;

const double eps=1E-9;
const double Exp=2.718281828459045;
const double pi=3.14159;
const double E = 2.7182818284590452354;

#define f first
#define s second
#define linf 2000000000000000000LL
#define FILL(a,b) memset(a, b, sizeof(a))
#define pb push_back
#define mp make_pair
#define sc(mas) scanf("%d",&mas)
#define scll(mas) scanf("%lld",&mas)
#define sc2(f1,f2) scanf("%d%d",&f1,&f2)
#define sc3(f1,f2,f3) scanf("%d%d%d",&f1,&f2,&f3)
#define fore(op,po) for (int op=0;op<po;++op)
#define fori(p) for (int i=0;i<p;++i)
#define forj(p) for (int j=0;j<p;++j)
#define rep(a,b) for (int i=a;i<=b;++i)
#define srep(i,n) for (int i=1;i<=n;++i)
#define bit(mask,i) ((mask>>i)&1)
#define pri(ff) printf("%d\n",ff)
#define pr2(f1,f2) printf("%d %d\n",f1,f2)
#define prll(fl) printf("%lld\n",fl)
#define prid(f1) printf("%.15lf\n",f1);
#define prn printf("NO\n")
#define pry printf("YES\n")

const int Max_Bit=63;
const int INF=2000000000;
const ll LINF=1000000000000000007ll;
const int MOD=1000000007;
const int NMAX=100005;
const int MMAX=105;
const int base=1000*1000*1000;

int main() {
	int n;
	cin >> n;
	cout << "YES" << endl;
	for(int i=0;i<n;i++) {
		int x1, y1, x2, y2;
		cin >> x1 >> y1 >> x2 >> y2;
		x1 = abs(x1), y1 = abs(y1);
		if(x1&1 && y1&1) cout << 1 << endl;
		if(x1&1 && !y1&1) cout << 2 << endl;
		if(!x1&1 && y1&1) cout << 3 << endl;
		if(!x1&1 && !y1&1) cout << 4 << endl;
	}
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <double, double> pdd;

const double eps=1E-9;
const double Exp=2.718281828459045;
const double pi=3.14159;
const double E = 2.7182818284590452354;

#define f first
#define s second
#define linf 2000000000000000000LL
#define FILL(a,b) memset(a, b, sizeof(a))
#define pb push_back
#define mp make_pair
#define sc(mas) scanf("%d",&mas)
#define scll(mas) scanf("%lld",&mas)
#define sc2(f1,f2) scanf("%d%d",&f1,&f2)
#define sc3(f1,f2,f3) scanf("%d%d%d",&f1,&f2,&f3)
#define fore(op,po) for (int op=0;op<po;++op)
#define fori(p) for (int i=0;i<p;++i)
#define forj(p) for (int j=0;j<p;++j)
#define rep(a,b) for (int i=a;i<=b;++i)
#define srep(i,n) for (int i=1;i<=n;++i)
#define bit(mask,i) ((mask>>i)&1)
#define pri(ff) printf("%d\n",ff)
#define pr2(f1,f2) printf("%d %d\n",f1,f2)
#define prll(fl) printf("%lld\n",fl)
#define prid(f1) printf("%.15lf\n",f1);
#define prn printf("NO\n")
#define pry printf("YES\n")

const int Max_Bit=63;
const int INF=2000000000;
const ll LINF=1000000000000000007ll;
const int MOD=1000000007;
const int NMAX=100005;
const int MMAX=105;
const int base=1000*1000*1000;

int main() {
	int n;
	cin >> n;
	cout << "YES" << endl;
	for(int i=0;i<n;i++) {
		int x1, y1, x2, y2;
		cin >> x1 >> y1 >> x2 >> y2;
		x1 = abs(x1), y1 = abs(y1);
		if((x1&1) && (y1&1)) cout << 1 << endl;
		if((x1&1) && !(y1&1)) cout << 2 << endl;
		if(!(x1&1) && (y1&1)) cout << 3 << endl;
		if(!(x1&1) && !(y1&1)) cout << 4 << endl;
	}
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <double, double> pdd;

const double eps=1E-9;
const double Exp=2.718281828459045;
const double pi=3.14159;
const double E = 2.7182818284590452354;

#define f first
#define s second
#define linf 2000000000000000000LL
#define FILL(a,b) memset(a, b, sizeof(a))
#define pb push_back
#define mp make_pair
#define sc(mas) scanf("%d",&mas)
#define scll(mas) scanf("%lld",&mas)
#define sc2(f1,f2) scanf("%d%d",&f1,&f2)
#define sc3(f1,f2,f3) scanf("%d%d%d",&f1,&f2,&f3)
#define fore(op,po) for (int op=0;op<po;++op)
#define fori(p) for (int i=0;i<p;++i)
#define forj(p) for (int j=0;j<p;++j)
#define rep(a,b) for (int i=a;i<=b;++i)
#define srep(i,n) for (int i=1;i<=n;++i)
#define bit(mask,i) ((mask>>i)&1)
#define pri(ff) printf("%d\n",ff)
#define pr2(f1,f2) printf("%d %d\n",f1,f2)
#define prll(fl) printf("%lld\n",fl)
#define prid(f1) printf("%.15lf\n",f1);
#define prn printf("NO\n")
#define pry printf("YES\n")

const int Max_Bit=63;
const int INF=2000000000;
const ll LINF=1000000000000000007ll;
const int MOD=1000000007;
const int NMAX=100005;
const int MMAX=105;
const int base=1000*1000*1000;

int main() {
	int n;
	scanf("%d", &n);
	pry;
	for(int i=0;i<n;i++) {
		int x1, y1, x2, y2;
		scanf("%d%d%d%d", &x1, &y1, &x2, &y2);
		x1 = abs(x1), y1 = abs(y1);
		if((x1&1) && (y1&1)) puts(1);
		if((x1&1) && !(y1&1)) puts(2);
		if(!(x1&1) && (y1&1)) puts(3);
		if(!(x1&1) && !(y1&1)) puts(4);
	}
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define int long long
using ll=long long;
using vi=vector<int>;
using vl=vector<long long>;
using pii=pair<int,int>;
using pll=pair<long long,long long>;
#define ITR(i,c) for(auto i=begin(c);i!=end(c);++i)
#define FORE(x,c) for(auto &x:c)
#define FOR(i,a,n) for(int i=a,i##_len=(int)n;i<i##_len;++i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) for(int i=((int)(n)-1);i>=0;--i)
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)   // c++14
#define SZ(c) ((int)c.size())
#define dump(...)
const int DX[9]={0,1,0,-1,1,1,-1,-1,0}, DY[9]={-1,0,1,0,-1,1,1,-1,0};
const int INF=1001001001; const long long INFLL=1001001001001001001ll;
template<class T> ostream& operator << (ostream &os, const vector<T> &v) {
    ITR(i,v) os << *i << (i==end(v)-1 ? "" : " "); return os; }
template<class T> istream& operator >> (istream &is, vector<T> &v) {
    ITR(i,v) is >> * i; return is; }
template<class T> istream& operator >> (istream &is, pair<T,T> &p) {
        is >> p.first >> p.second; return is; }
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}
//------------------------------------------------------------------------------
struct before_main_function {
    before_main_function() {
    #ifdef int
        cerr<<"\x1b[7m"<<"'int' is defined as 'long long' !!!!"<<"\x1b[m"<<endl;
    #endif
        cin.tie(0);ios::sync_with_stdio(false);
        cout<<setprecision(12)<<fixed;
    }
} before_main_function;
//------------------------------------------------------------------------------

signed main() {
    int n; cin>>n;
    cout<<"YES"<<endl;
    REP(i,n) {
        int x1,y1,x2,y2;
        cin>>x1>>y1>>x2>>y2;
        int ans=0;
        if(x1%2==0 && y1%2==0) ans=1;
        if(x1%2==0 && y1%2==1) ans=2;
        if(x1%2==1 && y1%2==0) ans=3;
        if(x1%2==1 && y1%2==1) ans=4;
        cout<<ans<<endl;
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define int long long
using ll=long long;
using vi=vector<int>;
using vl=vector<long long>;
using pii=pair<int,int>;
using pll=pair<long long,long long>;
#define ITR(i,c) for(auto i=begin(c);i!=end(c);++i)
#define FORE(x,c) for(auto &x:c)
#define FOR(i,a,n) for(int i=a,i##_len=(int)n;i<i##_len;++i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) for(int i=((int)(n)-1);i>=0;--i)
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)   // c++14
#define SZ(c) ((int)c.size())
#define dump(...)
const int DX[9]={0,1,0,-1,1,1,-1,-1,0}, DY[9]={-1,0,1,0,-1,1,1,-1,0};
const int INF=1001001001; const long long INFLL=1001001001001001001ll;
template<class T> ostream& operator << (ostream &os, const vector<T> &v) {
    ITR(i,v) os << *i << (i==end(v)-1 ? "" : " "); return os; }
template<class T> istream& operator >> (istream &is, vector<T> &v) {
    ITR(i,v) is >> * i; return is; }
template<class T> istream& operator >> (istream &is, pair<T,T> &p) {
        is >> p.first >> p.second; return is; }
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}
//------------------------------------------------------------------------------
struct before_main_function {
    before_main_function() {
    #ifdef int
        cerr<<"\x1b[7m"<<"'int' is defined as 'long long' !!!!"<<"\x1b[m"<<endl;
    #endif
        cin.tie(0);ios::sync_with_stdio(false);
        cout<<setprecision(12)<<fixed;
    }
} before_main_function;
//------------------------------------------------------------------------------

signed main() {
    int n; cin>>n;
    cout<<"YES"<<endl;
    REP(i,n) {
        int x1,y1,x2,y2;
        cin>>x1>>y1>>x2>>>y2;
        int ans=0;
        if(x1%2==0 && y1%2==0) ans=1;
        if(x1%2==0 && y1%2==1) ans=2;
        if(x1%2==1 && y1%2==0) ans=3;
        if(x1%2==1 && y1%2==1) ans=4;
        cout<<ans<<endl;
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define int long long
using ll=long long;
using vi=vector<int>;
using vl=vector<long long>;
using pii=pair<int,int>;
using pll=pair<long long,long long>;
#define ITR(i,c) for(auto i=begin(c);i!=end(c);++i)
#define FORE(x,c) for(auto &x:c)
#define FOR(i,a,n) for(int i=a,i##_len=(int)n;i<i##_len;++i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) for(int i=((int)(n)-1);i>=0;--i)
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)   // c++14
#define SZ(c) ((int)c.size())
#define dump(...)
const int DX[9]={0,1,0,-1,1,1,-1,-1,0}, DY[9]={-1,0,1,0,-1,1,1,-1,0};
const int INF=1001001001; const long long INFLL=1001001001001001001ll;
template<class T> ostream& operator << (ostream &os, const vector<T> &v) {
    ITR(i,v) os << *i << (i==end(v)-1 ? "" : " "); return os; }
template<class T> istream& operator >> (istream &is, vector<T> &v) {
    ITR(i,v) is >> * i; return is; }
template<class T> istream& operator >> (istream &is, pair<T,T> &p) {
        is >> p.first >> p.second; return is; }
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}
//------------------------------------------------------------------------------
struct before_main_function {
    before_main_function() {
    #ifdef int
        cerr<<"\x1b[7m"<<"'int' is defined as 'long long' !!!!"<<"\x1b[m"<<endl;
    #endif
        cin.tie(0);ios::sync_with_stdio(false);
        cout<<setprecision(12)<<fixed;
    }
} before_main_function;
//------------------------------------------------------------------------------

signed main() {
    int n; cin>>n;
    cout<<"YES"<<endl;
    REP(i,n) {
        int x1,y1,x2,y2;
        cin>>x1>>y1>>x2>>y2;
        x1+=1e9;  y1+=1e9;
        int ans=0;
        if(x1%2==0 && y1%2==0) ans=1;
        if(x1%2==0 && y1%2==1) ans=2;
        if(x1%2==1 && y1%2==0) ans=3;
        if(x1%2==1 && y1%2==1) ans=4;
        cout<<ans<<endl;
    }
    return 0;
}


//Codeforces Round #395 Div2D/Div1B solution
#include <bits/stdc++.h>
using namespace std;
template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }
#define forn(i, n) for (int i = 0; i < (int)(n); i++)
#define forab(i, a, b) for (int i = (int)(a); i < (int)(b); ++i)
#define _ cin.tie(0); ios_base::sync_with_stdio(0);
#define i64 long long

int main() {
    int n;
    printf("YES\n");
    scanf("%d", &n);
    for(int i = 0; i < n; i++) {
        int x1, y1, x2, y2;
        scanf("%d %d %d %d", &x1, &y1, &x2, &y2);
        printf("%d\n", ((12 + 2 * (x1 % 2) + (y1 % 2)) % 4) + 1);
    }
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

int main(){
    cout << "YES";
    int n; cin >> n;
    for(int i = 0; i < n; i++) {
        int x1, y1, x2, y2;
        cin >> x1 >> y1 >> x2 >> y2;
        cout << ((12 + 2 * (x1 % 2) + (y1 % 2)) % 4) + 1;
    }

}


#include <bits/stdc++.h>

using namespace std;

int main()
{
    #ifdef FILEIO
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
    ios_base::sync_with_stdio(false);

    int n;
    cin >> n;

    for(int x1, x2, y1, y2, i=0; i<n; i++)
    {
        cin >> x1 >> y1 >> x2 >> y2;
        int x = min(abs(x1), abs(x2));
        int y = min(abs(y1), abs(y2));
        cout << 1 + x%2 + 2*(y%2) << endl;
    }

    return 0;
}


#include <bits/stdc++.h>

using namespace std;

int main()
{
    #ifdef FILEIO
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
    ios_base::sync_with_stdio(false);

    int n;
    cin >> n;

    cout << "YES" << endl;
    for(int x1, x2, y1, y2, i=0; i<n; i++)
    {
        cin >> x1 >> y1 >> x2 >> y2;
        int x = min(abs(x1), abs(x2));
        int y = min(abs(y1), abs(y2));
        cout << 1 + x%2 + 2*(y%2) << endl;
    }

    return 0;
}


#include <bits/stdc++.h>

using namespace std;

int main()
{
    #ifdef FILEIO
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
    ios_base::sync_with_stdio(false);

    int n;
    cin >> n;

    cout << "YES" << endl;
    for(int x1, x2, y1, y2, i=0; i<n; i++)
    {
        cin >> x1 >> y1 >> x2 >> y2;
        int x = min(x1, x2);
        int y = min(y1, y2);
        cout << 1 + abs(x)%2 + 2*(abs(y)%2) << endl;
    }

    return 0;
}


#include <bits/stdc++.h>

using namespace std;

int main()
{
    #ifdef FILEIO
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
    ios_base::sync_with_stdio(false);

    int n;
    cin >> n;

    for(int x1, x2, y1, y2, i=0; i<n; i++)
    {
        cin >> x1 >> y1 >> x2 >> y2;
        int x = min(x1, x2);
        int y = min(y1, y2);
        cout << 1 + x%2 + 2*(y%2) << endl;
    }

    return 0;
}


#include <iostream>
#include <fstream>
#include <map>
#include <cmath>
#include <math.h>
#include <set>
#include <vector>
#include <sstream>
#include <string>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <queue>
#include <cstdlib>
#include <iomanip>
#include <unordered_map>
#include <unordered_set>
#include <string>
#include <time.h>
#include <ctime>

typedef long long int lli;
typedef long double ld;
const lli INF = 1e9 + 999, MOD = 1e9+7, MAXN = 200000; //18
const ld EPS = 0.00000001;
#define forn(a, b) for (lli i = a; i < b; i++)
#define fore(p, a, b) for (lli p = a; p < b; p++)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb(a) push_back(a)
#define sz(a) (int)a.size()
#define mp(a, b) make_pair(a, b)
#define f1 first
#define s2 second
#define cotu cout
#define itn lli
#define pii pair<int,int>

using namespace std;

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int n;
    cin >> n;
    vector<pii>ss;
    cout << "YES\n";
    for (int i = 0; i < n; i++){
        int x1, y1, x2, y2;
        cin >> x1 >> y1 >> x2 >> y2;
        x1 += 1e9;
        y1 += 1e9;
        cout << (x1 % 2) * 2 + (y1 % 2) + 1 << " ";
    }
    return 0;
}


#include <iostream>
#include <fstream>
#include <map>
#include <cmath>
#include <math.h>
#include <set>
#include <vector>
#include <sstream>
#include <string>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <queue>
#include <cstdlib>
#include <iomanip>
#include <unordered_map>
#include <unordered_set>
#include <string>
#include <time.h>
#include <ctime>

typedef long long int lli;
typedef long double ld;
const lli INF = 1e9 + 999, MOD = 1e9+7, MAXN = 200000; //18
const ld EPS = 0.00000001;
#define forn(a, b) for (lli i = a; i < b; i++)
#define fore(p, a, b) for (lli p = a; p < b; p++)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb(a) push_back(a)
#define sz(a) (int)a.size()
#define mp(a, b) make_pair(a, b)
#define f1 first
#define s2 second
#define cotu cout
#define itn lli
#define pii pair<int,int>

using namespace std;

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int n;
    cin >> n;
    vector<pii>ss;
    for (int i = 0; i < n; i++){
        int x1, y1, x2, y2;
        cin >> x1 >> y1 >> x2 >> y2;
        x1 += 1e9;
        y1 += 1e9;
        cout << (x1 % 2) * 2 + (y1 % 2) + 1;
    }
    return 0;
}


#include <iostream>
#include <fstream>
#include <map>
#include <cmath>
#include <math.h>
#include <set>
#include <vector>
#include <sstream>
#include <string>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <queue>
#include <cstdlib>
#include <iomanip>
#include <unordered_map>
#include <unordered_set>
#include <string>
#include <time.h>
#include <ctime>

typedef long long int lli;
typedef long double ld;
const lli INF = 1e9 + 999, MOD = 1e9+7, MAXN = 200000; //18
const ld EPS = 0.00000001;
#define forn(a, b) for (lli i = a; i < b; i++)
#define fore(p, a, b) for (lli p = a; p < b; p++)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb(a) push_back(a)
#define sz(a) (int)a.size()
#define mp(a, b) make_pair(a, b)
#define f1 first
#define s2 second
#define cotu cout
#define itn lli
#define pii pair<int,int>

using namespace std;

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int n;
    cin >> n;
    vector<pii>ss;
    for (int i = 0; i < n; i++){
        int x1, y1, x2, y2;
        cin >> x1 >> y1 >> x2 >> y2;
        x1 += 1e9;
        y1 += 1e9;
        cout << (x1 % 2) * 2 + (y1 % 2) + 1 << " ";
    }
    return 0;
}


[#include <iostream>
#include <fstream>
#include <map>
#include <cmath>
#include <math.h>
#include <set>
#include <vector>
#include <sstream>
#include <string>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <queue>
#include <cstdlib>
#include <iomanip>
#include <unordered_map>
#include <unordered_set>
#include <string>
#include <time.h>
#include <ctime>

typedef long long int lli;
typedef long double ld;
const lli INF = 1e9 + 999, MOD = 1e9+7, MAXN = 200000; //18
const ld EPS = 0.00000001;
#define forn(a, b) for (lli i = a; i < b; i++)
#define fore(p, a, b) for (lli p = a; p < b; p++)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb(a) push_back(a)
#define sz(a) (int)a.size()
#define mp(a, b) make_pair(a, b)
#define f1 first
#define s2 second
#define cotu cout
#define itn lli
#define pii pair<int,int>

using namespace std;

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int n;
    cin >> n;
    vector<pii>ss;
    for (int i = 0; i < n; i++){
        int x1, y1, x2, y2;
        cin >> x1 >> y1 >> x2 >> y2;
        x1 += 1e9;
        y1 += 1e9;
        cout << (x1 % 2) * 2 + (y1 % 2) + 1;
    }
    return 0;
}


#include<iostream>
#include<fstream>
#include<iomanip>
#include<string>
#include<vector>
#include<map>
#include<list>
#include<queue>
#include<deque>
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<set>
#include<stack>

#define rFOR(i,x,y) for(int i = x; i >= y; --i)
#define FOR(i,x,y) for(int i = x; i <= y; ++i)
#define clean(x) memset(x, 0, sizeof(x))
#define rclean(x) memset(x, -1, sizeof(x))
#define pb push_back
#define F first
#define S second
#define all(x) (x.begin(), x.end())
#define task "input"

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;

const int INF = 10e9 + 1;
const double PI = 3.14159265359;

int n;

main(){
    //freopen(task".in", "r", stdin);
    //freopen(task".out", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin >> n;
    cout << "YES\n";
    FOR(i, 1, n){
        int a, b, x, y;
        cin >> x >> y >> a >> b;
        x = abs(x);
        y = abs(y);
        cout << 2 * (x % 2) + (y % 2) + 1 << "\n";
    }
}


#include<iostream>
#include<fstream>
#include<iomanip>
#include<string>
#include<vector>
#include<map>
#include<list>
#include<queue>
#include<deque>
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<set>
#include<stack>

#define rFOR(i,x,y) for(int i = x; i >= y; --i)
#define FOR(i,x,y) for(int i = x; i <= y; ++i)
#define clean(x) memset(x, 0, sizeof(x))
#define rclean(x) memset(x, -1, sizeof(x))
#define pb push_back
#define F first
#define S second
#define all(x) (x.begin(), x.end())
#define task "input"

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;

const int INF = 10e9 + 1;
const double PI = 3.14159265359;

int n;

main(){
    //freopen(task".in", "r", stdin);
    //freopen(task".out", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin >> n;
    cout << "YES\n";
    FOR(i, 1, n){
        int a, b, x, y;
        cin >> a >> b >> x >> y;
        cout << 2 * (x % 2) + (y % 2) << "\n";
    }
}


/*
Hanit Banga
*/

#include <iostream>
#include <vector>

using namespace std;

#define pb push_back
#define fast_cin() ios_base::sync_with_stdio(false)

typedef long long ll;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;

const int N = 1e5 + 5, MX = 1e9;

int main()
{
	int n;
	cin >> n;
	cout << "YES\n";
	for (int i = 0; i < n; ++i)
	{
		int x1, y1, x2, y2;
		cin >> x1 >> y1 >> x2 >> y2;
		x1 += MX; x2 += MX;
		cout << (x1 % 2) + 2*(x2 % 2) << '\n';
	}
}


/*
Hanit Banga
*/

#include <iostream>
#include <vector>

using namespace std;

#define pb push_back
#define fast_cin() ios_base::sync_with_stdio(false)

typedef long long ll;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;

const int N = 1e5 + 5;

int main()
{
	int n;
	cin >> n;
	cout << "YES\n";
	for (int i = 0; i < n; ++i)
	{
		int x1, y1, x2, y2;
		cin >> x1 >> y1 >> x2 >> y2;
		cout << (x1 % 2) + 2*(x2 % 2) << '\n';
	}
}


/*
Hanit Banga
*/

#include <iostream>
#include <vector>

using namespace std;

#define pb push_back
#define fast_cin() ios_base::sync_with_stdio(false)

typedef long long ll;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;

const int N = 1e5 + 5, MX = 1e9;

int main()
{
	int n;
	cin >> n;
	cout << "YES\n";
	for (int i = 0; i < n; ++i)
	{
		int x1, y1, x2, y2;
		cin >> x1 >> y1 >> x2 >> y2;
		x1 += MX; y1 += MX;
		cout << (x1 % 2) + 2*(y1 % 2) + 1 << '\n';
	}
}


/*
Hanit Banga
*/

#include <iostream>
#include <vector>

using namespace std;

#define pb push_back
#define fast_cin() ios_base::sync_with_stdio(false)

typedef long long ll;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;

const int N = 1e5 + 5, MX = 1e9;

int main()
{
	int n;
	cin >> n;
	cout << "YES\n";
	for (int i = 0; i < n; ++i)
	{
		int x1, y1, x2, y2;
		cin >> x1 >> y1 >> x2 >> y2;
		x1 += MX; y1 += MX;
		cout << (x1 % 2) + 2*(y1 % 2) << '\n';
	}
}


#include <bits/stdc++.h>

struct Rect{
	int id, color;
	int x1, y1, x2, y2;
};

int main() {
	int n; scanf("%d", &n);

	std::vector<Rect> rects;

	int minX = INT_MAX;
	int maxY = INT_MIN;

	for (int i = 0; i < n; i++) {
		int x1, y1, x2, y2; scanf("%d %d %d %d", &x1, &y1, &x2, &y2);
		rects.push_back(Rect{i, 0, x1, y1, x2, y2});

		minX = std::min(minX, x1);
		maxY = std::max(maxY, y2);
	}

	std::sort(rects.begin(), rects.end(), [minX, maxY](const Rect &left, const Rect &right) {
		return left.x1 - minX + maxY - left.y2 < right.x1 - minX + maxY - right.y2;
	});

	int color = 1;
	for (int i = 0; i < (int)rects.size(); i++) {
		rects[i].color = color;
		color++;
		if (color == 5) {
			color = 1;
		}
	}

	std::sort(rects.begin(), rects.end(), [](const Rect &left, const Rect &right) {
		return left.id < right.id;
	});

	printf("YES\n");
	for (int i = 0; i < n; i++) {
		printf("%d\n", rects[i].color);
	}

	return 0;
}


#include<iostream>
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
using namespace std;
int minx(int x,int y){if(x<y)y=x;return y;}
int main(void)
{
	int n,x1,x2,y1,y2;
	scanf("%d",&n);
	printf("YES");
	while(n--)
	{
		scanf("%d%d%d%d",&x1,&y1,&x2,&y2);
		x1=minx(x1,x2);y1=minx(y1,y2);
		printf("\n%d",2*(x1&1)+(y1&1));
	}
	return 0;
}


#include<iostream>
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
using namespace std;
int minx(int x,int y){if(x<y)y=x;return y;}
int main(void)
{
	int n,x1,x2,y1,y2;
	scanf("%d",&n);
	printf("YES");
	while(n--)
	{
		scanf("%d%d%d%d",&x1,&y1,&x2,&y2);
		x1=minx(x1,x2);y1=minx(y1,y2);
		printf("\n%d",1+2*(x1&1)+(y1&1));
	}
	return 0;
}


#include<iostream>

using namespace std;

int main(){

	int n;
	cin >> n;

	string str;
	cin >> str;

	char c = str[0];
	int count = 0;

	for(int i = 0; i < str.length(); i++){

		if(str[i] == c) {
			count++;
		}else{
			break;
		}

	}

	char d = str[str.length() - 1];

	for(int i = str.length() - 1; i >= 0; i--){

		if(str[i] == d) {
			count++;
		}else{
			break;
		}

	}

	if(c == d){

		count += (count - 1);

	}

	cout << count+1 << endl;

}


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

int main(){

	int n;
	string str;
	cin >> n >> str;
	int l = 0, r = 0;
	char c = str[0];
	bool same = false;
	for(int i = 0; i < str.length(); i++){
		if(c == str[i]){
			l++;
		}else{
			break;
		}
	}
	if(str[str.length() - 1] != c){
		c = str[str.length() - 1];
	}else{
		same = true;
	}
	for(int i = str.length() - 1; i >= 0; i--){
		if(c == str[i]){
			r++;
		}else{
			break;
		}
	}
	long long result;
	if(same == true){
		result = ((l+1)*(r+1))%998244353;
	}else{
		result = (l+r+1)%998244353;
	}
	cout << result << endl;

}


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

#define MOD 998244353
#define ll long long

int main() {
	#ifndef ONLINE_JUDGE
	freopen("in.txt", "r", stdin);
	freopen("out.txt", "w", stdout);
	#endif

	int len;
	string str;

	cin >> len >> str;

	int front = 1, back = 1;

	for (int i = 1; i < len; i++) {
		if (str[i] == str[i - 1]) front++;
		else break;
	}
	for (int i = len - 2; i >= 0; i--) {
		if (str[i] == str[i + 1]) back++;
		else break;
	}

	ll ans = (front + back + 1) % MOD;
	if (str[0] == str[len - 1]) ans += (front * back) % MOD;

	cout << ans % MOD << endl;

}


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

#define ll long long

int main() {
	#ifndef ONLINE_JUDGE
	freopen("in.txt", "r", stdin);
	freopen("out.txt", "w", stdout);
	#endif

	int len;
	string str;

	cin >> len >> str;

	int front = 0, back = 0;

	for (int i = 0; i < len; i++) {
		if (str[i] == str[0]) front++;
		else break;
	}
	for (int i = len - 1; i >= 0; i--) {
		if (str[i] == str[len - 1]) back++;
		else break;
	}

	const ll MOD = 998244353;
	ll ans = (front + back + 1);
	if (str[0] == str[len - 1]) ans = (front + 1) * (back + 1);

	cout << ans % MOD << endl;

}


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

#define ll long long

int main() {
	#ifndef ONLINE_JUDGE
	freopen("in.txt", "r", stdin);
	freopen("out.txt", "w", stdout);
	#endif

	int len;
	string str;

	cin >> len >> str;

	int front = 1, back = 1;

	for (int i = 1; i < len; i++) {
		if (str[i] == str[i - 1]) front++;
		else break;
	}
	for (int i = len - 2; i >= 0; i--) {
		if (str[i] == str[i + 1]) back++;
		else break;
	}

	const ll MOD = 998244353;
	ll ans = (front + back + 1);
	if (str[0] == str[len - 1]) ans += (front * back);

	cout << ans % MOD << endl;

}


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

#define ll long long

int main() {
	#ifndef ONLINE_JUDGE
	freopen("in.txt", "r", stdin);
	freopen("out.txt", "w", stdout);
	#endif

	int len;
	string str;

	cin >> len >> str;

	int front = 1, back = 1;

	for (int i = 1; i < len; i++) {
		if (str[i] == str[i - 1]) front++;
		else break;
	}
	for (int i = len - 2; i >= 0; i--) {
		if (str[i] == str[i + 1]) back++;
		else break;
	}

	const ll MOD = 998244353;
	ll ans = (front + back + 1);
	if (str[0] == str[len - 1]) ans = (front + 1) * (back + 1);

	cout << ans % MOD << endl;

}


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

#define ll long long

int main() {
	#ifndef ONLINE_JUDGE
	freopen("in.txt", "r", stdin);
	freopen("out.txt", "w", stdout);
	#endif

	int len;
	string str;

	cin >> len >> str;

	ll front = 0, back = 0;

	for (int i = 0; i < len; i++) {
		if (str[i] == str[0]) front++;
		else break;
	}
	for (int i = len - 1; i >= 0; i--) {
		if (str[i] == str[len - 1]) back++;
		else break;
	}

	const ll MOD = 998244353;
	ll ans = (front + back + 1) % MOD;
	if (str[0] == str[len - 1]) ans = ((front + 1) * (back + 1)) % MOD;

	cout << ans << endl;

}


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

#define MOD 998244353
#define ll long long

int main() {
	#ifndef ONLINE_JUDGE
	freopen("in.txt", "r", stdin);
	freopen("out.txt", "w", stdout);
	#endif

	int len;
	string str;

	cin >> len >> str;

	int front = 1, back = 1;

	for (int i = 1; i < len; i++) {
		if (str[i] == str[i - 1]) front++;
		else break;
	}
	for (int i = len - 2; i >= 0; i--) {
		if (str[i] == str[i + 1]) back++;
		else break;
	}

	ll ans = (front + back + 1);
	if (str[0] == str[len - 1]) ans += front * back;

	cout << ans % MOD << endl;

}


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

#define MOD 998244353
#define ll long long

int main() {
	#ifndef ONLINE_JUDGE
	freopen("in.txt", "r", stdin);
	freopen("out.txt", "w", stdout);
	#endif

	int len;
	string str;

	cin >> len >> str;

	int front = 1, back = 1;

	for (int i = 1; i < len; i++) {
		if (str[i] == str[i - 1]) front++;
		else break;
	}
	for (int i = len - 2; i >= 0; i--) {
		if (str[i] == str[i + 1]) back++;
		else break;
	}

	ll ans = (front + back + 1) % MOD;
	if (str[0] == str[len - 1]) ans = (ans + (front * back) % MOD) % MOD;

	cout << ans << endl;

}


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

#define ll long long

int main() {
	#ifndef ONLINE_JUDGE
	freopen("in.txt", "r", stdin);
	freopen("out.txt", "w", stdout);
	#endif

	int len;
	string str;

	cin >> len >> str;

	int front = 0, back = 0;

	for (int i = 0; i < len; i++) {
		if (str[i] == str[0]) front++;
		else break;
	}
	for (int i = len - 1; i >= 0; i--) {
		if (str[i] == str[len - 1]) back++;
		else break;
	}

	const ll MOD = 998244353;
	ll ans = (front + back + 1) % MOD;
	if (str[0] == str[len - 1]) ans = ((front + 1) * (back + 1)) % MOD;

	cout << ans << endl;

}


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

#define MOD 998244353LL
#define ll long long

int main() {
	#ifndef ONLINE_JUDGE
	freopen("in.txt", "r", stdin);
	freopen("out.txt", "w", stdout);
	#endif

	int len;
	string str;

	cin >> len >> str;

	int front = 1, back = 1;

	for (int i = 1; i < len; i++) {
		if (str[i] == str[i - 1]) front++;
		else break;
	}
	for (int i = len - 2; i >= 0; i--) {
		if (str[i] == str[i + 1]) back++;
		else break;
	}

	ll ans = (front + back + 1);
	if (str[0] == str[len - 1]) ans += front * back;

	cout << ans % MOD << endl;

}


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

#define ll long long

int main() {
	#ifndef ONLINE_JUDGE
	freopen("in.txt", "r", stdin);
	freopen("out.txt", "w", stdout);
	#endif

	int len;
	string str;

	cin >> len >> str;

	int front = 1, back = 1;

	for (int i = 0; i < len; i++) {
		if (str[i] == str[0]) front++;
		else break;
	}
	for (int i = len - 1; i >= 0; i--) {
		if (str[i] == str[len - 1]) back++;
		else break;
	}

	const ll MOD = 998244353;
	ll ans = (front + back + 1);
	if (str[0] == str[len - 1]) ans = (front + 1) * (back + 1);

	cout << ans % MOD << endl;

}


#include<bits/stdc++.h>
typedef long long int lli;
using namespace std;

int main()

{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    const int mod= 998244353;
    int n;
    cin>>n;
    string s;
    cin>>s;
    int flag=0;
    if(s[0]==s[n-1]){flag=1;}
    int countl=0,countr=0;
    int i=0;
    while(s[i]==s[0])
    {
    	countl++;
    	i++;
    }
    i=n-1;
    while(s[i]==s[n-1])
    {
    	countr++;
    	i--;
    }

    if(countl==s.length())
    {
    	cout<<(countl*(countl+1) /2)%mod;
    	return 0;
    }
    int initial=countl+countr+1;
    if(flag==1)
    {
    	initial=initial+(countr);
    }
    cout<<initial%mod;
}


#include<bits/stdc++.h>
typedef long long int lli;
using namespace std;

int main()

{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    const int mod= 998244353;
    int n;
    cin>>n;
    string s;
    cin>>s;

    int flag=0;
    if(s[0]==s[n-1]){flag=1;}
    int countl=0,countr=0;
    int i=0;
    while(s[i]==s[0])
    {
    	countl++;
    	i++;
    	if(i==n){break;}
    }
    i=n-1;
    while(s[i]==s[n-1]&&i>-1)
    {
    	countr++;
    	i--;
    	if(i==-1)break;
    }
    if(countl==n)
    {
    	cout<<(countl*(countl+1) /2)%mod;
    	return 0;
    }
    lli initial=countl%mod+countr%mod+1;
    if(flag==1)
    {
    	initial=((countl+1)%mod*(countr+1)%mod)%mod;
    }
    cout<<initial%mod;
}


#include<bits/stdc++.h>
typedef long long int lli;
using namespace std;

int main()

{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    const int mod= 998244353;
    int n;
    cin>>n;
    string s;
    cin>>s;

    int flag=0;
    if(s[0]==s[n-1]){flag=1;}
    int countl=0,countr=0;
    for(int i=0;i<n;i++)
    {if(s[i]==s[0])
    {countl++;}
    else{break;}
    }
    for(int i=n-1;i>-1;i--)
    {if(s[i]==s[n-1])
    {countr++;}
    else{break;}
    }

    if(countl==n)
    {
    	cout<<(countl*(countl+1) /2)%mod;
    	return 0;
    }
    //lli initial=countl%mod+countr%mod+1;
    if(flag==1)
    {
    	cout << ((countl + 1) * 1ll * (countr + 1)) % 998244353 << endl;
    	return 0;
    }
    cout<<(countl+countr+1)%mod;
}


#include<bits/stdc++.h>
typedef long long int lli;
using namespace std;

int main()

{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    const int mod= 998244353;
    int n;
    cin>>n;
    string s;
    cin>>s;

    int flag=0;
    if(s[0]==s[n-1]){flag=1;}
    int countl=0,countr=0;
    int i=0;
    while(s[i]==s[0])
    {
    	countl++;
    	i++;
    	if(i==n){break;}
    }
    i=n-1;
    while(s[i]==s[n-1]&&i>-1)
    {
    	countr++;
    	i--;
    	if(i==-1)break;
    }
    if(countl==n)
    {
    	cout<<(countl*(countl+1) /2)%mod;
    	return 0;
    }
    int initial=countl+countr+1;
    if(flag==1)
    {
    	initial=initial+(countr);
    }
    cout<<initial%mod;
}


#include<bits/stdc++.h>
typedef long long int lli;
using namespace std;

int main()

{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    const int mod= 998244353;
    int n;
    cin>>n;
    string s;
    cin>>s;

    int flag=0;
    if(s[0]==s[n-1]){flag=1;}
    int countl=0,countr=0;
    int i=0;
    while(s[i]==s[0])
    {
    	countl++;
    	i++;
    	if(i==n){break;}
    }
    i=n-1;
    while(s[i]==s[n-1]&&i>-1)
    {
    	countr++;
    	i--;
    	if(i==-1)break;
    }
    if(countl==n)
    {
    	cout<<(countl*(countl+1) /2)%mod;
    	return 0;
    }
    int initial=countl+countr+1;
    if(flag==1)
    {
    	initial=((countl+1)*(countr+1));
    }
    cout<<initial%mod;
}


#include<bits/stdc++.h>
typedef long long int lli;
using namespace std;

int main()

{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    const int mod= 998244353;
    int n;
    cin>>n;
    string s;
    cin>>s;

    int flag=0;
    if(s[0]==s[n-1]){flag=1;}
    int countl=0,countr=0;
    int i=0;
    while(s[i]==s[0])
    {
    	countl++;
    	i++;
    	if(i==n){break;}
    }
    i=n-1;
    while(s[i]==s[n-1]&&i>-1)
    {
    	countr++;
    	i--;
    	if(i==-1)break;
    }
    if(countl==n)
    {
    	cout<<(countl*(countl+1) /2)%mod;
    	return 0;
    }
    int initial=countl%mod+countr%mod+1;
    if(flag==1)
    {
    	initial=((countl+1)%mod*(countr+1)%mod)%mod;
    }
    cout<<initial%mod;
}


#include<bits/stdc++.h>
typedef long long int lli;
using namespace std;

int main()

{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin>>n;
    string s;
    cin>>s;
    int flag=0;
    if(s[0]==s[n-1]){flag=1;}
    int countl=0,countr=0;
    int i=0;
    while(s[i]==s[0])
    {
    	countl++;
    	i++;
    }
    i=n-1;
    while(s[i]==s[n-1])
    {
    	countr++;
    	i--;
    }
    int initial=countl+countr+1;
    if(flag==1)
    {
    	initial=initial+(countr);
    }
    cout<<initial;
}


#include<bits/stdc++.h>
typedef long long int lli;
using namespace std;

int main()

{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    const int mod= 998244353;
    int n;
    cin>>n;
    string s;
    cin>>s;

    int flag=0;
    if(s[0]==s[n-1]){flag=1;}
    int countl=0,countr=0;
    for(int i=0;i<n;i++)
    {if(s[i]==s[0])
    {countl++;}
    else{break;}
    }
    for(int i=n-1;i>-1;i--)
    {if(s[i]==s[n-1])
    {countr++;}
    else{break;}
    }

    if(countl==n)
    {
    	cout<<(countl*(countl+1) /2)%mod;
    	return 0;
    }
    //lli initial=countl%mod+countr%mod+1;
    if(flag==1)
    {
    	cout<<((countl+1)%mod*(countr+1)%mod)%mod;
    	return 0;
    }
    cout<<(countl+countr+1)%mod;
}


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

int main()
{
    int n;
    cin>>n;
    string s;
    cin>>s;
    int l=0,r=s.length()-1,el=0,er=0;
    long long ans=0;

    while(true)
    {
       if(s[l]==s[l+1])
       {
           el++;
           l++;
       }
       else
       break;
    }
    while(true)
    {
       if(s[r]==s[r-1])
       {
           er++;
           r--;
       }
       else
       break;
    }
    //cout<<el<<" "<<er<<endl;
    ans=((el+1+er+1)%mod );
    if(s[0]==s[s.length()-1])
    ans=(ans+ ((el+1)*(er+1))%mod)%mod;
    cout<<(ans+1)%mod<<endl;
    return 0;

}


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

int main()
{
    int n;
    cin>>n;
    string s;
    cin>>s;
    int l=0,r=s.length()-1,el=0,er=0;
    long long ans=0;

    while(true)
    {
       if(s[l]==s[l+1])
       {
           el++;
           l++;
       }
       else
       break;
    }
    while(true)
    {
       if(s[r]==s[r-1])
       {
           er++;
           r--;
       }
       else
       break;
    }
    //cout<<el<<" "<<er<<endl;

    if(s[0]==s[s.length()-1])
    cout<<((el+2)*1ll*(er+2))%mod<<endl;
    else
    cout<<((el+1+er+1+1)%mod )<<endl;
    //cout<<(ans)%mod<<endl;
    return 0;

}


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

int main()
{
    int n;
    cin>>n;
    string s;
    cin>>s;
    int l=0,r=s.length()-1,el=0,er=0;
    long long ans=2;
    if(s[l]==s[r])
    ans++;
    while(true)
    {
        int templ=0,tempr=0;
        if(s[l+1]==s[l])
        {
            ans=(ans+1)%mod;
            if(s[l]==s[r])
            ans=(ans+1)%mod;
            templ=1;
        }
        else
        {
            el=1;
        }
        if(s[r-1]==s[r])
        {
            ans=(ans+1)%mod;
            if(s[l]==s[r])
            ans=(ans+1)%mod;
            tempr=1;
        }
        else
        {
            er=1;
        }
        if(templ==1)
        {
            l++;
            templ=0;
        }
        if(tempr==1)
        {
            r--;
            tempr=0;
        }
        if(el==1 && er==1)
        break;
    }
    cout<<(ans+1)%mod<<endl;
    return 0;

}


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

int main()
{
    int n;
    cin>>n;
    string s;
    cin>>s;
    int l=0,r=s.length()-1,el=0,er=0;
    long long ans=2;
    if(s[l]==s[r])
    ans++;
    while(true)
    {
        int templ=0,tempr=0;
        if(s[l+1]==s[l])
        {
            ans=(ans+1)%mod;
            if(s[l]==s[r])
            ans=(ans+1)%mod;
            templ=1;
        }
        else
        {
            el=1;
        }
        if(s[r-1]==s[r])
        {
            ans=(ans+1)%mod;
            if(s[l]==s[r])
            ans=(ans+1)%mod;
            tempr=1;
        }
        else
        {
            er=1;
        }
        if(templ==1)
        {
            l++;
            //templ=0;
        }
        if(tempr==1)
        {
            r--;
            //tempr=0;
        }
        if(templ==1 && tempr==1)
        {
            if(s[l]==s[r])
            ans=(ans+1)%mod;
        }
        templ=0;
        tempr=0;
        if(el==1 && er==1)
        break;
    }
    cout<<(ans+1)%mod<<endl;
    return 0;

}


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

int main()
{
    int n;
    cin>>n;
    string s;
    cin>>s;
    long long l=0,r=s.length()-1,el=0,er=0;
    long long ans=0;

    while(true)
    {
       if(s[l]==s[l+1])
       {
           el++;
           l++;
       }
       else
       break;
    }
    while(true)
    {
       if(s[r]==s[r-1])
       {
           er++;
           r--;
       }
       else
       break;
    }
    //cout<<el<<" "<<er<<endl;

    if(s[0]==s[s.length()-1])
    cout<<((el+2)*(er+2))%mod<<endl;
    else
    cout<<((el+1+er+1+1)%mod )<<endl;
    //cout<<(ans)%mod<<endl;
    return 0;

}


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

int main()
{
    int n;
    cin>>n;
    string s;
    cin>>s;
    int l=0,r=s.length()-1,el=0,er=0;
    long long ans=0;

    while(true)
    {
       if(s[l]==s[l+1])
       {
           el++;
           l++;
       }
       else
       break;
    }
    while(true)
    {
       if(s[r]==s[r-1])
       {
           er++;
           r--;
       }
       else
       break;
    }
    //cout<<el<<" "<<er<<endl;

    if(s[0]==s[s.length()-1])
    cout<<((el+2)*(er+2))%mod<<endl;
    else
    cout<<((el+1+er+1+1)%mod )<<endl;
    //cout<<(ans)%mod<<endl;
    return 0;

}


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

int main()
{
    int n;
    cin>>n;
    string s;
    cin>>s;
    int l=0,r=s.length()-1,el=0,er=0;
    long long ans=2;
    if(s[l]==s[r])
    ans++;
    while(true)
    {
        int templ=0,tempr=0;
        if(s[l+1]==s[l])
        {
            ans=(ans+1)%mod;
            if(s[l]==s[r])
            ans=(ans+1)%mod;
            templ=1;
        }
        else
        {
            el=1;
        }
        if(s[r-1]==s[r])
        {
            ans=(ans+1)%mod;
            if(s[l]==s[r])
            ans=(ans+1)%mod;
            tempr=1;
        }
        else
        {
            er=1;
        }
        if(templ==1)
        {
            l++;
            //templ=0;
        }
        if(tempr==1)
        {
            r--;
            //tempr=0;
        }
        if(templ==1 || tempr==1)
        {
            if(s[l]==s[r])
            ans=(ans+1)%mod;
        }
        templ=0;
        tempr=0;
        if(el==1 && er==1)
        break;
    }
    cout<<(ans+1)%mod<<endl;
    return 0;

}


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

int main()
{
    int n;
    cin>>n;
    string s;
    cin>>s;
    int l=0,r=s.length()-1,el=0,er=0;
    long long ans=0;

    while(true)
    {
       if(s[l]==s[l+1])
       {
           el++;
           l++;
       }
       else
       break;
    }
    while(true)
    {
       if(s[r]==s[r-1])
       {
           er++;
           r--;
       }
       else
       break;
    }
    //cout<<el<<" "<<er<<endl;

    ans=((el+1+er+1+1)%mod );
    if(s[0]==s[s.length()-1])
    ans=((el+2)*(er+2))%mod;
    cout<<(ans)%mod<<endl;
    return 0;

}


#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include "math.h"
#include <algorithm>
#include <map>
#include <deque>
#include <queue>
#include <set>
#include <stack>

using namespace std;
long long maxINT = 998244353;
vector<int>used(300300);
vector<int>l(300300);
vector<int>r(300300);
int main() {

	cin.tie(0);
	ios_base::sync_with_stdio(0);

	string s;
	long long n;
	cin >> n;
	cin >> s;
	long long begin = 1;
	for (int i = 1;i < n;++i) {
		if (s[i] != s[i - 1]) {
			break;
		}
		begin++;
	}
	if (begin == n) {
		cout << (((1 + n)*n) / 2) % maxINT;
		return 0;
	}
	long long last = 1;
	for (int i = n - 2;i >= 0;--i) {
		if (s[i] != s[i + 1]) {
			break;
		}
		last++;
	}
	if (s[n - 1] == s[0]) {
		long long removeLast = (begin*last) % maxINT;
		long long removeFirst = (last*begin)  % maxINT;
		cout << (removeLast + removeFirst + 2) % maxINT;
	}
	else {
		cout << (last + begin + 1) % maxINT;
	}
	return 0;
}


#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include "math.h"
#include <algorithm>
#include <map>
#include <deque>
#include <queue>
#include <set>
#include <stack>

using namespace std;
long long maxINT = 998244353;
int main() {

	cin.tie(0);
	ios_base::sync_with_stdio(0);

	string s;
	long long n;
	cin >> n;
	cin >> s;
	long long begin = 1;
	for (int i = 1;i < n;++i) {
		if (s[i] != s[i - 1]) {
			break;
		}
		begin++;
	}
	long long last = 1;
	for (int i = n - 2;i >= 0;--i) {
		if (s[i] != s[i + 1]) {
			break;
		}
		last++;
	}
	if (s[n - 1] == s[0]) {
		long long removeLast = (begin*last) % maxINT;
		long long removeFirst = (last*begin +2-min(last,begin)) % maxINT;
		cout << (removeLast + removeFirst) % maxINT;
	}
	else {
		cout << (last + begin + 1) % maxINT;
	}
	return 0;
}


#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include "math.h"
#include <algorithm>
#include <map>
#include <deque>
#include <queue>
#include <set>
#include <stack>

using namespace std;
long long maxINT = 998244353;
int main() {

	cin.tie(0);
	ios_base::sync_with_stdio(0);

	string s;
	long long n;
	cin >> n;
	cin >> s;
	long long begin = 1;
	for (int i = 1;i < n;++i) {
		if (s[i] != s[i - 1]) {
			break;
		}
		begin++;
	}
	long long last = 1;
	for (int i = n - 2;i >= 0;--i) {
		if (s[i] != s[i + 1]) {
			break;
		}
		last++;
	}
	if (s[n - 1] == s[0]) {
		long long removeLast = (begin*last) % maxINT;
		long long removeFirst = (last*begin - min(last, begin) + 3) % maxINT;
		cout << (removeLast + removeFirst) % maxINT;
	}
	else {
		cout << (last + begin + 1) % maxINT;
	}
	return 0;
}


#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include "math.h"
#include <algorithm>
#include <map>
#include <deque>
#include <queue>
#include <set>
#include <stack>

using namespace std;
long long maxINT = 998244353;
int main() {

	cin.tie(0);
	ios_base::sync_with_stdio(0);

	string s;
	long long n;
	cin >> n;
	cin >> s;
	long long begin = 1;
	for (int i = 1;i < n;++i) {
		if (s[i] != s[i - 1]) {
			break;
		}
		begin++;
	}
	long long last = 1;
	for (int i = n - 2;i >= 0;--i) {
		if (s[i] != s[i + 1]) {
			break;
		}
		last++;
	}
	if (s[n - 1] == s[0]) {
		long long removeLast = (begin*last) % maxINT;
		long long removeFirst = (last*begin + max(last, begin)) % maxINT;
		cout << (removeLast + removeFirst) % maxINT;
	}
	else {
		cout << (last + begin + 1) % maxINT;
	}
	return 0;
}


#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include "math.h"
#include <algorithm>
#include <map>
#include <deque>
#include <queue>
#include <set>
#include <stack>

using namespace std;
long long maxINT = 998244353;
int main() {

	cin.tie(0);
	ios_base::sync_with_stdio(0);

	string s;
	long long n;
	cin >> n;
	cin >> s;
	long long begin = 1;
	for (int i = 1;i < n;++i) {
		if (s[i] != s[i - 1]) {
			break;
		}
		begin++;
	}
	long long last = 1;
	for (int i = n - 2;i >= 0;--i) {
		if (s[i] != s[i + 1]) {
			break;
		}
		last++;
	}
	if (s[n - 1] == s[0]) {
		long long removeLast = (begin*last) % maxINT;
		long long removeFirst = (last*begin +3-min(last,begin)) % maxINT;
		cout << (removeLast + removeFirst) % maxINT;
	}
	else {
		cout << (last + begin + 1) % maxINT;
	}
	return 0;
}


#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include "math.h"
#include <algorithm>
#include <map>
#include <deque>
#include <queue>
#include <set>
#include <stack>

using namespace std;
long long maxINT = 998244353;
vector<int>used(300300);
vector<int>l(300300);
vector<int>r(300300);
int main() {

	cin.tie(0);
	ios_base::sync_with_stdio(0);

	string s;
	long long n;
	cin >> n;
	cin >> s;
	long long begin = 1;
	for (int i = 1;i < n;++i) {
		if (s[i] != s[i - 1]) {
			break;
		}
		begin++;
	}
	long long last = 1;
	for (int i = n - 2;i >= 0;--i) {
		if (s[i] != s[i + 1]) {
			break;
		}
		last++;
	}
	if (s[n - 1] == s[0]) {
		long long removeLast = (begin*last) % maxINT;
		long long removeFirst = (last*begin - (min(last, begin) - 1)) % maxINT;
		cout << (removeLast + removeFirst + 2) % maxINT;
	}
	else {
		cout << (last + begin + 1) % maxINT;
	}
	return 0;
}


#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include "math.h"
#include <algorithm>
#include <map>
#include <deque>
#include <queue>
#include <set>
#include <stack>

using namespace std;
long long maxINT = 998244353;
int main() {

	cin.tie(0);
	ios_base::sync_with_stdio(0);

	string s;
	long long n;
	cin >> n;
	cin >> s;
	long long begin = 1;
	for (int i = 1;i < n;++i) {
		if (s[i] != s[i - 1]) {
			break;
		}
		begin++;
	}
	long long last = 1;
	for (int i = n - 2;i >= 0;--i) {
		if (s[i] != s[i + 1]) {
			break;
		}
		last++;
	}
	if (s[n - 1] == s[0]) {
		long long removeLast = (begin*last) % maxINT;
		long long removeFirst = (last*begin + min(last, begin)+1) % maxINT;
		cout << (removeLast + removeFirst) % maxINT;
	}
	else {
		cout << (last + begin + 1) % maxINT;
	}
	return 0;
}


#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include "math.h"
#include <algorithm>
#include <map>
#include <deque>
#include <queue>
#include <set>
#include <stack>

using namespace std;
long long maxINT = 998244353;
int main() {

    cin.tie(0);
    ios_base::sync_with_stdio(0);

    string s;
    long long n;
    cin >> n;
    cin >> s;
    long long begin = 1;
    for (int i = 1;i < n;++i) {
        if (s[i] != s[i - 1]) {
            break;
        }
        begin++;
    }
    long long last = 1;
    for (int i = n - 2;i >= 0;--i) {
        if (s[i] != s[i + 1]) {
            break;
        }
        last++;
    }
    if (s[n - 1] == s[0]) {

        cout << ((begin+1)*(last+1)) % maxINT;
    }
    else {
        cout << (last + begin + 1) % maxINT;
    }
    return 0;
}


#include <iostream>
using namespace std;
int main()
{
	int N,i,j,sum=0;
	cin>>N;
	char a[N+2];
	for(i=1;i<=N;i++)
		cin>>a[i];
	int frist=0,last=0;
	for(i=1;i<N;i++)
	{
		if(a[i]==a[i+1])
			frist++;
		else
			break;
	}
	if(frist==N-1)
	{
		for(i=1;i<=N;i++)
			sum=sum+i;
		cout<<sum%998244353;
		return 0;
	}
	frist++;
	for(i=N;i>=1;i--)
	{
		if(a[i]==a[i-1])
			last++;
		else
			break;
	}
	last++;
	if(a[1]==a[N])
		cout<<(frist+last+frist*last+1)%998244353;
	else
		cout<<(frist+last+1)%998244353;

}


#include <iostream>
using namespace std;
int main()
{
	int N,i,j,sum=0;
	cin>>N;
	char a[N+1];
	cin>>a;
	long long frist=1,last=1;
	for(i=0;i<N-2;i++)
	{
		if(a[i]==a[i+1])
			frist++;
		else
			break;
	}
	cout<<"frist="<<frist<<endl;
	for(i=N-1;i>0;i--)
	{
		if(a[i]==a[i-1])
			last++;
		else
			break;
	}
	cout<<"last	="<<last<<endl;
	if(a[0]==a[N-1])
		cout<<(frist+last+(frist*last)+1)%998244353<<endl;
	else
		cout<<(frist+last+1)%998244353<<endl;

}


#include <iostream>
using namespace std;
int main()
{
	int N,i,j,sum=0;
	cin>>N;
	char a[N+2];
	for(i=1;i<=N;i++)
		cin>>a[i];
	int frist=0,last=0;
	for(i=1;i<N;i++)
	{
		if(a[i]==a[i+1])
			frist++;
		else
			break;
	}
	if(frist==N-1)
	{
		for(i=1;i<=N;i++)
			sum=sum+i;
		cout<<sum;
		return 0;
	}
	frist++;
	for(i=N;i>=1;i--)
	{
		if(a[i]==a[i-1])
			last++;
		else
			break;
	}
	last++;
	if(a[1]==a[N])
		cout<<(frist+last+frist*last+1);
	else
		cout<<(frist+last+1);

}


#include <iostream>
using namespace std;
int main()
{
	int N,i,j,sum=0;
	cin>>N;
	char a[N+2];
	for(i=1;i<=N;i++)
		cin>>a[i];
	int frist=0,last=0;
	for(i=1;i<=N;i++)
	{
		if(a[i]==a[i+1])
			frist++;
		else
			break;
	}
	if(frist==N-1)
	{
		for(i=1;i<=N;i++)
			sum=sun+i;
		cout<<sum;
		return 0;
	}
	frist++;
	for(i=N;i>=1;i--)
	{
		if(a[i]==a[i-1])
			last++;
		else
			break;
	}
	last++;
	if(a[1]==a[N])
		cout<<(frist+last+frist*last+1);
	else
		cout<<(frist+last+1);

}


#include <iostream>
using namespace std;
int main()
{
	int N,i,j,sum=0;
	cin>>N;
	char a[N+2];
	for(i=1;i<=N;i++)
		cin>>a[i];
	int frist=0,last=0;
	for(i=1;i<N;i++)
	{
		if(a[i]==a[i+1])
			frist++;
		else
			break;
	}
	if(frist==(N-1))
	{
		for(i=1;i<=N;i++)
			sum=sum+i;
		cout<<sum%998244353;
		return 0;
	}
	frist++;
	for(i=N;i>=1;i--)
	{
		if(a[i]==a[i-1])
			last++;
		else
			break;
	}
	last++;
	if(a[1]==a[N])
		cout<<(frist+last+frist*last+1)%998244353;
	else
		cout<<(frist+last+1)%998244353;

}


#include <iostream>
using namespace std;
int main()
{
	int N,i,j,sum=0;
	cin>>N;
	char a[N+2];
	for(i=1;i<=N;i++)
		cin>>a[i];
	int frist=0,last=0;
	for(i=1;i<=N;i++)
	{
		if(a[i]==a[i+1])
			frist++;
		else
			break;
	}
	if(frist==N-1)
	{
		for(i=1;i<=N;i++)
			sum=sum+i;
		cout<<sum;
		return 0;
	}
	frist++;
	for(i=N;i>=1;i--)
	{
		if(a[i]==a[i-1])
			last++;
		else
			break;
	}
	last++;
	if(a[1]==a[N])
		cout<<(frist+last+frist*last+1);
	else
		cout<<(frist+last+1);

}


#include <iostream>
using namespace std;
int main()
{
	int N,i,j,sum=0;
	cin>>N;
	char a[N+1];
	cin>>a;
	long long frist=1,last=1;
	for(i=0;i<N-2;i++)
	{
		if(a[i]==a[i+1])
			frist++;
		else
			break;
	}
	for(i=N-1;i>0;i--)
	{
		if(a[i]==a[i-1])
			last++;
		else
			break;
	}
	if(a[0]==a[N-1])
		cout<<(frist+last+(frist*last)+1)%998244353<<endl;
	else
		cout<<(frist+last+1)%998244353<<endl;

}


#include <iostream>
using namespace std;
int main()
{
	int N,i,j,sum=0;
	cin>>N;
	char a[N+2];
	for(i=1;i<=N;i++)
		cin>>a[i];
	int frist=0,last=0;
	for(i=1;i<N;i++)
	{
		if(a[i]==a[i+1])
			frist++;
		else
			break;
	}
	frist++;
	for(i=N;i>1;i--)
	{
		if(a[i]==a[i-1])
			last++;
		else
			break;
	}
	last++;
	if(a[1]==a[N])
		cout<<(frist+last+(frist*last)+1)%998244353<<endl;
	else
		cout<<(frist+last+1)%998244353<<endl;

}


#include <iostream>
using namespace std;
int main()
{
	int N,i,j,sum=0;
	cin>>N;
	char a[N+2];
	for(i=1;i<=N;i++)
		cin>>a[i];
	int frist=0,last=0;
	for(i=1;i<N;i++)
	{
		if(a[i]==a[i+1])
			frist++;
		else
			break;
	}
	frist++;
	for(i=N;i>1;i--)
	{
		if(a[i]==a[i-1])
			last++;
		else
			break;
	}
	last++;
	if(a[1]==a[N])
		cout<<(frist+last+frist*last+1)%998244353<<endl;
	else
		cout<<(frist+last+1)%998244353<<endl;

}


#include <iostream>
using namespace std;
int main()
{
	int N,i,j,sum=0;
	cin>>N;
	char a[N+1];
	cin>>a;
	int frist=1,last=1;
	for(i=0;i<N-2;i++)
	{
		if(a[i]==a[i+1])
			frist++;
		else
			break;
	}
	for(i=N-1;i>0;i--)
	{
		if(a[i]==a[i-1])
			last++;
		else
			break;
	}
	if(a[0]==a[N-1])
		cout<<(frist+last+(frist*last)+1)%998244353<<endl;
	else
		cout<<(frist+last+1)%998244353<<endl;

}


#include <iostream>
using namespace std;
int main()
{
	int N,i,j,sum=0;
	cin>>N;
	char a[N+2];
	for(i=1;i<=N;i++)
		cin>>a[i];
	int frist=0,last=0;
	for(i=1;i<N;i++)
	{
		if(a[i]==a[i+1])
			frist++;
		else
			break;
	}
	if(frist==(N-1))
	{
		for(i=1;i<=N;i++)
			sum=sum+i;
		cout<<sum%998244353;
		return 0;
	}
	frist++;
	for(i=N;i>=1;i--)
	{
		if(a[i]==a[i-1])
			last++;
		else
			break;
	}
	last++;
	if(a[1]==a[N])
		cout<<(frist+last+frist*last+1)%998244353<<endl;
	else
		cout<<(frist+last+1)%998244353<<endl;

}


#include <iostream>
using namespace std;
int main()
{
	int N,i,j,sum=0;
	cin>>N;
	char a[N+2];
	cin>>a;
	int frist=0,last=0;
	for(i=0;i<N-2;i++)
	{
		if(a[i]==a[i+1])
			frist++;
		else
			break;
	}
	frist++;
	for(i=N-1;i>0;i--)
	{
		if(a[i]==a[i-1])
			last++;
		else
			break;
	}
	last++;
	if(a[1]==a[N])
		cout<<(frist+last+(frist*last)+1)%998244353<<endl;
	else
		cout<<(frist+last+1)%998244353<<endl;

}


#include <iostream>
using namespace std;
int main()
{
	int N,i,j,sum=0;
	cin>>N;
	char a[N+2];
	cin>>a;
	int frist=0,last=0;
	for(i=0;i<N-2;i++)
	{
		if(a[i]==a[i+1])
			frist++;
		else
			break;
	}
	frist++;
	for(i=N-1;i>0;i--)
	{
		if(a[i]==a[i-1])
			last++;
		else
			break;
	}
	last++;
	if(a[0]==a[N-1])
		cout<<(frist+last+(frist*last)+1)%998244353<<endl;
	else
		cout<<(frist+last+1)%998244353<<endl;

}


#include <iostream>
using namespace std;
int main()
{
	int N,i,j,kl;
	cin>>N;
	char a[N+2];
	for(i=1;i<=N;i++)
		cin>>a[i];
	int frist=0,last=0;
	for(i=1;i<=N;i++)
	{
		if(a[i]==a[i+1])
			frist++;
		else
			break;
	}
	frist++;
	for(i=N;i>=1;i--)
	{
		if(a[i]==a[i-1])
			last++;
		else
			break;
	}
	last++;
	if(a[1]==a[N])
		cout<<(frist+last+frist*last+1);
	else
		cout<<(frist+last+1);

}


#include <bits/stdc++.h>
#include <iostream>
#define mod 998244353
#define ll long long
using namespace std;
int main()
{	int n,i;
	cin>>n;
	char a[n];
	cin>>a;
	int li=1;
	for(i=0;i<strlen(a)-1;i++)
	{if(a[i]==a[i+1]) li++;
	else break;}

	int le=1;
	for(i=strlen(a)-1;i>0;i--)
	{
	if(a[i]==a[i-1]) le++;
	else break;
	}

	if(a[0]==a[strlen(a)-1])
	{
	  	int l=strlen(a);
		int ts= (l*(l+1))%mod;
		li= (li*(li+1))%mod;
		le= (le*(le+1))%mod;
		int res=ts-li-le;
		res%=mod;
		cout<<res<<endl;
	}
	else
	{
		cout<<(1+li+le)%mod<<endl;
	}
	return 0;
}


#include <bits/stdc++.h>
#include <iostream>
#define mod 998244353
#define ll long long
using namespace std;
int main()
{	int n,i;
	cin>>n;
	char a[n];
	cin>>a;
	int li=1;
	for(i=0;i<strlen(a)-1;i++)
	{if(a[i]==a[i+1]) li++;
	else break;}

	int le=1;
	for(i=strlen(a)-1;i>0;i--)
	{
	if(a[i]==a[i-1]) le++;
	else break;
	}

	if(a[0]==a[strlen(a)-1])
	{
		int res=li*le;
		res+=li;
		res+=le;
		res+=1;
		cout<<res%mod<<endl;
	}
	else
	{
		cout<<(1+li+le)%mod<<endl;
	}
	return 0;
}


#include <bits/stdc++.h>
#include <iostream>
#define mod 998244353
#define ll long long
using namespace std;
int main()
{	ll n,i,res=0;
	cin>>n;
	string a;
	cin>>a;
	int li=1;
	for(i=0;i<n;i++)
	{
	if(a[i]==a[i+1]) li++;
	else break;
	}

	int le=1;
	for(i=n-1;i>0;i--)
	{
	if(a[i]==a[i-1]) le++;
	else break;
	}

	if(a[0]==a[n-1])
	   res=li*le;
	res+=(1+li+le);
	cout<<res%mod<<endl;
	return 0;
}


#include <bits/stdc++.h>
#include <iostream>
#define mod 998244353
#define ll long long
using namespace std;
int main()
{	int n,i;
	cin>>n;
	char a[n];
	cin>>a;
	ll li=1;
	for(i=0;i<strlen(a)-1;i++)
	{if(a[i]==a[i+1]) li++;
	else break;}

	ll le=1;
	for(i=strlen(a)-1;i>0;i--)
	{
	if(a[i]==a[i-1]) le++;
	else break;
	}

	if(a[0]==a[strlen(a)-1])
	{
		ll res=li*le;
		res+=li;
		res+=le;
		res+=1;
		cout<<res%mod<<endl;
	}
	else
	{
		cout<<(1+li+le)%mod<<endl;
	}
	return 0;
}


#include <bits/stdc++.h>
#include <iostream>
#define mod 998244353
#define ll long long
using namespace std;
int main()
{	ll n,i,res=0;
	cin>>n;
	string a;
	cin>>a;
	ll li=1;
	for(i=0;i<n;i++)
	{
	if(a[i]==a[i+1]) li++;
	else break;
	}

	ll le=1;
	for(i=n-1;i>0;i--)
	{
	if(a[i]==a[i-1]) le++;
	else break;
	}

	if(a[0]==a[n-1])
	   res=li*le;
	res+=(1+li+le);
	cout<<res%mod<<endl;
	return 0;
}


#include <bits/stdc++.h>
#include <iostream>
#define mod 1000000007
#define ll long long
using namespace std;
int main()
{	int n,i;
	cin>>n;
	char a[n];
	cin>>a;
	int li=1;
	for(i=0;i<strlen(a)-1;i++)
	{if(a[i]==a[i+1]) li++;
	else break;}

	int le=1;
	for(i=strlen(a)-1;i>0;i--)
	{
	if(a[i]==a[i-1]) le++;
	else break;
	}

	if(a[0]==a[strlen(a)-1])
	{
	  	int l=strlen(a);
		int ts= (l*(l+1))/2;
		li= (li*(li+1))/2;
		le= (le*(le+1))/2;
		cout<<ts-li-le<<endl;
	}
	else
	{
		cout<<1+li+le<<endl;
	}
	return 0;
}


#include <bits/stdc++.h>
#include <iostream>
#define mod 998244353
#define ll long long
using namespace std;
int main()
{	int n,i;
	cin>>n;
	char a[n];
	cin>>a;
	int li=1;
	for(i=0;i<strlen(a)-1;i++)
	{if(a[i]==a[i+1]) li++;
	else break;}

	int le=1;
	for(i=strlen(a)-1;i>0;i--)
	{
	if(a[i]==a[i-1]) le++;
	else break;
	}

	if(a[0]==a[strlen(a)-1])
	{
		ll res=li*le;
		res+=li;
		res+=le;
		res+=1;
		cout<<res%mod<<endl;
	}
	else
	{
		cout<<(1+li+le)%mod<<endl;
	}
	return 0;
}


#include <bits/stdc++.h>
#include <iostream>
#define mod 998244353
#define ll long long
using namespace std;
int main()
{	int n,i;
	cin>>n;
	char a[n];
	cin>>a;
	int li=1;
	for(i=0;i<strlen(a)-1;i++)
	{if(a[i]==a[i+1]) li++;
	else break;}

	int le=1;
	for(i=strlen(a)-1;i>0;i--)
	{
	if(a[i]==a[i-1]) le++;
	else break;
	}

	if(a[0]==a[strlen(a)-1])
	{
	  	int l=strlen(a);
		int ts= (l*(l+1))%mod;
		li= (li*(li+1))%mod;
		le= (le*(le+1))%mod;
		int res=ts-li-le;
		res%=mod;
		cout<<res/2<<endl;
	}
	else
	{
		cout<<(1+li+le)%mod<<endl;
	}
	return 0;
}


#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

using namespace __gnu_pbds;

#define ll long long int
#define li long int
using namespace std;

typedef vector<long long int> vi;
typedef pair<ll, ll> pi;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;

#define EB emplace_back
#define REP(i, x, y) for(long long int i=x ; i<y ; i++)
#define F first
#define PB push_back
#define S second
#define MP make_pair
#define MT make_tuple
#define INF 9999999
#define MOD 1000000007
ll power(ll x, unsigned ll y, ll p)
{
    ll res = 1;      // Initialize result

    x = x % p;  // Update x if it is more than or
                // equal to p

    while (y > 0)
    {
        // If y is odd, multiply x with result
        if (y & 1)
            res = (res*x) % p;

        // y must be even now
        y = y>>1; // y = y/2
        x = (x*x) % p;
    }
    return res;
}

int main()
{
    ios::sync_with_stdio(0);
    ll n;
    cin>>n;
    string s;
    cin>>s;
    ll ans=0;
    char c1=s[0];
    char x=c1;
    ll j=0;

    while(x==c1&& j<=n-1)
    {
        j++;
        x=s[j];
    }

    char c2=s[n-1];

    if(c2==c1)
    {
       if(j==n)
       {

           ans+=((n*(n+1))/2)%998244353;
       }
       else
       {

        ll t=n-1;
        char y=c2;
        while(y==c2 && t>=0)
        {
            t--;
            y=s[t];

        }
        t++;
        ll right=n-t;
        ll left=j;

        //cout<<left<<" "<<right<<"\n";
        ans+=2*(right%998244353)*(left%998244353);

       }

    }

    else
    {

        ll t=n-1;
        char y=c2;
        while(y==c2 && t>=0)
        {
            t--;
            y=s[t];

        }
        t++;
        ll right=n-t;
        ll left=j;

        ans+= ((left+1)%998244353+right%998244353)%998244353;

    }
    cout<<ans<<'\n';

    return 0;
}


#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

using namespace __gnu_pbds;

#define ll long long int
#define li long int
using namespace std;

typedef vector<long long int> vi;
typedef pair<ll, ll> pi;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;

#define EB emplace_back
#define REP(i, x, y) for(long long int i=x ; i<y ; i++)
#define F first
#define PB push_back
#define S second
#define MP make_pair
#define MT make_tuple
#define INF 9999999
#define MOD 1000000007
ll power(ll x, unsigned ll y, ll p)
{
    ll res = 1;      // Initialize result

    x = x % p;  // Update x if it is more than or
                // equal to p

    while (y > 0)
    {
        // If y is odd, multiply x with result
        if (y & 1)
            res = (res*x) % p;

        // y must be even now
        y = y>>1; // y = y/2
        x = (x*x) % p;
    }
    return res;
}

int main()
{
    ios::sync_with_stdio(0);
    ll n;
    cin>>n;
    string s;
    cin>>s;
    ll ans=0;
    char c1=s[0];
    char x=c1;
    ll j=0;

    while(x==c1&& j<=n-1)
    {
        j++;
        x=s[j];
    }

    char c2=s[n-1];
    if(c2==c1)
    {
       if(j==n)
       {
           ans+=((n*(n+1))/2)%998244353;
       }
       else
       {

        ll t=n-1;
        char y=c2;
        while(y==c2 && t>=0)
        {
            t--;
            y=s[t];

        }
        t++;
        ll right=n-t;
        ll left=j;

        ans+=power(2,left,998244353)+power(2,right,998244353);

       }

    }

    else
    {
        ll t=n-1;
        char y=c2;
        while(y==c2 && t>=0)
        {
            t--;
            y=s[t];

        }
        t++;
        ll right=n-t;
        ll left=j;

        ans+= (left+1)%998244353+right%998244353;

    }
    cout<<ans<<'\n';

    return 0;
}


#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

using namespace __gnu_pbds;

#define ll long long int
#define li long int
using namespace std;

typedef vector<long long int> vi;
typedef pair<ll, ll> pi;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;

#define EB emplace_back
#define REP(i, x, y) for(long long int i=x ; i<y ; i++)
#define F first
#define PB push_back
#define S second
#define MP make_pair
#define MT make_tuple
#define INF 9999999
#define MOD 1000000007

int main()
{
    ios::sync_with_stdio(0);
    ll n;
    cin>>n;
    string s;
    cin>>s;
    ll ans=0;
    char c1=s[0];
    char x=c1;
    ll j=0;

    while(x==c1&& j<=n-1)
    {
        j++;
        x=s[j];
    }

    char c2=s[n-1];
    if(c2==c1)
    {
       if(j==n-1)
       {
           ans+=0;
       }
       else
       {

        ll t=n-1;
        char y=c2;
        while(y==c2 && t>=0)
        {
            t--;
            y=s[t];

        }
        t++;
        ll right=n-t;
        ll left=j;

        ans+=fmod(pow(2,left),998244353)+fmod(pow(2,right),998244353);

       }

    }

    else
    {
        ll t=n-1;
        char y=c2;
        while(y==c2 && t>=0)
        {
            t--;
            y=s[t];

        }
        t++;
        ll right=n-t;
        ll left=j;

        ans+= (left+1)%998244353+right%998244353;

    }
    cout<<ans<<'\n';

    return 0;
}


#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

using namespace __gnu_pbds;

#define ll long long int
#define li long int
using namespace std;

typedef vector<long long int> vi;
typedef pair<ll, ll> pi;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;

#define EB emplace_back
#define REP(i, x, y) for(long long int i=x ; i<y ; i++)
#define F first
#define PB push_back
#define S second
#define MP make_pair
#define MT make_tuple
#define INF 9999999
#define MOD 1000000007
ll power(ll x, unsigned ll y, ll p)
{
    ll res = 1;      // Initialize result

    x = x % p;  // Update x if it is more than or
                // equal to p

    while (y > 0)
    {
        // If y is odd, multiply x with result
        if (y & 1)
            res = (res*x) % p;

        // y must be even now
        y = y>>1; // y = y/2
        x = (x*x) % p;
    }
    return res;
}

int main()
{
    ios::sync_with_stdio(0);
    ll n;
    cin>>n;
    string s;
    cin>>s;
    ll ans=0;
    char c1=s[0];
    char x=c1;
    ll j=0;

    while(x==c1&& j<=n-1)
    {
        j++;
        x=s[j];
    }

    char c2=s[n-1];

    if(c2==c1)
    {
       if(j==n)
       {

           ans+=((n*(n+1))/2)%998244353;
       }
       else
       {

        ll t=n-1;
        char y=c2;
        while(y==c2 && t>=0)
        {
            t--;
            y=s[t];

        }
        t++;
        ll right=n-t;
        ll left=j;

        //cout<<left<<" "<<right<<"\n";
        if(left!=1&&right!=1)
        ans+=((right%998244353)*(left%998244353)+left%998244353 +right%998244353)%998244353;

        else if(left==1&&right!=1)
            ans+=((right%998244353)*2 +right)%998244353;

            else
                ans+=((left%998244353)*2 +left)%998244353;

       }

    }

    else
    {

        ll t=n-1;
        char y=c2;
        while(y==c2 && t>=0)
        {
            t--;
            y=s[t];

        }
        t++;
        ll right=n-t;
        ll left=j;

        ans+= ((left+1)%998244353+right%998244353)%998244353;

    }
    cout<<ans<<'\n';

    return 0;
}


#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

using namespace __gnu_pbds;

#define ll long long int
#define li long int
using namespace std;

typedef vector<long long int> vi;
typedef pair<ll, ll> pi;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;

#define EB emplace_back
#define REP(i, x, y) for(long long int i=x ; i<y ; i++)
#define F first
#define PB push_back
#define S second
#define MP make_pair
#define MT make_tuple
#define INF 9999999
#define MOD 1000000007
ll power(ll x, unsigned ll y, ll p)
{
    ll res = 1;      // Initialize result

    x = x % p;  // Update x if it is more than or
                // equal to p

    while (y > 0)
    {
        // If y is odd, multiply x with result
        if (y & 1)
            res = (res*x) % p;

        // y must be even now
        y = y>>1; // y = y/2
        x = (x*x) % p;
    }
    return res;
}

int main()
{
    ios::sync_with_stdio(0);
    ll n;
    cin>>n;
    string s;
    cin>>s;
    ll ans=0;
    char c1=s[0];
    char x=c1;
    ll j=0;

    while(x==c1&& j<=n-1)
    {
        j++;
        x=s[j];
    }

    char c2=s[n-1];
    if(c2==c1)
    {
       if(j==n)
       {
           ans+=((n*(n+1))/2)%998244353;
       }
       else
       {

        ll t=n-1;
        char y=c2;
        while(y==c2 && t>=0)
        {
            t--;
            y=s[t];

        }
        t++;
        ll right=n-t;
        ll left=j;

        ans+=(power(2,left,998244353)+power(2,right,998244353))%998244353;

       }

    }

    else
    {
        ll t=n-1;
        char y=c2;
        while(y==c2 && t>=0)
        {
            t--;
            y=s[t];

        }
        t++;
        ll right=n-t;
        ll left=j;

        ans+= ((left+1)%998244353+right%998244353)%998244353;

    }
    cout<<ans<<'\n';

    return 0;
}


#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

using namespace __gnu_pbds;

#define ll long long int
#define li long int
using namespace std;

typedef vector<long long int> vi;
typedef pair<ll, ll> pi;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;

#define EB emplace_back
#define REP(i, x, y) for(long long int i=x ; i<y ; i++)
#define F first
#define PB push_back
#define S second
#define MP make_pair
#define MT make_tuple
#define INF 9999999
#define MOD 1000000007
ll power(ll x, unsigned ll y, ll p)
{
    ll res = 1;      // Initialize result

    x = x % p;  // Update x if it is more than or
                // equal to p

    while (y > 0)
    {
        // If y is odd, multiply x with result
        if (y & 1)
            res = (res*x) % p;

        // y must be even now
        y = y>>1; // y = y/2
        x = (x*x) % p;
    }
    return res;
}

int main()
{
    ios::sync_with_stdio(0);
    ll n;
    cin>>n;
    string s;
    cin>>s;
    ll ans=0;
    char c1=s[0];
    char x=c1;
    ll j=0;

    while(x==c1&& j<=n-1)
    {
        j++;
        x=s[j];
    }

    char c2=s[n-1];
    if(c2==c1)
    {
       if(j==n)
       {
           ans+=power(2,j,998244353);
       }
       else
       {

        ll t=n-1;
        char y=c2;
        while(y==c2 && t>=0)
        {
            t--;
            y=s[t];

        }
        t++;
        ll right=n-t;
        ll left=j;

        ans+=power(2,left,998244353)+power(2,right,998244353);

       }

    }

    else
    {
        ll t=n-1;
        char y=c2;
        while(y==c2 && t>=0)
        {
            t--;
            y=s[t];

        }
        t++;
        ll right=n-t;
        ll left=j;

        ans+= (left+1)%998244353+right%998244353;

    }
    cout<<ans<<'\n';

    return 0;
}


#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

using namespace __gnu_pbds;

#define ll long long int
#define li long int
using namespace std;

typedef vector<long long int> vi;
typedef pair<ll, ll> pi;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;

#define EB emplace_back
#define REP(i, x, y) for(long long int i=x ; i<y ; i++)
#define F first
#define PB push_back
#define S second
#define MP make_pair
#define MT make_tuple
#define INF 9999999
#define MOD 998244353
ll power(ll x, unsigned ll y, ll p)
{
    ll res = 1;      // Initialize result

    x = x % p;  // Update x if it is more than or
                // equal to p

    while (y > 0)
    {
        // If y is odd, multiply x with result
        if (y & 1)
            res = (res*x) % p;

        // y must be even now
        y = y>>1; // y = y/2
        x = (x*x) % p;
    }
    return res;
}

int main()
{
    ios::sync_with_stdio(0);
    ll n;
    cin>>n;
    string s;
    cin>>s;
    ll ans=0;
    char c1=s[0];
    char x=c1;
    ll j=0;

    while(x==c1&& j<=n-1)
    {
        j++;
        x=s[j];
    }

        ll t=n-1;

        char c2=s[n-1];

        char y=c2;
        while(y==c2 && t>=0)
        {
            t--;
            y=s[t];

        }
        t++;
        ll right=n-t;
        ll left=j;
        //cout<<right<<" "<<left<<" "<<t<<" "<<j<<" ";

    if(c2==c1)
    {
      ans+=(left%MOD*right%MOD+left%MOD+right%MOD+1)%MOD;
    }
    else
        ans=(left+right+1)%MOD;

    cout<<ans<<'\n';

    return 0;
}


#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

using namespace __gnu_pbds;

#define ll long long int
#define li long int
using namespace std;

typedef vector<long long int> vi;
typedef pair<ll, ll> pi;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;

#define EB emplace_back
#define REP(i, x, y) for(long long int i=x ; i<y ; i++)
#define F first
#define PB push_back
#define S second
#define MP make_pair
#define MT make_tuple
#define INF 9999999
#define MOD 1000000007
ll power(ll x, unsigned ll y, ll p)
{
    ll res = 1;      // Initialize result

    x = x % p;  // Update x if it is more than or
                // equal to p

    while (y > 0)
    {
        // If y is odd, multiply x with result
        if (y & 1)
            res = (res*x) % p;

        // y must be even now
        y = y>>1; // y = y/2
        x = (x*x) % p;
    }
    return res;
}

int main()
{
    ios::sync_with_stdio(0);
    ll n;
    cin>>n;
    string s;
    cin>>s;
    ll ans=0;
    char c1=s[0];
    char x=c1;
    ll j=0;

    while(x==c1&& j<=n-1)
    {
        j++;
        x=s[j];
    }

    char c2=s[n-1];

    if(c2==c1)
    {
       if(j==n)
       {

           ans+=((n*(n+1))/2)%998244353;
       }
       else
       {

        ll t=n-1;
        char y=c2;
        while(y==c2 && t>=0)
        {
            t--;
            y=s[t];

        }
        t++;
        ll right=n-t;
        ll left=j;

        //cout<<left<<" "<<right<<"\n";
        ans+=((left+right)*2)%998244353;

       }

    }

    else
    {

        ll t=n-1;
        char y=c2;
        while(y==c2 && t>=0)
        {
            t--;
            y=s[t];

        }
        t++;
        ll right=n-t;
        ll left=j;

        ans+= ((left+1)%998244353+right%998244353)%998244353;

    }
    cout<<ans<<'\n';

    return 0;
}


#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

using namespace __gnu_pbds;

#define ll long long int
#define li long int
using namespace std;

typedef vector<long long int> vi;
typedef pair<ll, ll> pi;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;

#define EB emplace_back
#define REP(i, x, y) for(long long int i=x ; i<y ; i++)
#define F first
#define PB push_back
#define S second
#define MP make_pair
#define MT make_tuple
#define INF 9999999
#define MOD 1000000007
ll power(ll x, unsigned ll y, ll p)
{
    ll res = 1;      // Initialize result

    x = x % p;  // Update x if it is more than or
                // equal to p

    while (y > 0)
    {
        // If y is odd, multiply x with result
        if (y & 1)
            res = (res*x) % p;

        // y must be even now
        y = y>>1; // y = y/2
        x = (x*x) % p;
    }
    return res;
}

int main()
{
    ios::sync_with_stdio(0);
    ll n;
    cin>>n;
    string s;
    cin>>s;
    ll ans=0;
    char c1=s[0];
    char x=c1;
    ll j=0;

    while(x==c1&& j<=n-1)
    {
        j++;
        x=s[j];
    }

        ans+=j;

        ll t=n-1;

        char c2=s[n-1];

        char y=c2;
        while(y==c2 && t>=0)
        {
            t--;
            y=s[t];

        }
        t++;
        ll right=n-t;
        ll left=j;
        //cout<<right<<" "<<left<<" "<<t<<" "<<j<<" ";
        ans+=right;

    if(c2==c1)
    {
      ans+=j*right+1;
    }

    cout<<ans<<'\n';

    return 0;
}


#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

using namespace __gnu_pbds;

#define ll long long int
#define li long int
using namespace std;

typedef vector<long long int> vi;
typedef pair<ll, ll> pi;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;

#define EB emplace_back
#define REP(i, x, y) for(long long int i=x ; i<y ; i++)
#define F first
#define PB push_back
#define S second
#define MP make_pair
#define MT make_tuple
#define INF 9999999
#define MOD 1000000007

int main()
{
    ios::sync_with_stdio(0);
    ll n;
    cin>>n;
    string s;
    cin>>s;
    ll ans=0;
    char c1=s[0];
    char x=c1;
    ll j=0;

    while(x==c1&& j<=n-1)
    {
        j++;
        x=s[j];
    }

    char c2=s[n-1];
    if(c2==c1)
    {
       if(j==n)
       {
           ans+=fmod(pow(2,j),998244353);
       }
       else
       {

        ll t=n-1;
        char y=c2;
        while(y==c2 && t>=0)
        {
            t--;
            y=s[t];

        }
        t++;
        ll right=n-t;
        ll left=j;

        ans+=fmod(pow(2,left),998244353)+fmod(pow(2,right),998244353);

       }

    }

    else
    {
        ll t=n-1;
        char y=c2;
        while(y==c2 && t>=0)
        {
            t--;
            y=s[t];

        }
        t++;
        ll right=n-t;
        ll left=j;

        ans+= (left+1)%998244353+right%998244353;

    }
    cout<<ans<<'\n';

    return 0;
}