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

int n;

int main()
{
    cin >> n;
    int soft = 0;
    int hard = 0;
    while (n--) {
        string s, t;
        cin >> s >> t;
        if (t=="soft") soft+=1;
        else hard+=1;
    }
    for (int i=0;;i++) {
        if (i*i/2 >= soft && i*i-i*i/2 >= hard) {
            printf("%d\n", i);
            break;
        }
        if (i*i/2 >= hard && i*i-i*i/2 >= soft) {
            printf("%d\n", i);
            break;
        }
    }
}


#include <bits/stdc++.h>

using namespace std;
string s;
int n,i,nr1,nr2,nra,nrb,a[1001][1001],siz,j;
int main()
{

    cin>>n;
    for(i=1;i<=n;++i)
    {
        cin>>s;
        cin>>s;
        if(s=="soft") nr1++;
        else if(s=="hard") nr2++;
    }

    nr1 = max(nr1,nr2);

    while(1)
    {
        for(siz=1;;++siz)
        {
            nra = nrb = 0;
            n = siz;
            memset(a,0,sizeof(a));

            for(i=1;i<=n;++i)
                a[i][0] = i%2;

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

            for(i=1;i<=n;++i)
            {
                for(j=1;j<=n;++j)
                    if(a[i][j] == 1) nra ++;
                else nrb++;
            }

            if(nr1 <= max(nra,nrb)){

            cout<<siz;
            return 0;}
        }
    }
    return 0;
}


#include <bits/stdc++.h>

using namespace std;
string s;
int n,i,nr1,nr2,nra,nrb,a[1001][1001],siz,j;
int main()
{

    cin>>n;
    for(i=1;i<=n;++i)
    {
        cin>>s;
        cin>>s;
        if(s=="soft") nr1++;
        else if(s=="hard") nr2++;
    }

    while(1)
    {
        for(siz=1;;++siz)
        {
            nra = nrb = 0;
            n = siz;
            memset(a,0,sizeof(a));

            for(i=1;i<=n;++i)
                a[i][0] = i%2;

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

            for(i=1;i<=n;++i)
            {
                for(j=1;j<=n;++j)
                    if(a[i][j] == 1) nra ++;
                else nrb++;
            }

            if((nra >= nr1 && nrb >=nr2)  || nra >=nr2 && nrb>=nr1){

            cout<<siz;
            return 0;}
        }
    }
    return 0;
}


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

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef complex<ld> pt;
typedef vector<pt> pol;
typedef mt19937 RNG;

const char nl = '\n';
const ll INF = 0x3f3f3f3f;
const ll INFLL = 0x3f3f3f3f3f3f3f3f;
const ll MOD = 1e9+7;
const ld EPS = 1e-10;

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	cout << fixed << setprecision(10);

	int n;
	cin >> n;

	string s, t;
	set<char> let;
	for (int i = 0; i < n; i++) {
		cin >> s >> t;
		let.insert(s.back());
	}

	vector<int> v;
	for (char c : let) {
		v.push_back(c);
	}

	int ans = 1;
	int cnt = 1;
	for (int i = 1; i < v.size(); i++) {
		if (v[i] == v[i-1] + 1) {
			cnt++;
		} else {
			cnt = 1;
		}
		ans = max(ans, cnt);
	}
	cout << ans << nl;

	return 0;
}


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

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef complex<ld> pt;
typedef vector<pt> pol;
typedef mt19937 RNG;

const char nl = '\n';
const ll INF = 0x3f3f3f3f;
const ll INFLL = 0x3f3f3f3f3f3f3f3f;
const ll MOD = 1e9+7;
const ld EPS = 1e-10;

int next_square(int n) {
	int res = sqrt(n);
	while (res*res < n) res++;
	return res;
}

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	cout << fixed << setprecision(10);

	int n;
	cin >> n;

	int hard, soft;
	hard = soft = 0;

	string s, t;
	for (int i = 0; i < n; i++) {
		cin >> s >> t;
		if (t == "hard") hard++;
		else soft++;
	}

	if (hard == soft) cout << next_square(2*hard) << nl;
	else cout << next_square(2*max(hard,soft)-1) << nl;

	return 0;
}


#include <iostream>
#include <vector>
#include <cstdio>
#include <map>
#include <algorithm>
#include <cmath>
#include <string>
#include <cstring>
#include <set>
#include <queue>
#include <unordered_set>
#include <complex>
#include <unordered_map>
#include <bitset>
#include <ctime>
#include <cassert>
#include <random>

#define sz(a) (int)((a).size())

using namespace std;

mt19937 rnd(239);

typedef long long ll;
typedef long double ld;

int solve()
{
    ios::sync_with_stdio(0);
    int n;
    cin >> n;
    int a = 0, b = 0;
    for (int i = 0; i < n; i++)
    {
        string x, y;
        cin >> x >> y;
        if (y[0] == 's')
            a++;
        else
            b++;
    }
    if (a < b)
        swap(a, b);
    int i = 1;
    while (true)
    {
        int x = 0, y = 0;
        for (int a = 0; a < i; a++)
            for (int b = 0; b < i; b++)
                if (a % 2 == b % 2)
                    x++;
                else
                    y++;
        if (x >= a && y >= b)
            break;
        i++;
    }
    cout << i << endl;
    return 1;
}

int32_t main()
{
    #ifdef ONPC
        freopen("in.txt", "r", stdin);
    #endif
    int T = 100;
    //cin >> T;
    for (int i = 1; i <= T; i++)
    {
        #ifdef ONPC
            cerr << "Test #" << i << ":\n";
        #endif
        if (solve())
            break;
        #ifdef ONPC
            cerr << "_______________________________________________" << endl;
        #endif
    }
    #ifdef ONPC
        cerr << endl << "finished in " << clock() * 1000LL / CLOCKS_PER_SEC << " ms" << endl;
    #endif
    return 0;
}


#include <iostream>
#include <vector>
#include <cstdio>
#include <map>
#include <algorithm>
#include <cmath>
#include <string>
#include <cstring>
#include <set>
#include <queue>
#include <unordered_set>
#include <complex>
#include <unordered_map>
#include <bitset>
#include <ctime>
#include <cassert>
#include <random>

#define sz(a) (int)((a).size())

using namespace std;

mt19937 rnd(239);

typedef long long ll;
typedef long double ld;

int solve()
{
    ios::sync_with_stdio(0);
    int n;
    cin >> n;
    int a = 0, b = 0;
    for (int i = 0; i < n; i++)
    {
        string x, y;
        cin >> x >> y;
        if (y[0] == 's')
            a++;
        else
            b++;
    }
    int i = 1;
    while (true)
    {
        int x = 0, y = 0;
        for (int a = 0; a < i; a++)
            for (int b = 0; b < i; b++)
                if (a % 2 == b % 2)
                    x++;
                else
                    y++;
        if (x >= a && y >= b)
            break;
        i++;
    }
    cout << i << endl;
    return 1;
}

int32_t main()
{
    #ifdef ONPC
        freopen("in.txt", "r", stdin);
    #endif
    int T = 100;
    //cin >> T;
    for (int i = 1; i <= T; i++)
    {
        #ifdef ONPC
            cerr << "Test #" << i << ":\n";
        #endif
        if (solve())
            break;
        #ifdef ONPC
            cerr << "_______________________________________________" << endl;
        #endif
    }
    #ifdef ONPC
        cerr << endl << "finished in " << clock() * 1000LL / CLOCKS_PER_SEC << " ms" << endl;
    #endif
    return 0;
}


#include <iostream>
#include <vector>
#include <cstdio>
#include <map>
#include <algorithm>
#include <cmath>
#include <string>
#include <cstring>
#include <set>
#include <queue>
#include <unordered_set>
#include <complex>
#include <unordered_map>
#include <bitset>
#include <ctime>
#include <cassert>
#include <random>

#define sz(a) (int)((a).size())

using namespace std;

mt19937 rnd(239);

typedef long long ll;
typedef long double ld;

int solve()
{
    ios::sync_with_stdio(0);
    int n;
    cin >> n;
    int a = 0, b = 0;
    for (int i = 0; i < n; i++)
    {
        string x, y;
        cin >> x >> y;
        if (y[0] == 's')
            a++;
        else
            b++;
    }
    if (a > b)
        swap(a, b);
    int i = 1;
    while (true)
    {
        int x = 0, y = 0;
        for (int a = 0; a < i; a++)
            for (int b = 0; b < i; b++)
                if (a % 2 == b % 2)
                    x++;
                else
                    y++;
        if (x >= a && y >= b)
            break;
        i++;
    }
    cout << i << endl;
    return 1;
}

int32_t main()
{
    #ifdef ONPC
        freopen("in.txt", "r", stdin);
    #endif
    int T = 100;
    //cin >> T;
    for (int i = 1; i <= T; i++)
    {
        #ifdef ONPC
            cerr << "Test #" << i << ":\n";
        #endif
        if (solve())
            break;
        #ifdef ONPC
            cerr << "_______________________________________________" << endl;
        #endif
    }
    #ifdef ONPC
        cerr << endl << "finished in " << clock() * 1000LL / CLOCKS_PER_SEC << " ms" << endl;
    #endif
    return 0;
}


#include <bits/stdc++.h>

#define ll long long
#define mod 1000000007

using namespace std;

map<string,int> m;

int main()
{
    int n;
    cin >> n;

    string x,y;

    for(int i=0;i<n;i++)
    {
        cin >> x >> y;
        m[y]++;
    }

    cout << max(m["hard"],m["soft"]) - 2 << endl;
}


#include <bits/stdc++.h>

#define ll long long
#define mod 1000000007

using namespace std;

map<string,int> m;

int main()
{
    int n;
    cin >> n;

    string x,y;

    for(int i=0;i<n;i++)
    {
        cin >> x >> y;
        m[y]++;
    }

    int t1,t2,temp,temp1;
    t1 = m["hard"];
    t2 = m["soft"];

    if(t1 > t2)
    {
        temp = t1;
        t1 = t2;
        t2 = temp;
    }

    for(int i=1;i<100;i++)
    {
        temp = i*i;
        temp1 = temp/2;
        temp -= temp1;

        if(temp1 >= t1 && temp >= t2)
        {
            cout << i << endl;
            return 0;
        }
    }
}


#include <bits/stdc++.h>
#ifdef JLOCAL
#include "stress.h"
#endif
using namespace std;

#define rep(i, z, n) for (int i = (z); i < int(n); ++i)
#define repr(i, n, z) for (int i = int(n) - 1; i >= (z); --i)
#define shl(n) (1 << (n))
#define hbit(n, i) (((n) >> (i)) & 1)

#define STRESS 0
using lint = long long;
template <typename T> using vc = std::vector<T>;

void solve(istream& cin, ostream& cout) {
    int n;
    cin >> n;
    int c1 = 0, c2 = 0;
    rep(i, 0, n) {
        string s, t;
        cin >> s >> t;
        if (t == "hard") {
            c1++;
        } else {
            c2++;
        }
    }
    int m = max(c1, c2);
    rep(i, 1, 1000) {
        int k = (i * i + 1) / 2;
        if (k >= m) {
            cout << i;
            return;
        }
    }
}

int main() {
#if !defined(JLOCAL) || !STRESS
#ifdef JLOCAL
    freopen("input.txt", "r", stdin);
#endif
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    solve(cin, cout);
#else
    srand();
    for (int ti = 0; ti < 100; ti++) {
        stress::gen();
        stress::stupid();
        ifstream in("input.txt");
        ofstream out("output.txt");
        solve(in, out);
        out.flush();
        stress::check();
    }
    cout << "ok" << endl;
#endif
    return 0;
}


#include <bits/stdc++.h>
#ifdef JLOCAL
#include "stress.h"
#endif
using namespace std;

#define rep(i, z, n) for (int i = (z); i < int(n); ++i)
#define repr(i, n, z) for (int i = int(n) - 1; i >= (z); --i)
#define shl(n) (1 << (n))
#define hbit(n, i) (((n) >> (i)) & 1)

#define STRESS 0
using lint = long long;
template <typename T> using vc = std::vector<T>;

void solve(istream& cin, ostream& cout) {
    int n;
    cin >> n;
    int c1 = 0, c2 = 0;
    rep(i, 0, n) {
        string s, t;
        cin >> s >> t;
        if (t == "soft") {
            c1++;
        } else {
            c2++;
        }
    }
    rep(i, 1, 1000) {
        int k1 = (i * i + 1) / 2;
        int k2 = i * i - k1;
        if (k1 >= c1 && k2 >= c2) {
            cout << i;
            return;
        }
    }
    assert(false);
}

int main() {
#if !defined(JLOCAL) || !STRESS
#ifdef JLOCAL
    freopen("input.txt", "r", stdin);
#endif
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    solve(cin, cout);
#else
    srand();
    for (int ti = 0; ti < 100; ti++) {
        stress::gen();
        stress::stupid();
        ifstream in("input.txt");
        ofstream out("output.txt");
        solve(in, out);
        out.flush();
        stress::check();
    }
    cout << "ok" << endl;
#endif
    return 0;
}


#include <bits/stdc++.h>
#ifdef JLOCAL
#include "stress.h"
#endif
using namespace std;

#define rep(i, z, n) for (int i = (z); i < int(n); ++i)
#define repr(i, n, z) for (int i = int(n) - 1; i >= (z); --i)
#define shl(n) (1 << (n))
#define hbit(n, i) (((n) >> (i)) & 1)

#define STRESS 0
using lint = long long;
template <typename T> using vc = std::vector<T>;

void solve(istream& cin, ostream& cout) {
    int n;
    cin >> n;
    int c1 = 0, c2 = 0;
    rep(i, 0, n) {
        string s, t;
        cin >> s >> t;
        if (t == "soft") {
            c1++;
        } else {
            c2++;
        }
    }
    rep(i, 1, 1000) {
        int k1 = (i * i + 1) / 2;
        int k2 = i * i - k1;
        if (k1 >= max(c1, c2) && k2 >= min(c1, c2)) {
            cout << i;
            return;
        }
    }
    assert(false);
}

int main() {
#if !defined(JLOCAL) || !STRESS
#ifdef JLOCAL
    freopen("input.txt", "r", stdin);
#endif
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    solve(cin, cout);
#else
    srand();
    for (int ti = 0; ti < 100; ti++) {
        stress::gen();
        stress::stupid();
        ifstream in("input.txt");
        ofstream out("output.txt");
        solve(in, out);
        out.flush();
        stress::check();
    }
    cout << "ok" << endl;
#endif
    return 0;
}


#include <map>
#include <list>
#include <cmath>
#include <ctime>
#include <queue>
#include <stack>
#include <string>
#include <vector>
#include <iostream>
#include <algorithm>
#include <utility>
#include<bits/stdc++.h>

#define FOR(i,a,b) for(int i=a;i<b;i++)
#define gi(x) scanf("%d",&x)
#define gi2(x,y) scanf("%d%d",&x,&y)
#define gi3(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define giarr(arr,n) FOR(i,0,n) gi(arr[i]);
#define gll(x) scanf("%lld",&x)
#define gll2(x,y) scanf("%lld%lld",&x,&y)
#define gll3(x,y,z) scanf("%lld%lld%lld",&x,&y,&y)
#define gllarr(arr,n) FOR(i,0,n) gll(arr[i]);
#define gd(x) scanf("%lf",&x)
#define gs(x) cin>>s
#define pb push_back
#define ff first
#define ss second
#define mp make_pair
#define mod 1000000007
#define deb(x) cout<<#x<<" : "<<x<<endl;
#define debug(x,y) cout<<#x<<" : "<<x<<"\t"<<#y<<" : "<<y<<endl;
#define all(x) x.begin(),x.end()
#define vi vector<int>
#define vll vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define nax 1000010
//#define vi vector<int>
typedef long long ll;
//ll co1,co2;

using namespace std;

int maxarr(vi &arr);
int minarr(vi &arr);
long long modulo(long long base,long long exponent,long long modulus);
long long choose(ll n,ll k);
bool isprime(ll n);
ll inverse(ll a,ll m);
ll fastmult(ll a,ll b,ll c);
vll a(nax);
vll prime;
ll sum[nax];
vector<bool> aprime(nax);
void setprime();
ll divCeil(ll a, ll b);
ll arrceil(vll a,ll k);

void build()
{

}

int main(){

    ll n;
    cin>>n;
    ll s=0,h=0;
    ll x;
    FOR(i,0,n)
    {
    	string s1,s2;
    	cin>>s1;
    	cin>>s2;

    	if(s2=="hard")
    		h++;
    	else
    		s++;
    }
    x=max(h,s);
    ll ans=0;

    FOR(i,1,100)
    {
    	ll temp=i*i;
    	if(temp%2!=0)
    		temp=temp/2 +1;
    	else
    		temp=temp/2;

    	if(temp>=x && (s+h)<=(i*i) )
    	{
    		ans=i;
    		break;
    	}

    }
    cout<<ans;

    build();

return 0;
}

int maxarr(vi &arr)
{
    int maxi=INT_MIN;
    FOR(i,0,arr.size())  maxi=max(arr[i],maxi);

    return maxi;

}

int minarr(vi &arr)
{
    int mini=INT_MAX;
    FOR(i,0,arr.size()) mini=min(arr[i],mini);
    return mini;
}

long long modulo(long long base,long long exponent,long long modulus)
{
    if(modulus ==1)
        return 0;

    long long result=1;
    base=base % modulus;
    while(exponent>0)
    {
        if(exponent%2==1)
        {
            result=(result*base) % modulus;

        }
        exponent=exponent>>1;
        base = (base*base) % modulus;
    }
    return result;
}

long long choose(ll n,ll k)
{
    if(k==0)  return 1;
    return (n* choose(n-1,k-1))/k;
}

bool isprime(ll n)
{
    for(ll i=2;i*i<=n;i++)
    {
        if(n%i==0)
            return false;
    }
    return true;
}

void EE(ll a,ll b,ll &co1,ll &co2)
{
    if(a%b==0)
    {
        co1=0;
        co2=1;
        return;
    }
    EE(b,a%b,co1,co2);
    ll temp=co1;
    co1=co2;
    co2=temp-co2*(a/b);
}

ll inverse(ll a,ll m)
{
    ll x,y;
    EE(a,m,x,y);
    if(x<0) x+=m;
    return x;
}

ll fastmult(ll a,ll b,ll c)
{
    if(b==0)
        return 0;

    long long res=fastmult(a,b>>1,c);
    res=(res+res) % c;
    if(b%2==1)
    {
        res=(res+a)%c;
    }
    return res;
}

void setprime()
{
    aprime[0]=true;
    aprime[1]=true;

    for(int i=2;i*i<nax;i++)
    {
       // cout<<"HIII";
        if(aprime[i]==false)
        {
           // prime.pb(i);

            for(int j=i*2;j<nax;j+=i)
            {
                aprime[j]=true;
            }
        }
    }
}

ll divCeil(ll a, ll b) { return (a + b - 1) / b; }

ll arrceil(vll a,ll k)
{
    ll n=a.size();
    ll low=0;
    ll high=n-1;

    if(a[0]>k)
        return -1;
    while(low<high)

    {
       // debug(low,high);
        ll mid=(low+high+1)/2;
        if(a[mid]<=k)
            low=mid;
        else
            high=mid-1;
    }
    return low;
}


#include <map>
#include <list>
#include <cmath>
#include <ctime>
#include <queue>
#include <stack>
#include <string>
#include <vector>
#include <iostream>
#include <algorithm>
#include <utility>
#include<bits/stdc++.h>

#define FOR(i,a,b) for(int i=a;i<b;i++)
#define gi(x) scanf("%d",&x)
#define gi2(x,y) scanf("%d%d",&x,&y)
#define gi3(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define giarr(arr,n) FOR(i,0,n) gi(arr[i]);
#define gll(x) scanf("%lld",&x)
#define gll2(x,y) scanf("%lld%lld",&x,&y)
#define gll3(x,y,z) scanf("%lld%lld%lld",&x,&y,&y)
#define gllarr(arr,n) FOR(i,0,n) gll(arr[i]);
#define gd(x) scanf("%lf",&x)
#define gs(x) cin>>s
#define pb push_back
#define ff first
#define ss second
#define mp make_pair
#define mod 1000000007
#define deb(x) cout<<#x<<" : "<<x<<endl;
#define debug(x,y) cout<<#x<<" : "<<x<<"\t"<<#y<<" : "<<y<<endl;
#define all(x) x.begin(),x.end()
#define vi vector<int>
#define vll vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define nax 1000010
//#define vi vector<int>
typedef long long ll;
//ll co1,co2;

using namespace std;

int maxarr(vi &arr);
int minarr(vi &arr);
long long modulo(long long base,long long exponent,long long modulus);
long long choose(ll n,ll k);
bool isprime(ll n);
ll inverse(ll a,ll m);
ll fastmult(ll a,ll b,ll c);
vll a(nax);
vll prime;
ll sum[nax];
vector<bool> aprime(nax);
void setprime();
ll divCeil(ll a, ll b);
ll arrceil(vll a,ll k);

void build()
{

}

int main(){

    ll n;
    cin>>n;
    ll s=0,h=0;
    ll x;
    FOR(i,0,n)
    {
    	string s1,s2;
    	cin>>s1;
    	cin>>s2;

    	if(s2=="hard")
    		h++;
    	else
    		s++;
    }
    x=max(h,s);
    ll ans=0;

    FOR(i,1,100)
    {
    	ll temp=i*i;
    	if(temp%2!=0)
    		temp=temp/2 +1;
    	else
    		temp=temp/2;

    	if(temp>=x)
    	{
    		ans=i;
    		break;
    	}

    }
    cout<<ans;

    build();

return 0;
}

int maxarr(vi &arr)
{
    int maxi=INT_MIN;
    FOR(i,0,arr.size())  maxi=max(arr[i],maxi);

    return maxi;

}

int minarr(vi &arr)
{
    int mini=INT_MAX;
    FOR(i,0,arr.size()) mini=min(arr[i],mini);
    return mini;
}

long long modulo(long long base,long long exponent,long long modulus)
{
    if(modulus ==1)
        return 0;

    long long result=1;
    base=base % modulus;
    while(exponent>0)
    {
        if(exponent%2==1)
        {
            result=(result*base) % modulus;

        }
        exponent=exponent>>1;
        base = (base*base) % modulus;
    }
    return result;
}

long long choose(ll n,ll k)
{
    if(k==0)  return 1;
    return (n* choose(n-1,k-1))/k;
}

bool isprime(ll n)
{
    for(ll i=2;i*i<=n;i++)
    {
        if(n%i==0)
            return false;
    }
    return true;
}

void EE(ll a,ll b,ll &co1,ll &co2)
{
    if(a%b==0)
    {
        co1=0;
        co2=1;
        return;
    }
    EE(b,a%b,co1,co2);
    ll temp=co1;
    co1=co2;
    co2=temp-co2*(a/b);
}

ll inverse(ll a,ll m)
{
    ll x,y;
    EE(a,m,x,y);
    if(x<0) x+=m;
    return x;
}

ll fastmult(ll a,ll b,ll c)
{
    if(b==0)
        return 0;

    long long res=fastmult(a,b>>1,c);
    res=(res+res) % c;
    if(b%2==1)
    {
        res=(res+a)%c;
    }
    return res;
}

void setprime()
{
    aprime[0]=true;
    aprime[1]=true;

    for(int i=2;i*i<nax;i++)
    {
       // cout<<"HIII";
        if(aprime[i]==false)
        {
           // prime.pb(i);

            for(int j=i*2;j<nax;j+=i)
            {
                aprime[j]=true;
            }
        }
    }
}

ll divCeil(ll a, ll b) { return (a + b - 1) / b; }

ll arrceil(vll a,ll k)
{
    ll n=a.size();
    ll low=0;
    ll high=n-1;

    if(a[0]>k)
        return -1;
    while(low<high)

    {
       // debug(low,high);
        ll mid=(low+high+1)/2;
        if(a[mid]<=k)
            low=mid;
        else
            high=mid-1;
    }
    return low;
}


#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define all(v) v.begin(), v.end()
typedef long long ll;
typedef unsigned long long ull;
ull gcd(ull a, ull b) { return (b == 0 ? a : gcd(b, a % b)); }
ll n, m, r, z, l, k, a, h, t, s;
char c;
int sumsoft = 1;
int sumhard = 0;
int qsoft = 1;
int qhard = 0;
int ans = 1;
int dsoft = 0;
int dhard = 2;
int soft = 0;
int hard = 0;

void solve() {

  cin >> n;
  string s, s1;
  for (int i = 0; i < n; i++) {
    cin >> s1 >> s;
    if (s.compare("hard") == 0)
      hard++;
    else
      soft++;
  }
  int maxx = max(soft, hard);

  while ((sumhard < hard || sumsoft < soft) &&
         (sumhard < soft || sumsoft < hard)) {
    qsoft += dsoft;
    sumsoft += qsoft;
    dsoft = (dsoft + 2) % 4;
    qhard += dhard;
    sumhard += qhard;
    dhard = (dhard + 2) % 4;
    ans++;
  }

  cout << ans;
}
int main() {

  solve();

  return 0;
}


#include <bits/stdc++.h>
using namespace std;
int n,h,s,r;
std::string ss,a;
std::map<string, int> ma;
set<string> se;
int main(){
  std::cin >> n;
  for(int i = 0; i<n; i++){
    std::cin >> ss >> a;
    ma[ss]++;
    ma[a]++;
    se.insert(a);
    se.insert(ss);
  }
  for(string sss : se)
    r = max(r, ma[sss]);
  std::cout << r-2 << '\n';
}


#include <bits/stdc++.h>
using namespace std;
int n,h,s;
std::string ss,a;
int main(){
  std::cin >> n;
  for(int i = 0; i<n; i++){
    std::cin >> ss >> a;
    if(a=="hard") h++;
    else s++;
  }
  std::cout << max(0,max(h,s)-2) << '\n';
}


#include <bits/stdc++.h>
using namespace std;
int n,h,s;
std::string ss,a;
int main(){
  std::cin >> n;
  for(int i = 0; i<n; i++){
    std::cin >> ss >> a;
    if(a=="hard") h++;
    else s++;
  }
  std::cout << max(h,s)-2 << '\n';
}


#define _CRT_SECURE_NO_WARNINGS
#include<cstdio>
#include<vector>
#include <functional>
#include <string>
#include <utility>
#include<iostream>
#include<algorithm>
#include<map>
#include<iterator>
#include<set>
#include<stack>
#include<queue>
#include<fstream>
#include<iomanip>
#include <unordered_map>
#include <unordered_set>
#include <numeric>
#include<cmath>
#include<list>
#include <sstream>
#define rep(i,m,n) for(int i = (m); i < (n); i++)
#define rep0(i, n) for(int i = (0); i < (n); i++)
#define repd(i,m,n) for(int i=(m); i > (n); i--)
#define ll long long
#define ull unsigned ll
#define pii pair<int,int>
#define pll pair<ll,ll>
#define plli pair<pll,int>
//#define endl '\n'
#define pb push_back
//#define x first
//#define y second
#define pt pair<ll,ll>
#define vi vector<int>
#define vll vector<ll>
#define vvi vector<vi>
#define vvll vector<vll>
#define vpii vector<pii>
#define vpll vector<pll>
#define vpt vector<pt>
#define vb vector<bool>
#define vvb vector<vb>
#define pdd pair<long double, long double>
#define vpll vector<pll>
#define vpdd vector<pair<long double, long double> >
#define pq priority_queue
#define M_PI 3.14159265358979323846
using namespace std;

int main()
{
	//ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

    int n;
    cin >> n;

    int hard=0,soft=0;

    rep(i,0,n) {
        string s;
        cin >> s; cin >> s;
        if (s[0] == 'h') {
            hard++;
        } else {
            soft++;
        }
    }

    n = 1;

    while (true) {
        int all = n*n;
        int s = all/2 + all%2;
        int h = all/2;
        if (s >= soft && h >= hard) {
            cout << n << endl;
            return 0;
        }
        n++;
    }

	return 0;
}


#define _CRT_SECURE_NO_WARNINGS
#include<cstdio>
#include<vector>
#include <functional>
#include <string>
#include <utility>
#include<iostream>
#include<algorithm>
#include<map>
#include<iterator>
#include<set>
#include<stack>
#include<queue>
#include<fstream>
#include<iomanip>
#include <unordered_map>
#include <unordered_set>
#include <numeric>
#include<cmath>
#include<list>
#include <sstream>
#define rep(i,m,n) for(int i = (m); i < (n); i++)
#define rep0(i, n) for(int i = (0); i < (n); i++)
#define repd(i,m,n) for(int i=(m); i > (n); i--)
#define ll long long
#define ull unsigned ll
#define pii pair<int,int>
#define pll pair<ll,ll>
#define plli pair<pll,int>
//#define endl '\n'
#define pb push_back
//#define x first
//#define y second
#define pt pair<ll,ll>
#define vi vector<int>
#define vll vector<ll>
#define vvi vector<vi>
#define vvll vector<vll>
#define vpii vector<pii>
#define vpll vector<pll>
#define vpt vector<pt>
#define vb vector<bool>
#define vvb vector<vb>
#define pdd pair<long double, long double>
#define vpll vector<pll>
#define vpdd vector<pair<long double, long double> >
#define pq priority_queue
#define M_PI 3.14159265358979323846
using namespace std;

int main()
{
	//ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

    int n;
    cin >> n;

    int hard=0,soft=0;

    rep(i,0,n) {
        string s;
        cin >> s; cin >> s;
        if (s[0] == 'h') {
            hard++;
        } else {
            soft++;
        }
    }

    n = 1;

    while (true) {
        int all = n*n;
        int s = all/2 + all%2;
        int h = all/2;
        if (s >= soft && h >= hard) {
            cout << n << endl;
            return 0;
        }
        if (h >= soft && s >= hard) {
            cout << n << endl;
            return 0;
        }
        n++;
    }

	return 0;
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    int n, a = 0, b = 0;
    cin >> n;
    for (int i = 0; i < n; i++){
        string s, s1;
        cin >> s >> s1;
        if (s1 == "soft")
            a++;
        else
            b++;
    }
    if (a > b)
        swap(a, b);
    for (int i = 1;; i++){
        int p = i * i / 2, q = i * i - p;
        if (a <= p && b <= q)
            return cout << i << endl, 0;
    }

    return 0;
}


#include <bits/stdc++.h>
#include <math.h>
using namespace std;
int main()
{
      int64_t t, a;
      cin >> t;
      while(t--)
      {
            int64_t t = 0, d = 0;
            cin >> a;
            for(int64_t i = 2; i <= 32; i++)
            {
                  t = (pow(2, i) - 1);
                  d = a / t;
                  if(d * t == a)
                  break;
            }
            cout << a / t << endl;
      }
}


#include <bits/stdc++.h>
#include <math.h>
using namespace std;
int main()
{
      int t, a;
      cin >> t;
      while(t--)
      {
            int t = 0;
            cin >> a;
            for(int i = 1; i <= 32; i++)
            {
                  t = i;
                  if(a % (pow(2, i) - 1) == 0)
                  break;
            }
            cout << t + 1 << endl;
      }
}


#include <bits/stdc++.h>
#include <math.h>
using namespace std;
int main()
{
      int64_t t, a;
      cin >> t;
      while(t--)
      {
            int64_t t = 0;
            cin >> a;
            for(int64_t i = 1; i <= 32; i++)
            {
                  t = i;
                  if(a % i == 0)
                  break;
            }
            cout << t + 1 << endl;
      }
}


#include <bits/stdc++.h>
#include <math.h>
using namespace std;
int main()
{
      int64_t t, a;
      cin >> t;
      while(t--)
      {
            int64_t t = 0, d = 0;
            cin >> a;
            for(int64_t i = 1; i <= 32; i++)
            {
                  t = i;
                  d = a / (pow(2, i) - 1);
                  if(d * (pow(2, i) - 1) == a)
                  break;
            }
            cout << t + 1 << endl;
      }
}


#include <bits/stdc++.h>
#include <math.h>
using namespace std;
int main()
{
      int64_t t, a;
      cin >> t;
      while(t--)
      {
            int64_t t = 0, d = 0;
            cin >> a;
            for(int64_t i = 1; i <= 32; i++)
            {
                  t = (pow(2, i) - 1);
                  d = a / (pow(2, i) - 1);
                  if(d * (pow(2, i) - 1) == a)
                  break;
            }
            cout << a / t << endl;
      }
}


#include <bits/stdc++.h>
#include <math.h>
using namespace std;
int main()
{
      int64_t t, a;
      cin >> t;
      while(t--)
      {
            int t = 0;
            cin >> a;
            for(int64_t i = 1; i <= 32; i++)
            {
                  t = i;
                  if(a % (pow(2, i) - 1) == 0)
                  break;
            }
            cout << t + 1 << endl;
      }
}


#include <bits/stdc++.h>
#include <math.h>
using namespace std;
int main()
{
      int64_t t, a;
      cin >> t;
      while(t--)
      {
            int64_t t = 0, d = 0;
            cin >> a;
            for(int64_t i = 1; i <= 32; i++)
            {
                  t = i;
                  d = a / (pow(2, i + 1) - 1);
                  if(d * (pow(2, i + 1) - 1) == a)
                  break;
            }
            cout << t + 1 << endl;
      }
}


#include <bits/stdc++.h>
#include <math.h>
using namespace std;
int main()
{
      int64_t t, a;
      cin >> t;
      while(t--)
      {
            int64_t t = 0;
            cin >> a;
            for(int64_t i = 1; i <= 32; i++)
            {
                  t = i;
                  if(a % (pow(2, i) - 1) == 0)
                  break;
            }
            cout << t + 1 << endl;
      }
}


#include <bits/stdc++.h>
#include <math.h>
using namespace std;
int main()
{
      int64_t t, a;
      cin >> t;
      while(t--)
      {
            int64_t t = 0, d = 0;
            cin >> a;
            for(int64_t i = 1; i <= 32; i++)
            {
                  t = i;
                  d = a / (pow(@, i) - 1);
                  if(d * (pow(2, i) - 1) == a)
                  break;
            }
            cout << t + 1 << endl;
      }
}


#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
#define LL long long
int  n,k,mod,a[26]={2,3,5,7,9,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97};
int main()
{
	int t,s=0;
	scanf("%d",&t);
	while(t--)
	{
		scanf("%d",&n);
		for(int i=1;i<=25;i++)
		{
			if(n%a[i]==0)
			{
				printf("++%d\n",n/a[i]);
				break;
			}
		}
		if(n==1)
		printf("%d\n",n);
	}
    return 0;
}


#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
#define LL long long
int  n,k,mod,a[26]={2,3,5,7,9,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97};
int main()
{
	int t,s=0;
	scanf("%d",&t);
	while(t--)
	{
		scanf("%d",&n);
		for(int i=1;i<=25;i++)
		{
			if(n%a[i]==0)
			{
				printf("%d\n",n/a[i]);
				break;
			}
		}
		if(n==1)
		printf("%d\n",n);
	}
    return 0;
}


#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
#define ll long long
int  n,k,mod,a[4000000];
int mode(int a,int b,int mode)
{
	int sum = 1;
	while(b){
		if(b&1){
			sum =(sum*a)%mode;
			b--;
		}
		b/=2;
		a=a*a% mode;
	}
	return sum;
}
int main()
{
	int t,s=0;
	scanf("%d",&t);
	s=2;
	for(int i=1;i<=30;i++)
	{
		s*=2;
		a[i]=s;
		a[i]--;
	}//printf("%d",a[30]);
	while(t--)
	{
		scanf("%d",&n);
		for(int i=1;;i++)
		{
			if(n%a[i]==0)
			{
				printf("%d\n",n/a[i]);
				break;
			}
		}
	}
    return 0;
}


#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
#define LL long long
int  n,k,mod,a[26]={2,3,5,7,9,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97};
int main()
{
	int t,s=0;
	scanf("%d",&t);
	while(t--)
	{
		scanf("%d",&n);
		for(int i=1;i<=25;i++)
		{
			if(n%a[i]==0)
			{
				printf("%d\n",n/a[i]);
				break;
			}
		}
	}
    return 0;
}


#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
#define LL long long
int  n,k,mod,a[12]={2,3,5,7,9,11,13,17,19,23,29};
int main()
{
	int t,s=0;
	scanf("%d",&t);
	while(t--)
	{
		scanf("%d",&n);
		for(int i=1;i<=11;i++)
		{
			if(n%a[i]==0)
			{
				printf("%d\n",n/a[i]);
				break;
			}
		}
	}
    return 0;
}


#include<iostream>
#include<cmath>
using namespace std;
int main()
{
	long long t;
	cin>>t;
	while(t--)
	{
		long long n,k;
		cin>>n;
		for(double i=2;i<40;i++)
		{
			if(n%(int)(pow(2,i)-1)==0)
			{
				k=n/(pow(2,i)-1);
				cout<<k<<endl;
				break;
			}
		}
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin>>n;
    while(n--){
        long long t;
        cin>>t;
        for(int i=2;i<=40;++i)if(t%((1ll<<i)-1)==0){
            cout<<t/((1<<i)-1)<<endl;
            break;
        }
    }
    return 0;
}


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

int T,bin[50],sum[50],n;
int main(){
	scanf("%d",&T);
	bin[1]=1;
	for (register int i=2; i<=30; ++i) bin[i]=bin[i-1]*2;
	for (register int i=1; i<=30; ++i) sum[i]=sum[i-1]+bin[i];
	while (T--)
	{
		scanf("%d",&n);
		for (register int i=2; i<=30; ++i) if (n%sum[i]==0)
		{
			printf("%d\n",n/sum[i]);
			break;
		}
	}
return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
	int t;
	cin>>t;
	while(t--)
	{
		int n;
		cin>>n;
		int sum=0,ans=0;
		for(int i=0;sum<=n;i++)
		{
			sum=pow(2,i)-1;
			if(n%sum==0){
				ans=n/sum;
				break;
			}
		}
		cout<<ans<<endl;
	}
}


#include<iostream>

using namespace std;

int n;

int main()
{
	cin >> n;

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

		for(int i = 1; i <= t; i++)
		{
			int s = i;

			while(s < t)
				s += 2 * s;

			if(s == t)
			{
				cout << i << endl;
				break;
			}
			else
				continue;
		}
	}

	return 0;
}


#include <bits/stdc++.h>
using namespace std;
int main()
{
	int t,n,k,ans;
	cin >> t;
	while(t--)
	{
		cin >> n;
		k = 1;
		ans = 1;
		while(1)
		{
			ans += pow(2,k);
			if(n % ans == 0)
			{
				cout << n/ans << endl;
				break;
			}
			k++;
		}
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int t,n;
int main()
{
	cin>>t;
	for(int i=1;i<=t;i++)
	{
		scanf("%d",&n);
			for(int k=2;k<=log2(n)+1;k++)
			{
			    if(n%((1<<k)-1)==0)
			    {
			    	cout<<n/((1<<k)-1)<<endl;
			    	break;
			    }
			}
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    int t;
    cin >> t;
    while(t--)
	{
        int n;
        cin>>n;
        for(int k=2;(1<<k)-1<=n;++k)
		{
            if(n%((1<<k)-1)==0)
			{
                cout<<n/((1<<k)-1)<<endl;
                break;
            }
        }
    }
}
//sb题


#include<cstdio>
#include<algorithm>
#include<queue>
#include<iostream>
#define I long long
#define F for
using namespace std;
long long t, n, m;
signed main() {
	scanf("%lld", &t);
	while (t--) {
		scanf("%lld", &n);
		long long q = 4;
		while (1) {
			if (n % (q - 1) == 0) {
				printf("%lld\n", n / (q - 1));
				break;
			}
			q *= 2;
		}

	}
}


#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin>>n;
    while(n--){
        long long t;
        cin>>t;
        for(int i=2;i<=20;++i)if(t%((1ll<<i)-1)==0){
            cout<<t/((1<<i)-1)<<endl;
            break;
        }
    }
    return 0;
}


#include <bits/stdc++.h>

int main()
{
	int ni, x;

	scanf("%d", &ni);

	for (int i = 1; i <= ni; ++ i)
	{
		cin >> x;

		int n = 3, k = 2;

		while (x % n != 0)
		{
			n += pow(2, k);

			k ++;
		}

		printf("%d\n", x / n);
	}

	return 0;
}


#include <bits/stdc++.h>
using namespace std;
int main()
{
	int t,n,k,ans;
	cin >> t;
	while(t--)
	{
		cin >> n;
		k = 1;
		ans = 1;
		while(1)
		{
			ans = (2 << k) -1;
			if(n % ans == 0)
			{
				cout << n/ans << endl;
				break;
			}
			k++;
		}
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
long long fastPow(long long x,long long y)
{
    long long ret=1;
    while(y>0)
	{
        if(y&1) ret*=x;
        x*=x;
        y>>=1;
    }
    return ret;
}
int main()
{
	int t;
	cin>>t;
	while(t--)
	{
		long long n;
		cin>>n;
		for(int i=2;true;i++)
		{
			int pp=(fastPow(2,i)-1);
			if(n%pp==0)
			{
				cout<<n/pp<<endl;
				break;
			}
		}
	}
	return 0;
}


#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<set>
#include<vector>
#include<map>
using namespace std;

typedef long long ll;
const int inf=1e9+7;
const int N=200005;

int a[N],b[N*2],c[N*2];
int main()
{
    int t;
    scanf("%d",&t);
    while(t--)
    {
        int n,k;
        scanf("%d%d",&n,&k);
        int i,x;
        for(i=1;i<=n;i++)
            scanf("%d",&a[i]);
        for(i=1;i<=n/2;i++)
        {
            b[min(a[i],a[n-i+1])+1]++;
            b[max(a[i],a[n-i+1])+k+1]--;
            c[a[i]+a[n-i+1]]++;
        }
        int minn=inf;
        for(i=1;i<=2*k;i++)
        {
            b[i]=b[i-1]+b[i];
            x=b[i]-c[i];
            x+=(n/2-b[i])*2;
            minn=min(minn,x);
        }
        printf("%d\n",minn);
        for(i=1;i<=2*k+20;i++)
            b[i]=c[i]=0;
    }
}


#include <bits/stdc++.h>
#include <iostream>
using namespace std;
int main()
{
    int t;
    cin>>t;
    while(t--)
    {
        int n,k,x;
        cin>>n;
        for(int i=2 ; i<n ; i++)
        {
            double a = pow(2,i);
            if((n%(a-1.0)) ==0)
            {
                k=i;
                break;
        }

        }

        x= n / (pow(2,k)-1);
        cout<<x<<endl;
    }
}


#include <bits/stdc++.h>
#include <iostream>
#include <cmath>
using namespace std;
int main()
{
    int t;
    cin>>t;
    while(t--)
    {
        double n;
        int k,x;
        cin>>n;
        for(int i=2 ; i<n ; i++)
        {
            double a = pow(2,i);
            if(fmod(n,(a-1.0)) ==0)
            {
                k=i;
                break;
        }

        }

        x= n / (pow(2,k)-1);
        cout<<x<<endl;
    }
}


#include <bits/stdc++.h>
#include <iostream>
int main()
{
    int t;
    cin>>t;
    while(t--)
    {
        int n,k,x;
        cin>>n;
        for(int i=2 ; i<n ; i++)
        {
            if((n%(pow(2,i)-1)) ==0)
            {
                k=i;
                break;
        }

        }

        x= n / (pow(2,k)-1);
        cout<<x<<endl;
    }
}


#include <bits/stdc++.h>
#include <iostream>
using namespace std;
int main()
{
    int t;
    cin>>t;
    while(t--)
    {
        double n;
        int k,x;
        cin>>n;
        for(int i=2 ; i<n ; i++)
        {
            double a = pow(2,i);
            if((n%(a-1.0)) ==0)
            {
                k=i;
                break;
        }

        }

        x= n / (pow(2,k)-1);
        cout<<x<<endl;
    }
}


#include <bits/stdc++.h>
#include <iostream>
using namespace std;
int main()
{
    int t;
    cin>>t;
    while(t--)
    {
        int n,k,x;
        cin>>n;
        for(int i=2 ; i<n ; i++)
        {
            if((n%(pow(2,i)-1)) ==0)
            {
                k=i;
                break;
        }

        }

        x= n / (pow(2,k)-1);
        cout<<x<<endl;
    }
}


#include <bits/stdc++.h>
#include <iostream>
using namespace std;
int main()
{
    int t;
    cin>>t;
    while(t--)
    {
        double n,k,x;
        cin>>n;
        for(double i=2 ; i<n ; i++)
        {
            double a=1;
            if((n%(pow(2,i)-a)) ==0)
            {
                k=i;
                break;
        }

        }

        x= n / (pow(2,k)-1);
        cout<<x<<endl;
    }
}


/*786*/
#include <bits/stdc++.h>

#define pu ios_base::sync_with_stdio();cin.tie(NULL);cout.tie(NULL);

#define ll                  long long
#define yes                 cout<<"YES"<<endl
#define no                  cout<<"NO"<<endl
#define sp                  ' '
#define vi                  vector<int>
#define vl                  vector<ll>
#define pb                  push_back
#define mp                  make_pair
#define f(i,n)              for(i=0;i<n;i++)
#define stop                return 0;
#define new                 cout<<endl
#define res(x)              cout<<x<<endl;
#define vip                 vector<pair<int,int> >
#define srt(v)              sort(v.begin(),v.end());
#define test                int t;cin>t;while(t--)
#define mx(a)               *max_element(a,a+n)

using namespace std;
int main()

{
    pu;
   int t;
   cin>>t;
   while(t--){
    int n,i,a,s=0;
    cin>>n;
    if(n%3==0)cout<<n/3<<endl;
    else if(n%7==0)cout<<n/7<<endl;
    else if(n%2==0)cout<<2<<endl;
    else cout<<1<<endl;
   }

    stop;
}


/*786*/
#include <bits/stdc++.h>

#define pu ios_base::sync_with_stdio();cin.tie(NULL);cout.tie(NULL);

#define ll                  long long
#define yes                 cout<<"YES"<<endl
#define no                  cout<<"NO"<<endl
#define sp                  ' '
#define vi                  vector<int>
#define vl                  vector<ll>
#define pb                  push_back
#define mp                  make_pair
#define f(i,n)              for(i=0;i<n;i++)
#define stop                return 0;
#define new                 cout<<endl
#define res(x)              cout<<x<<endl;
#define vip                 vector<pair<int,int> >
#define srt(v)              sort(v.begin(),v.end());
#define test                int t;cin>t;while(t--)
#define mx(a)               *max_element(a,a+n)

using namespace std;
int main()

{
    pu;
   int t;
   cin>>t;
   while(t--){
    int n,i,a,s=0;
    cin>>n;
    if(n%2==0)cout<<2<<endl;
    else cout<<1<<endl;
   }

    stop;
}


/*786*/
#include <bits/stdc++.h>

#define pu ios_base::sync_with_stdio();cin.tie(NULL);cout.tie(NULL);

#define ll                  long long
#define yes                 cout<<"YES"<<endl
#define no                  cout<<"NO"<<endl
#define sp                  ' '
#define vi                  vector<int>
#define vl                  vector<ll>
#define pb                  push_back
#define mp                  make_pair
#define f(i,n)              for(i=0;i<n;i++)
#define stop                return 0;
#define new                 cout<<endl
#define res(x)              cout<<x<<endl;
#define vip                 vector<pair<int,int> >
#define srt(v)              sort(v.begin(),v.end());
#define test                int t;cin>t;while(t--)
#define mx(a)               *max_element(a,a+n)

using namespace std;
int main()

{
    pu;
   int t;
   cin>>t;
   while(t--){
    int n,i,a,s=0;
    cin>>n;
    if(n%3==0){
            res(n/3);
    }
    else res(n/7);
   }

    stop;
}


/*786*/
#include <bits/stdc++.h>

#define pu ios_base::sync_with_stdio();cin.tie(NULL);cout.tie(NULL);

#define ll                  long long
#define yes                 cout<<"YES"<<endl
#define no                  cout<<"NO"<<endl
#define sp                  ' '
#define vi                  vector<int>
#define vl                  vector<ll>
#define pb                  push_back
#define mp                  make_pair
#define f(i,n)              for(i=0;i<n;i++)
#define stop                return 0;
#define new                 cout<<endl
#define res(x)              cout<<x<<endl;
#define vip                 vector<pair<int,int> >
#define srt(v)              sort(v.begin(),v.end());
#define test                int t;cin>t;while(t--)
#define mx(a)               *max_element(a,a+n)

using namespace std;
int main()

{
    pu;
   ll t;
   cin>>t;
   while(t--){
    ll n,i;
    cin>>n;
    for(i=3; ;i+=(i*2)+1){
        if(n%i==0){
            res(n/i);
            break;
        }
    }
   }

    stop;
}


/*786*/
#include <bits/stdc++.h>

#define pu ios_base::sync_with_stdio();cin.tie(NULL);cout.tie(NULL);

#define ll                  long long
#define yes                 cout<<"YES"<<endl
#define no                  cout<<"NO"<<endl
#define sp                  ' '
#define vi                  vector<int>
#define vl                  vector<ll>
#define pb                  push_back
#define mp                  make_pair
#define f(i,n)              for(i=0;i<n;i++)
#define stop                return 0;
#define new                 cout<<endl
#define res(x)              cout<<x<<endl;
#define vip                 vector<pair<int,int> >
#define srt(v)              sort(v.begin(),v.end());
#define test                int t;cin>t;while(t--)
#define mx(a)               *max_element(a,a+n)

using namespace std;
int main()

{
    pu;
   int t;
   cin>>t;
   while(t--){
    int n,i,a,s=0;
    cin>>n;
    cout<<1<<endl;
   }

    stop;
}


/*786*/
#include <bits/stdc++.h>

#define pu ios_base::sync_with_stdio();cin.tie(NULL);cout.tie(NULL);

#define ll                  long long
#define yes                 cout<<"YES"<<endl
#define no                  cout<<"NO"<<endl
#define sp                  ' '
#define vi                  vector<int>
#define vl                  vector<ll>
#define pb                  push_back
#define mp                  make_pair
#define f(i,n)              for(i=0;i<n;i++)
#define stop                return 0;
#define new                 cout<<endl
#define res(x)              cout<<x<<endl;
#define vip                 vector<pair<int,int> >
#define srt(v)              sort(v.begin(),v.end());
#define test                int t;cin>t;while(t--)
#define mx(a)               *max_element(a,a+n)

using namespace std;
int main()

{
    pu;
   int t;
   cin>>t;
   while(t--){
    int n,i,a,s=0;
    cin>>n;
    if(n%2==0)cout<<2<<endl;
    else if(n%3==0)cout<<n/3<<endl;
    else cout<<1<<endl;
   }

    stop;
}


/*786*/
#include <bits/stdc++.h>

#define pu ios_base::sync_with_stdio();cin.tie(NULL);cout.tie(NULL);

#define ll                  long long
#define yes                 cout<<"YES"<<endl
#define no                  cout<<"NO"<<endl
#define sp                  ' '
#define vi                  vector<int>
#define vl                  vector<ll>
#define pb                  push_back
#define mp                  make_pair
#define f(i,n)              for(i=0;i<n;i++)
#define stop                return 0;
#define new                 cout<<endl
#define res(x)              cout<<x<<endl;
#define vip                 vector<pair<int,int> >
#define srt(v)              sort(v.begin(),v.end());
#define test                int t;cin>t;while(t--)
#define mx(a)               *max_element(a,a+n)

using namespace std;
int main()

{
    pu;
   int t;
   cin>>t;
   while(t--){
    int n,i,a,s=0;
    cin>>n;
    if(n%3==0){
            res(n/3);
    }
    else res(n%3);
   }

    stop;
}


/*786*/
#include <bits/stdc++.h>

#define pu ios_base::sync_with_stdio();cin.tie(NULL);cout.tie(NULL);

#define ll                  long long
#define yes                 cout<<"YES"<<endl
#define no                  cout<<"NO"<<endl
#define sp                  ' '
#define vi                  vector<int>
#define vl                  vector<ll>
#define pb                  push_back
#define mp                  make_pair
#define f(i,n)              for(i=0;i<n;i++)
#define stop                return 0;
#define new                 cout<<endl
#define res(x)              cout<<x<<endl;
#define vip                 vector<pair<int,int> >
#define srt(v)              sort(v.begin(),v.end());
#define test                int t;cin>t;while(t--)
#define mx(a)               *max_element(a,a+n)

using namespace std;
int main()

{
    pu;
   ll t;
   cin>>t;
   while(t--){
    ll n,i=3;
    cin>>n;
    while(n%i!=0){
        i=(i*2)+1;
    }
    res(n/i);
   }

    stop;
}


         #include <stdio.h>
 #include <iostream>
 #include <string>
 #include<math.h>
 using namespace std;
 int main()
 {
     long int i,n,p,temp;
     int st=0,t;
     cin>>t;
     while(t--)
     {
         cin>>n;
         for(i=2;i<n;i++)
         {
             temp=pow(2,i)-1;
             p=n%temp;
            if(p==0)
            {
                temp=n/temp;
                break;
            }
         }

         cout<<temp<<endl;
     }
 }


         #include <stdio.h>
 #include <iostream>
 #include <string>
 #include<math.h>
 using namespace std;
 int main()
 {
     long int i,n,p,temp;
     int st=0,t;
     cin>>t;
     while(t--)
     {
         cin>>n;
         for(i=2;i<n/2;i++)
         {
             temp=pow(2,i)-1;
             p=n%temp;
            if(p==0)
            {
                n=n/temp;
                break;
            }
         }

         cout<<n<<endl;
     }
 }


         #include <stdio.h>
 #include <iostream>
 #include <string>
 #include<math.h>
 using namespace std;
 int main()
 {
     long int i,j,n,m;
     int st=0,t;
     cin>>t;
     while(t--)
     {
         cin>>n;
         for(i=0;i<n;i++)
         {
             for(j=0;j<n;j++)
             {
                 if((i*(pow(2,j)-1))==n){
                 st=1;
                 break;}
             }
             if(st==1)
             {
                st=0;
                break;
             }

         }
         cout<<i<<endl;
     }
 }


         #include <stdio.h>
 #include <iostream>
 #include <string>
 #include<math.h>
 using namespace std;
 int main()
 {
     long int i,n,p,temp;
     int st=0,t;
     cin>>t;
     while(t--)
     {
         cin>>n;
         for(i=1;i<n/2;i++)
         {
             temp=2*pow(2,i)-1;
             p=n%temp;
            if(p==0)
            {
                n=n/temp;
                break;
            }
         }

         cout<<n<<endl;
     }
 }


         #include <stdio.h>
 #include <iostream>
 #include <string>
 #include<math.h>
 using namespace std;
 int main()
 {
     long int i,n,p,temp;
     int st=0,t;
     cin>>t;
     while(t--)
     {
         cin>>n;
         for(i=2;i<n/2;i++)
         {
             temp=2*pow(2,i)-1;
             p=n%temp;
            if(p==0)
            {
                n=n/temp;
                break;
            }
         }

         cout<<n<<endl;
     }
 }


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

#define ll long long
#define F first
#define S second

int main() {
  int q;
	cin >> q;
	for (int qq = 0; qq < q; qq ++) {
		ll n;
		cin >> n;
		for (int i = 4; i <= n; i *= 2) {
			if (n % (i - 1) == 0 && n / (i - 1) > 1) {
				cout << i - 1 << endl;
				break;
			}
		}
	}
}


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

#define ll long long
#define F first
#define S second

int main() {
  int q;
	cin >> q;
	for (int qq = 0; qq < q; qq ++) {
		ll n;
		cin >> n;
		for (int i = 4; i <= n; i *= 2) {
			if (n % (i - 1) == 0) {
				cout << i - 1 << endl;
				break;
			}
		}
	}
}


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

#define ll long long
#define F first
#define S second

int main() {
  int q;
	cin >> q;
	for (int qq = 0; qq < q; qq ++) {
		ll n;
		cin >> n;
		for (int i = 4; i <= n; i *= 2) {
			if (n % (i - 1) == 0) {
				cout << n / (i - 1) << endl;
				break;
			}
		}
	}
}


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

#define ll long long
#define F first
#define S second

int main() {
  int q;
	cin >> q;
	for (int qq = 0; qq < q; qq ++) {
		ll n;
		cin >> n;
		for (int i = 4; i <= n; i *= 2) {
			if (n % (i - 1) == 0) {
				cout << n % (i - 1) << endl;
				break;
			}
		}
	}
}


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

#define ll long long
#define F first
#define S second

int main() {
  int q;
	cin >> q;
	for (int qq = 0; qq < q; qq ++) {
		ll n;
		cin >> n;
		for (int i = 4; i <= n * 2; i *= 2) {
			if (n % (i - 1) == 0)  {
				cout << n / (i - 1) << endl;
				break;
			}
		}
	}
}


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

#define ll long long
#define F first
#define S second

int main() {
  int q;
	cin >> q;
	for (int qq = 0; qq < q; qq ++) {
		ll n;
		cin >> n;
		for (int i = 4; i <= n; i *= 2) {
			if (n % (i - 1) == 0)  {
				cout << n / (i - 1) << endl;
				break;
			}
		}
	}
}


#include <iostream>
#include <algorithm>
#include <cmath>

using namespace std;

int calc(int n)
{
    int y;
    int sum = 0;
    int k = 1;
    int x = n / 3;
    for(x; x > 0; x--) {
        y = x;
        while(sum < n){
            sum += x * k;
            k *= 2;
        }
        if(sum == n)
            break;
        else {
            sum = 0;
            k = 1;
        }
    }
    return y;
};

int main()
{
    int t;
    cin >> t;
    int ca[t];
    int sol[t];
    for(int i = 0; i < t; i++)
    {
        cin >> ca[i];
    }
    for(int i = 0; i < t; i++)
    {
        sol[i] = calc(ca[i]);
        cout << sol[i] << "\n";
    }

    return 0;
}


#include <iostream>
#include <algorithm>
#include <cmath>
#include <stdio.h>

using namespace std;

int calc(int n)
{
    long long int x = 3;
    long long int y;
    while(x < 64) {
        y = n / x;
        long long int sum = 0;
        int k = 1;
        while(sum < n){
            sum += y * k;
            k *= 2;
        }
        if(sum == n)
            break;
        x *= 2;
        x++;
    }
    return y;
};

int main()
{
    long long int t;
    cin >> t;
    long long int ca[t];
    long long int sol[t];
    for(int i = 0; i < t; i++)
    {
        scanf("%d", &ca[i]);
        sol[i] = calc(ca[i]);
    }
    for(int i = 0; i < t; i++)
    {
        printf("%d \n", sol[i]);
    }
    return 0;
}


#include <iostream>
#include <algorithm>
#include <cmath>
#include <stdio.h>

using namespace std;

int calc(int n)
{
    long long int x = 3;
    long long int y;
    while(x <= n) {
        y = n / x;
        long long int sum = 0;
        int k = 1;
        while(sum < n){
            sum += y * k;
            k *= 2;
        }
        if(sum == n)
            break;
        x *= 2;
        x++;
    }
    return y;
};

int main()
{
    long long int t;
    cin >> t;
    long long int ca[t];
    long long int sol[t];
    for(int i = 0; i < t; i++)
    {
        scanf("%d", &ca[i]);
        sol[i] = calc(ca[i]);
    }
    for(int i = 0; i < t; i++)
    {
        printf("%d \n", sol[i]);
    }
    return 0;
}


#include <iostream>
#include <algorithm>
#include <cmath>

using namespace std;

int calc(int n)
{
    long long int x = n / 3;
    for(x; x > 1; x--) {
        long long int sum = 0;
        int k = 1;
        while(sum < n){
            sum += x * k;
            k *= 2;
        }
        if(sum == n)
            break;
        if(x == n/3) {
            x /= 2;
            x++;
        }
    }
    return x;
};

int main()
{
    long long int t;
    cin >> t;
    long long int ca[t];
    long long int sol[t];
    for(int i = 0; i < t; i++)
    {
        cin >> ca[i];
        sol[i] = calc(ca[i]);
    }
    for(int i = 0; i < t; i++)
    {
        cout << sol[i] << "\n";
    }

    return 0;
}


#include <iostream>
#include <algorithm>
#include <cmath>

using namespace std;

int calc(int n)
{
    int y;
    int sum = 0;
    int k = 1;
    int x = n / 3;
    for(x; x > 0; x--) {
        y = x;
        while(sum < n){
            sum += x * k;
            k *= 2;
        }
        if(sum == n)
            break;
        else {
            sum = 0;
            k = 1;
        }
    }
    return y;
};

int main()
{
    int t;
    cin >> t;
    int ca[t];
    int sol[t];
    for(int i = 0; i < t; i++)
    {
        cin >> ca[i];
        sol[i] = calc(ca[i]);
    }
    for(int i = 0; i < t; i++)
    {
        cout << sol[i] << "\n";
    }

    return 0;
}


#include <iostream>
#include <algorithm>
#include <cmath>

using namespace std;

int calc(int n)
{
    long long int x = n / 3;
    for(x; x > 0; x--) {
        long long int sum = 0;
        int k = 1;
        while(sum < n){
            sum += x * k;
            k *= 2;
        }
        if(sum == n)
            break;
        else
            x = x/2 + 1;
    }
    return x;
};

int main()
{
    int t;
    cin >> t;
    int ca[t];
    int sol[t];
    for(int i = 0; i < t; i++)
    {
        cin >> ca[i];
        sol[i] = calc(ca[i]);
    }
    for(int i = 0; i < t; i++)
    {
        cout << sol[i] << "\n";
    }

    return 0;
}


#include <iostream>
#include <algorithm>
#include <cmath>

using namespace std;

int calc(int n)
{
    int x = n / 3;
    for(x; x > 0; x--) {
        int sum = 0;
        int k = 1;
        while(sum < n){
            sum += x * k;
            k *= 2;
        }
        if(sum == n)
            break;
        else
            x = x/2 + 1;
    }
    return x;
};

int main()
{
    int t;
    cin >> t;
    int ca[t];
    int sol[t];
    for(int i = 0; i < t; i++)
    {
        cin >> ca[i];
        sol[i] = calc(ca[i]);
    }
    for(int i = 0; i < t; i++)
    {
        cout << sol[i] << "\n";
    }

    return 0;
}


#include <iostream>
#include <algorithm>
#include <cmath>

using namespace std;

int calc(int n)
{
    int x = n / 3;
    for(x; x > 0; x--) {
        int sum = 0;
        int k = 1;
        while(sum < n){
            sum += x * k;
            k *= 2;
        }
        if(sum == n)
            break;
    }
    return x;
};

int main()
{
    int t;
    cin >> t;
    int ca[t];
    int sol[t];
    for(int i = 0; i < t; i++)
    {
        cin >> ca[i];
        sol[i] = calc(ca[i]);
    }
    for(int i = 0; i < t; i++)
    {
        cout << sol[i] << "\n";
    }

    return 0;
}


#include <iostream>
#include <algorithm>
#include <cmath>
#include <stdio.h>

using namespace std;

int calc(int n)
{
    long long int x = n / 3;
    for(x; x > 1; x--) {
        long long int sum = 0;
        int k = 1;
        while(sum < n){
            sum += x * k;
            k *= 2;
        }
        if(sum == n)
            break;
        if(x == n/3) {
            x /= 2;
            x++;
        }
    }
    return x;
};

int main()
{
    long long int t;
    cin >> t;
    long long int ca[t];
    long long int sol[t];
    for(int i = 0; i < t; i++)
    {
        scanf("%d", &ca[i]);
        sol[i] = calc(ca[i]);
    }
    for(int i = 0; i < t; i++)
    {
        printf("%d \n", sol[i]);
    }
    return 0;
}


#include <iostream>
#include <algorithm>
#include <cmath>
#include <stdio.h>

using namespace std;

int calc(int n)
{
    long long int x = n / 3;
    for(x; x > 1; x--) {
        long long int sum = 0;
        int k = 1;
        while(sum < n){
            sum += x * k;
            k *= 2;
        }
        if(sum == n)
            break;
        if(x == n/3) {
            x /= 2;
            x++;
        }
    }
    return x;
};

int main()
{
    long long int t;
    cin >> t;
    long long int ca[t];
    long long int sol[t];
    for(int i = 0; i < t; i++)
    {
        scanf("%d", &ca[i]);
        sol[i] = calc(ca[i]);
    }
    for(int i = 0; i < t; i++)
    {
        printf("%d", sol[i]);
    }
    return 0;
}


#include <iostream>
#include <algorithm>
#include <cmath>
#include <stdio.h>

using namespace std;

int calc(int n)
{
    /*long long int x = n / 3;
    for(x; x > 1; x--) {
        long long int sum = 0;
        int k = 1;
        while(sum < n){
            sum += x * k;
            k *= 2;
        }
        if(sum == n)
            break;
        else {
            x /= 3;
            x++;
        }
    }*/
    int x = 3;
    long long int y;
    while(x < 64) {
        y = n / x;
        long long int sum = 0;
        int k = 1;
        while(sum < n){
            sum += y * k;
            k *= 2;
        }
        if(sum == n)
            break;
        x *= 2;
        x++;
    }
    return y;
};

int main()
{
    long long int t;
    cin >> t;
    long long int ca[t];
    long long int sol[t];
    for(int i = 0; i < t; i++)
    {
        scanf("%d", &ca[i]);
        sol[i] = calc(ca[i]);
    }
    for(int i = 0; i < t; i++)
    {
        printf("%d \n", sol[i]);
    }
    return 0;
}


#include<bits/stdc++.h>

using namespace std;

/// WRITE CODE AND DRINK A CUP OF MILK TEA :D.
#define task "1343A"
#define TL ios_base::sync_with_stdio(0); cin.tie(0);

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

void solve()
{
    int n;
    cin >> n;
    int k = 0;
    for (int i = 0; i <= 1e9; ++i) {
        k += (1 << i);
        if ((i > 1) && (k > 1e9 || n % k == 0)) break;
    }
    cout << n / k << endl;
}
int main()
{
    TL
    int t;
    cin >> t;
    while (t--) {
        solve();
    }
}
/// LOOK AT MY CODE, MY CODE IS AMAZING :D.


#include<bits/stdc++.h>

using namespace std;

/// WRITE CODE AND DRINK A CUP OF MILK TEA :D.
#define task "1343A"
#define TL ios_base::sync_with_stdio(0); cin.tie(0);

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

void solve()
{
    ll n;
    cin >> n;
    ll k = 0;
    for (ll i = 0; i <= 1e9; ++i) {
        k += (1 << i);
        if ((i > 1) && (k > 1e9 || n % k == 0)) break;
    }
    cout << n / k << '\n';
}
ll main()
{
    TL
    ll t;
    cin >> t;
    while (t--) {
        solve();
    }
}
/// LOOK AT MY CODE, MY CODE IS AMAZING :D.


#include<bits/stdc++.h>

using namespace std;

/// WRITE CODE AND DRINK A CUP OF MILK TEA :D.
#define task "1343A"
#define TL ios_base::sync_with_stdio(0); cin.tie(0);

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

void solve()
{
    ll n;
    cin >> n;
    ll k = 0;
    for (ll i = 0; i <= 1e9; ++i) {
        k += (1 << i);
        if ((i > 1) && (k > 1e9 || n % k == 0)) break;
    }
    cout << n / k << '\n';
}
int main()
{
    TL
    ll t;
    cin >> t;
    while (t--) {
        solve();
    }
}
/// LOOK AT MY CODE, MY CODE IS AMAZING :D.


#include<bits/stdc++.h>

using namespace std;

/// WRITE CODE AND DRINK A CUP OF MILK TEA :D.
#define task "1343A"
#define TL ios_base::sync_with_stdio(0); cin.tie(0);

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

void solve()
{
    cout << 1 << '\n';
}
int main()
{
    TL
    int t;
    cin >> t;
    while (t--) {
        solve();
    }
}
/// LOOK AT MY CODE, MY CODE IS AMAZING :D.


#include<bits/stdc++.h>

using namespace std;

/// WRITE CODE AND DRINK A CUP OF MILK TEA :D.
#define task "1343A"
#define TL ios_base::sync_with_stdio(0); cin.tie(0);

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

void solve()
{
    int n;
    cin >> n;
    int k = 0;
    for (int i = 0; i <= 1e9; ++i) {
        k += (1 << i);
        if ((i > 1) && (k > 1e9 || n % k == 0)) break;
    }
    cout << n / k << endl;
}
int main()
{

    TL
    int t;
    cin >> t;
    while (t--) {
        solve();
    }
}
/// LOOK AT MY CODE, MY CODE IS AMAZING :D.


#include<bits/stdc++.h>

using namespace std;

/// WRITE CODE AND DRINK A CUP OF MILK TEA :D.
#define task "1343A"
#define TL ios_base::sync_with_stdio(0); cin.tie(0);

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

void solve()
{
    int n;
    cin >> n;
    int k = 0;
    for (int i = 0; i <= 1e9; ++i) {
        k += (1 << i);
        if ((k > 1) && (k > 1e9 || n % k == 0)) break;
    }
    cout << n / k << endl;
}
int main()
{
    TL
    int t;
    cin >> t;
    while (t--) {
        solve();
    }
}
/// LOOK AT MY CODE, MY CODE IS AMAZING :D.


#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <vector>
#include <string>
#include <queue>
#include <utility>
#include <map>
//#include <unordered_map>
#include <set>
using namespace std;
typedef long long LL;
typedef pair<int,int> PII;
#define deg(x) cout<<#x<<'='<<x<<endl
#define mes(a,b) memset(a,b,sizeof(a))
#define Close ios::sync_with_stdio(false), cin.tie(0)
#define mk(a,b) make_pair(a,b)
#define lowbit(x) (x & (-x))
#define lson p << 1
#define rson p << 1 | 1
const int inf = 0x3f3f3f3f;
const int mod = 1e9 + 7;
const int N = 1005;

int main()
{
    int T,n;
    scanf("%d", &T);
    while(T--) {
        cin >> n;
        if(n % 2)
            puts("1");
        else
            puts("2");
    }
    return 0;
}


#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <vector>
#include <string>
#include <queue>
#include <utility>
#include <map>
//#include <unordered_map>
#include <set>
using namespace std;
typedef long long LL;
typedef pair<int,int> PII;
#define deg(x) cout<<#x<<'='<<x<<endl
#define mes(a,b) memset(a,b,sizeof(a))
#define Close ios::sync_with_stdio(false), cin.tie(0)
#define mk(a,b) make_pair(a,b)
#define lowbit(x) (x & (-x))
#define lson p << 1
#define rson p << 1 | 1
const int inf = 0x3f3f3f3f;
const int mod = 1e9 + 7;
const int N = 1005;

int main()
{
    int T,n;
    scanf("%d", &T);
    while(T--) {
        if(n % 2)
            puts("1");
        else
            puts("2");
    }
    return 0;
}


#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <vector>
#include <string>
#include <queue>
#include <utility>
#include <map>
//#include <unordered_map>
#include <set>
using namespace std;
typedef long long LL;
typedef pair<int,int> PII;
#define deg(x) cout<<#x<<'='<<x<<endl
#define mes(a,b) memset(a,b,sizeof(a))
#define Close ios::sync_with_stdio(false), cin.tie(0)
#define mk(a,b) make_pair(a,b)
#define lowbit(x) (x & (-x))
#define lson p << 1
#define rson p << 1 | 1
const int inf = 0x3f3f3f3f;
const int mod = 1e9 + 7;
const int N = 1005;

int main()
{
    int T,n;
    scanf("%d", &T);
    while(T--) {
        cin >> n;
        if(n % 2)
            puts("3");
        else
            puts("2");
    }
    return 0;
}


#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <vector>
#include <string>
#include <queue>
#include <utility>
#include <map>
//#include <unordered_map>
#include <set>
using namespace std;
typedef long long LL;
typedef pair<int,int> PII;
#define deg(x) cout<<#x<<'='<<x<<endl
#define mes(a,b) memset(a,b,sizeof(a))
#define Close ios::sync_with_stdio(false), cin.tie(0)
#define mk(a,b) make_pair(a,b)
#define lowbit(x) (x & (-x))
#define lson p << 1
#define rson p << 1 | 1
const int inf = 0x3f3f3f3f;
const int mod = 1e9 + 7;
const int N = 1005;

int main()
{
    int T,n;
    scanf("%d", &T);
    while(T--) {
        if(n % 2)
            puts("3");
        else
            puts("2");
    }
    return 0;
}


#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <vector>
#include <string>
#include <queue>
#include <utility>
#include <map>
//#include <unordered_map>
#include <set>
using namespace std;
typedef long long LL;
typedef pair<int,int> PII;
#define deg(x) cout<<#x<<'='<<x<<endl
#define mes(a,b) memset(a,b,sizeof(a))
#define Close ios::sync_with_stdio(false), cin.tie(0)
#define mk(a,b) make_pair(a,b)
#define lowbit(x) (x & (-x))
#define lson p << 1
#define rson p << 1 | 1
const int inf = 0x3f3f3f3f;
const int mod = 1e9 + 7;
const int N = 1005;

int main()
{
    int T,n;
    scanf("%d", &T);
    while(T--) {
        scanf("%d", &n);
        int sum = 1;
        for (int i = 1;; i++) {
            sum += 1 << i;
            if(n % sum == 0) {
                printf("%d\n", n / sum);
                break;
            }
        }
    }
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

int t, n;

int main() {

    cin >> t;

    for (int i = 0; i < t; i++) {

        cin >> n;

        int k = 3, power = 2;
        while (n % k != 0) {
            power *= 2;
            k += power;
        }
        cout << n / k << endl;
    }
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

int t, n;

int main() {
    cin >> t;
    for (int i = 0; i < t; i++) {
        cin >> n;
        for (int j = 4; j < 12345; j++)
            if (n % (j - 1) == 0) {
                cout << endl << n / (j - 1);
                break;
            }
    }
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

int t, n;

int main() {
    cin >> t;
    for (int i = 0; i < t; i++) {
        cin >> n;
        for (int j = 4; j < 12345; j *= 2)
            if (n % (j - 1) == 0) {
                cout << n / (j - 1) << j << endl;
                break;
            }
    }
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

int t, n;

int main() {
    cin >> t;
    for (int i = 0; i < t; i++) {
        cin >> n;
        for (int j = 4; j < 12345; j++)
            if (n % (j - 1) == 0) {
                cout << n / (j - 1) << endl;
                break;
            }
    }
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

int t, n;

int main() {
    cin >> t;
    for (int i = 0; i < t; i++) {
        cin >> n;
        for (int j = 4; j < 12345; j *= 2)
            if (n % (j - 1) == 0) {
                cout << n / (j - 1) << endl;
                break;
            }
    }
    return 0;
}


#include <iostream>

using namespace std;

int main() {

	int t, n;
	cin >> t;
	while (t--) {
		cin >> n;
		cout << 1;
	}
}


#include <iostream>

using namespace std;

int main() {

	int t, n;
	cin >> t;
	while (t--) {
		cin >> n;
		int k = 1;
		while (n % k != 0 || k == 1) {
			k = k * 2 + 1;
		}
		cout << n / k << endl;
	}
}


#include <iostream>

using namespace std;

int main() {

	int t, n;
	cin >> t;
	while (t--) {
		cin >> n;
		cout << n << endl;
	}
}


#include <iostream>

using namespace std;

int main() {

	int t, n;
	cin >> t;
	while (t--) {
		cin >> n;
		cout << 2 << endl;
	}
}


#include <iostream>

using namespace std;

int main() {

	int t, n;
	cin >> t;
	while (t--) {
		cin >> n;
		if (n % 2 == 0) {
			cout << n << endl;
		}
		else {
			cout << 1 << endl;
		}
	}
}


#include <iostream>

using namespace std;

int main() {

	int t, n;
	cin >> t;
	while (t--) {
		cin >> n;
		if (n % 2 == 0) {
			cout << n << endl;
		}
		else {
			cout << n/3 << endl;
		}
	}
}


#include <iostream>

using namespace std;

int main() {

	int t, n;
	cin >> t;
	while (t--) {
		cin >> n;
		cout << 1 << endl;
	}
}


#include <iostream>

using namespace std;

int main() {

	int t, n;
	cin >> t;
	while (t--) {
		cin >> n;
		if (n % 2 == 0) {
			cout << n/2 << endl;
		}
		else {
			cout << n/3 << endl;
		}
	}
}


#include<bits/stdc++.h>
#define inf 2147283647
#define int long long
using namespace std;
signed main(){
    int t;
    cin>>t;
    for(int i=1;i<=t;i++)
    {
        int n;
        cin>>n;
        for(int i=2;i<=32;i++)
        {
            if(n%((1<<i)-1)==0)
            {
                cout<<n/((1<<i)-1)<<endl;
                break;
            }
        }
    }
    return 0;
}


#include<iostream>
#include<cmath>
using namespace std;
int main()
{
	int t;
	cin>>t;
	while(t--)
	{
		int n,k;
		cin>>n;
		for(double i=2;i<10;i++)
		{
			if(n%(int)(pow(2,i)-1)==0)
			{
				k=n/(pow(2,i)-1);
				cout<<k<<endl;
				break;
			}
		}
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define Fast_IO ios::sync_with_stdio(false);
#define DEBUG fprintf(stderr,"Running on Line %d in Function %s\n",__LINE__,__FUNCTION__)
#define fir first
#define sec second
#define mod 998244353
#define ll long long
#define inf 0x3f3f3f3f
#define INF 0x3f3f3f3f3f3f3f3f
inline int read()
{
	char ch=getchar(); int nega=1; while(!isdigit(ch)) {if(ch=='-') nega=-1; ch=getchar();}
	int ans=0; while(isdigit(ch)) {ans=ans*10+ch-48;ch=getchar();}
	if(nega==-1) return -ans;
	return ans;
}
typedef pair<int,int> pii;
inline int min(int x,int y,int z){return min(x,min(y,z));}
inline int max(int x,int y,int z){return max(x,max(y,z));}
inline int add(int x,int y){return x+y>=mod?x+y-mod:x+y;}
inline int add(int x,int y,int z){return add(add(x,y),z);}
inline int sub(int x,int y){return x-y<0?x-y+mod:x-y;}
inline int mul(int x,int y){return 1LL*x*y%mod;}
inline int mul(int x,int y,int z){return mul(mul(x,y),z);}
void work()
{
	int n=read();
	for(int i=2;i<=31;i++)
	{
		int x=(1<<i)-1;
		if(n%x==0)
		{
			printf("%d\n",n/x);
			return ;
		}
	}
}
signed main()
{
	int T=read();
	while(T--) work();
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
	int T;
	cin>>T;
	while(T--){
		int n;
		cin>>n;
		for(int i=2;i<=30;i++){
			if(n%((int)pow(2,i)-1)==0){
				cout<<n/(int)((int)pow(2,i)-1)<<endl;
				break;
			}
		}
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin>>n;
    int top=0;
    tab[0]=1;
    while(n--){
        long long t;
        cin>>t;
        for(int i=2;i<=15;++i)if(t%((1<<i)-1)==0){
            cout<<t/((1<<i)-1)<<endl;
            break;
        }
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    int t;
    cin >> t;
    while(t--)
	{
        int n;
        cin>>n;
        for(int k=2;(1<<k)-1<=n;++k)
		{
            if(n%((1<<k)-1)==0)
			{
                cout<<n/((1<<k)-1)<<endl;
                break;
            }
        }
    }
}
//sb题 ，114514


#include <stdio.h>

int read()
{
	char c;
	while((c = getchar()) < 48 || c > 57);
	int x = c - 48;
	while((c = getchar()) > 47 && c < 58) x = x * 10 + c - 48;
	return x;
}

void write(int x)
{
	if(x < 10){
		putchar(x + 48);
		return;
	}
	write(x / 10);
	putchar(x % 10 + 48);
}

int main()
{
	int n, i, T, j;
	int a[33], x;

	for(a[j = 0] = i = x = 1; ; j = i++){
		a[i] = a[j] + (x <<= 1);
		if(a[i] > 1000000000) break;
	}
	scanf("%d", &T);
	while(T--){
		n = read();
		for(i = 1; n % a[i]; i++);
		write(n / a[i]), puts("");
	}

	return 0;
}


#include<iostream>

using namespace std;

int p(int n)
{
	int m = 2;
	while(n--)
	{
		m *= 2;
	}
	return m;
}
int n;

int main()
{
	cin >> n;

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

		for(int i = 1; i <= t; i++)
		{
			int s = i, m = i;

			while(s < t)
			{
				s += 2 * m;
				m = 2 * m;
			}

			if(s % t == 0)
			{
				cout << i << endl;
				break;
			}
			else
				continue;
		}
	}

	return 0;
}


#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <cstring>
#include <vector>
#include <queue>
#include <cmath>
typedef long long LL;
using namespace std;

int main() {
	int T;
	scanf("%d",&T);
	while(T--) {
		LL n;
		scanf("%lld",&n);
		for(int i=1;i<=sqrt(n);i++) {
			if(n%i==0) {
				LL base=4;
				while(base<i+1) base*=2;
				if(base==i+1) {
					printf("%lld\n",n/i);break;
				}
				base=4;
				while(base<n/i+1) base*=2;
				if(base==n/i+1) {
					printf("%d\n",i);break;
				}
			}
		}
	}
	return 0;
}


#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <cstring>
#include <vector>
#include <queue>
#include <cmath>
typedef long long LL;
using namespace std;

// const int N=;

int main() {
	int T;
	scanf("%d",&T);
	whiel(T--) {
		int n;
		scanf("%d",&n);
		printf("1\n");
	}
	return 0;
}


#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <cstring>
#include <vector>
#include <queue>
#include <cmath>
typedef long long LL;
using namespace std;

// const int N=;

int main() {
	int T;
	scanf("%d",&T);
	while(T--) {
		int n;
		scanf("%d",&n);
		printf("1\n");
	}
	return 0;
}


#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <cstring>
#include <vector>
#include <queue>
#include <cmath>
typedef long long LL;
using namespace std;

int main() {
	int T;
	scanf("%d",&T);
	while(T--) {
		LL n;
		scanf("%lld",&n);
		LL basex=4,basey=4;
		while(basey<n) basey*=2;
		basey*=2;
		for(int i=1;i<=sqrt(n);i++) {
			if(n%i==0) {
				while(basex<i+1) basex*=2;
				if(basex==i+1) {
					printf("%lld\n",n/i);break;
				}
				while(basey>n/i+1) basey/=2;
				if(basey==n/i+1) {
					printf("%d\n",i);break;
				}
			}
		}
	}
	return 0;
}


#include<set>
#include<map>
#include<list>
#include<iomanip>
#include<cmath>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<complex>
#include<sstream>
#include<iostream>
#include<fstream>
#include<algorithm>
#include<numeric>
#include<utility>
#include<functional>
#include<stdio.h>
#include<assert.h>
#include<memory.h>
#include<bitset>
using namespace std;

#define all(v)              ((v).begin()), ((v).end())
#define sz(v)               ((int)((v).size()))
#define clr(v, d)           memset(v, d, sizeof(v))
#define rep(i, v)       for(int i=0;i<sz(v);++i)
#define lp(i, n)        for(int i=0;i<(int)(n);++i)
#define lpi(i, j, n)    for(int i=(j);i<(int)(n);++i)
#define lpd(i, j, n)    for(int i=(j);i>=(int)(n);--i)

typedef long long         ll;
const ll OO = 1e8;

#define pb                  push_back
#define MP                  make_pair
#define P(x)                cout<<#x<<" = { "<<x<<" }\n"
typedef long double       ld;
typedef vector<int>       vi;
typedef vector<double>    vd;
typedef vector< vi >      vvi;
typedef vector< vd >      vvd;
typedef vector<string>    vs;

int n ;
char a[5002][5002] ;

int main ()
{
    cin>>n ;
    gets(*a) ;
    for(int i=0;i<n;i++){
            gets(a[i]) ;
    }
    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            for(int k=j+1;k<n;k++){
                if(a[i][j]=='1'&&a[j][k]=='1'&&a[k][i]=='1'){
                    cout<<i+1<<" "<<j+1<<" "<<k+1  ;
                    return 0 ;
                } else if (a[i][k]=='1'&&a[k][j]=='1'&&a[j][i]=='1'){
                    cout<<k+1<<" "<<j+1<<" "<<i+1  ;
                    return 0 ;
                }
            }
        }
    }
    cout<<-1 ;
    return 0 ;
}


#include<set>
#include<map>
#include<list>
#include<iomanip>
#include<cmath>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<complex>
#include<sstream>
#include<iostream>
#include<fstream>
#include<algorithm>
#include<numeric>
#include<utility>
#include<functional>
#include<stdio.h>
#include<assert.h>
#include<memory.h>
#include<bitset>
using namespace std;

#define all(v)              ((v).begin()), ((v).end())
#define sz(v)               ((int)((v).size()))
#define clr(v, d)           memset(v, d, sizeof(v))
#define rep(i, v)       for(int i=0;i<sz(v);++i)
#define lp(i, n)        for(int i=0;i<(int)(n);++i)
#define lpi(i, j, n)    for(int i=(j);i<(int)(n);++i)
#define lpd(i, j, n)    for(int i=(j);i>=(int)(n);--i)

typedef long long         ll;
const ll OO = 1e8;

#define pb                  push_back
#define MP                  make_pair
#define P(x)                cout<<#x<<" = { "<<x<<" }\n"
typedef long double       ld;
typedef vector<int>       vi;
typedef vector<double>    vd;
typedef vector< vi >      vvi;
typedef vector< vd >      vvd;
typedef vector<string>    vs;

int n ;
int a[5002][5002] ,vis[5002], ans[3], f=0 ;

void dfs(int x,int p){
        if(f) return ;
        vis[x]=1;
        for(int i=1;i<=n;i++){
            if(a[x][i]&&a[i][p]){
                f=1 ;
                ans[0]=x ;
                ans[1]=i ;
                ans[2]=p ;
                return ;
            }
            if(!vis[i]) dfs(i,x) ;
        }

}

int main ()
{
    string s ;
    cin>>n ;
    for(int i=1;i<=n;i++){
            cin>>s ;
            for(int j=1;j<=n;j++)
                a[i][j]=(s[j-1]-'0') ;
    }
    for(int i=1;i<=n;i++) dfs(i,0);
    if(f){
        cout<<ans[0]<<" "<<ans[1]<<" "<<ans[2]  ;
    } else
    cout<<-1 ;
    return 0 ;
}


#include<set>
#include<map>
#include<list>
#include<iomanip>
#include<cmath>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<complex>
#include<sstream>
#include<iostream>
#include<fstream>
#include<algorithm>
#include<numeric>
#include<utility>
#include<functional>
#include<stdio.h>
#include<assert.h>
#include<memory.h>
#include<bitset>
using namespace std;

#define all(v)              ((v).begin()), ((v).end())
#define sz(v)               ((int)((v).size()))
#define clr(v, d)           memset(v, d, sizeof(v))
#define rep(i, v)       for(int i=0;i<sz(v);++i)
#define lp(i, n)        for(int i=0;i<(int)(n);++i)
#define lpi(i, j, n)    for(int i=(j);i<(int)(n);++i)
#define lpd(i, j, n)    for(int i=(j);i>=(int)(n);--i)

typedef long long         ll;
const ll OO = 1e8;

#define pb                  push_back
#define MP                  make_pair
#define P(x)                cout<<#x<<" = { "<<x<<" }\n"
typedef long double       ld;
typedef vector<int>       vi;
typedef vector<double>    vd;
typedef vector< vi >      vvi;
typedef vector< vd >      vvd;
typedef vector<string>    vs;

int n ;
int a[5002][5002] ,vis[5002], ans[3], f=0 ;

void dfs(int x,int p){
        if(f) return ;
        vis[x]=1;
        for(int i=1;i<=n;i++){
            if(a[x][i]&&a[i][p]){
                f=1 ;
                ans[0]=p ;
                ans[1]=x ;
                ans[2]=i ;
                return ;
            }
            if(!vis[i]&&a[x][i]) dfs(i,x) ;
        }

}

int main ()
{
    char s[5001] ;
    cin>>n ;
    for(int i=1;i<=n;i++){
            scanf("%s",&s) ;
            for(int j=1;j<=n;j++)
                a[i][j]=(s[j-1]-'0') ;
    }
    for(int i=1;i<=n&&f==0;i++) dfs(i,0) ;
    if(f){
        cout<<ans[0]<<" "<<ans[1]<<" "<<ans[2]  ;
    } else
    cout<<-1 ;
    return 0 ;
}


#include<set>
#include<map>
#include<list>
#include<iomanip>
#include<cmath>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<complex>
#include<sstream>
#include<iostream>
#include<fstream>
#include<algorithm>
#include<numeric>
#include<utility>
#include<functional>
#include<stdio.h>
#include<assert.h>
#include<memory.h>
#include<bitset>
using namespace std;

#define all(v)              ((v).begin()), ((v).end())
#define sz(v)               ((int)((v).size()))
#define clr(v, d)           memset(v, d, sizeof(v))
#define rep(i, v)       for(int i=0;i<sz(v);++i)
#define lp(i, n)        for(int i=0;i<(int)(n);++i)
#define lpi(i, j, n)    for(int i=(j);i<(int)(n);++i)
#define lpd(i, j, n)    for(int i=(j);i>=(int)(n);--i)

typedef long long         ll;
const ll OO = 1e8;

#define pb                  push_back
#define MP                  make_pair
#define P(x)                cout<<#x<<" = { "<<x<<" }\n"
typedef long double       ld;
typedef vector<int>       vi;
typedef vector<double>    vd;
typedef vector< vi >      vvi;
typedef vector< vd >      vvd;
typedef vector<string>    vs;

int n ;
char a[5002][5002] ; int vis[5002], ans[3], f=0 ;

void dfs(int x,int p){
        if(f) return ;
        vis[x]=1;
        for(int i=0;i<n;i++){
            if(a[x][i]=='1'){
                if(a[i][p]=='1'){
                cout<<p+1<<" "<<x+1<<" "<<i+1  ;
                exit(0) ;
                }
             else
            if(!vis[i]) dfs(i,x) ;
        }
    }

}

int main ()
{
    scanf("%d",&n) ;
    for(int i=0;i<n;i++){
            scanf("%s",&a[i]) ;
    }
    for(int i=0;i<n&&f==0;i++) dfs(i,i) ;
    cout<<-1 ;
    return 0 ;
}


#include<set>
#include<map>
#include<list>
#include<iomanip>
#include<cmath>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<complex>
#include<sstream>
#include<iostream>
#include<fstream>
#include<algorithm>
#include<numeric>
#include<utility>
#include<functional>
#include<stdio.h>
#include<assert.h>
#include<memory.h>
#include<bitset>
using namespace std;

#define all(v)				((v).begin()), ((v).end())
#define sz(v)				((int)((v).size()))
#define clr(v, d)			memset(v, d, sizeof(v))
#define rep(i, v)		for(int i=0;i<sz(v);++i)
#define lp(i, n)		for(int i=0;i<(int)(n);++i)
#define lpi(i, j, n)	for(int i=(j);i<(int)(n);++i)
#define lpd(i, j, n)	for(int i=(j);i>=(int)(n);--i)

typedef long long         ll;
const ll OO = 1e8;

#define pb					push_back
#define MP					make_pair
#define P(x)				cout<<#x<<" = { "<<x<<" }\n"
typedef long double   	  ld;
typedef vector<int>       vi;
typedef vector<double>    vd;
typedef vector< vi >      vvi;
typedef vector< vd >      vvd;
typedef vector<string>    vs;

int n ;
int a[5002][5002] ,ans[3] ;

int main ()
{
    string s ;
    cin>>n ;
    for(int i=1;i<=n;i++){
            cin>>s ;
            for(int j=1;j<=n;j++)
                a[i][j]=(s[j-1]-'0') ;
    }
    for(int i=1;i<=n;i++){
        for(int j=1;j<=n;j++){
            for(int k=1;k<=n;k++){
                if(a[i][j]&&a[j][k]&&a[k][i]){
                    cout<<i<<" "<<j<<" "<<k  ;
                    return 0 ;
                }
            }
        }
    }
    cout<<-1 ;
    return 0 ;
}


#include<set>
#include<map>
#include<list>
#include<iomanip>
#include<cmath>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<complex>
#include<sstream>
#include<iostream>
#include<fstream>
#include<algorithm>
#include<numeric>
#include<utility>
#include<functional>
#include<stdio.h>
#include<assert.h>
#include<memory.h>
#include<bitset>
using namespace std;

#define all(v)				((v).begin()), ((v).end())
#define sz(v)				((int)((v).size()))
#define clr(v, d)			memset(v, d, sizeof(v))
#define rep(i, v)		for(int i=0;i<sz(v);++i)
#define lp(i, n)		for(int i=0;i<(int)(n);++i)
#define lpi(i, j, n)	for(int i=(j);i<(int)(n);++i)
#define lpd(i, j, n)	for(int i=(j);i>=(int)(n);--i)

typedef long long         ll;
const ll OO = 1e8;

#define pb					push_back
#define MP					make_pair
#define P(x)				cout<<#x<<" = { "<<x<<" }\n"
typedef long double   	  ld;
typedef vector<int>       vi;
typedef vector<double>    vd;
typedef vector< vi >      vvi;
typedef vector< vd >      vvd;
typedef vector<string>    vs;

int n ;
int a[5002][5002] ,ans[3] ;

int main ()
{
    string s ;
    cin>>n ;
    for(int i=1;i<=n;i++){
            cin>>s ;
            for(int j=1;j<=n;j++)
                a[i][j]=(s[j-1]-'0') ;
    }
    for(int i=1;i<=n;i++){
        for(int j=i+1;j<=n;j++){
            for(int k=j+1;k<=n;k++){
                if(a[i][j]&&a[j][k]&&a[k][i]){
                    cout<<i<<" "<<j<<" "<<k  ;
                    return 0 ;
                } else if (a[i][k]&&a[k][j]&&a[j][i]){
                    cout<<k<<" "<<j<<" "<<i  ;
                    return 0 ;
                }

            }
        }
    }
    cout<<-1 ;
    return 0 ;
}


#include<set>
#include<map>
#include<list>
#include<iomanip>
#include<cmath>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<complex>
#include<sstream>
#include<iostream>
#include<fstream>
#include<algorithm>
#include<numeric>
#include<utility>
#include<functional>
#include<stdio.h>
#include<assert.h>
#include<memory.h>
#include<bitset>
using namespace std;

#define all(v)              ((v).begin()), ((v).end())
#define sz(v)               ((int)((v).size()))
#define clr(v, d)           memset(v, d, sizeof(v))
#define rep(i, v)       for(int i=0;i<sz(v);++i)
#define lp(i, n)        for(int i=0;i<(int)(n);++i)
#define lpi(i, j, n)    for(int i=(j);i<(int)(n);++i)
#define lpd(i, j, n)    for(int i=(j);i>=(int)(n);--i)

typedef long long         ll;
const ll OO = 1e8;

#define pb                  push_back
#define MP                  make_pair
#define P(x)                cout<<#x<<" = { "<<x<<" }\n"
typedef long double       ld;
typedef vector<int>       vi;
typedef vector<double>    vd;
typedef vector< vi >      vvi;
typedef vector< vd >      vvd;
typedef vector<string>    vs;

int n ;
int a[5002][5002] ,vis[5002], ans[3], f=0 ;

void dfs(int x,int p){
        if(f) return ;
        vis[x]=1;
        for(int i=1;i<=n;i++){
            if(a[x][i]&&a[i][p]){
                f=1 ;
                ans[0]=p ;
                ans[1]=x ;
                ans[2]=i ;
                return ;
            }
            if(!vis[i]) dfs(i,x) ;
        }

}

int main ()
{
    string s ;
    cin>>n ;
    for(int i=1;i<=n;i++){
            cin>>s ;
            for(int j=1;j<=n;j++)
                a[i][j]=(s[j-1]-'0') ;
    }
    for(int i=1;i<=n;i++) dfs(i,0);
    if(f){
        cout<<ans[0]<<" "<<ans[1]<<" "<<ans[2]  ;
    } else
    cout<<-1 ;
    return 0 ;
}


#include<set>
#include<map>
#include<list>
#include<iomanip>
#include<cmath>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<complex>
#include<sstream>
#include<iostream>
#include<fstream>
#include<algorithm>
#include<numeric>
#include<utility>
#include<functional>
#include<stdio.h>
#include<assert.h>
#include<memory.h>
#include<bitset>
using namespace std;

#define all(v)              ((v).begin()), ((v).end())
#define sz(v)               ((int)((v).size()))
#define clr(v, d)           memset(v, d, sizeof(v))
#define rep(i, v)       for(int i=0;i<sz(v);++i)
#define lp(i, n)        for(int i=0;i<(int)(n);++i)
#define lpi(i, j, n)    for(int i=(j);i<(int)(n);++i)
#define lpd(i, j, n)    for(int i=(j);i>=(int)(n);--i)

typedef long long         ll;
const ll OO = 1e8;

#define pb                  push_back
#define MP                  make_pair
#define P(x)                cout<<#x<<" = { "<<x<<" }\n"
typedef long double       ld;
typedef vector<int>       vi;
typedef vector<double>    vd;
typedef vector< vi >      vvi;
typedef vector< vd >      vvd;
typedef vector<string>    vs;

int n ;
string a[5002] ; int vis[5002], ans[3], f=0 ;

void dfs(int x,int p){
        if(f) return ;
        vis[x]=1;
        for(int i=0;i<n;i++){
            if(a[x][i]=='1'&&a[i][p]=='1'){
                cout<<p+1<<" "<<x+1<<" "<<i+1  ;
                exit(0) ;
            }
            if(!vis[i]&&a[x][i]=='1') dfs(i,x) ;
        }

}

int main ()
{
    string s ;
    cin>>n ;
    for(int i=0;i<n;i++){
            cin>>a[i] ;
    }
    for(int i=0;i<n;i++) dfs(i,i) ;
    cout<<-1 ;
    return 0 ;
}


#include<set>
#include<map>
#include<list>
#include<iomanip>
#include<cmath>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<complex>
#include<sstream>
#include<iostream>
#include<fstream>
#include<algorithm>
#include<numeric>
#include<utility>
#include<functional>
#include<stdio.h>
#include<assert.h>
#include<memory.h>
#include<bitset>
using namespace std;

#define all(v)				((v).begin()), ((v).end())
#define sz(v)				((int)((v).size()))
#define clr(v, d)			memset(v, d, sizeof(v))
#define rep(i, v)		for(int i=0;i<sz(v);++i)
#define lp(i, n)		for(int i=0;i<(int)(n);++i)
#define lpi(i, j, n)	for(int i=(j);i<(int)(n);++i)
#define lpd(i, j, n)	for(int i=(j);i>=(int)(n);--i)

typedef long long         ll;
const ll OO = 1e8;

#define pb					push_back
#define MP					make_pair
#define P(x)				cout<<#x<<" = { "<<x<<" }\n"
typedef long double   	  ld;
typedef vector<int>       vi;
typedef vector<double>    vd;
typedef vector< vi >      vvi;
typedef vector< vd >      vvd;
typedef vector<string>    vs;

int n ;
int a[5002][5002] ,ans[3] ;

int main ()
{
    string s ;
    cin>>n ;
    for(int i=1;i<=n;i++){
            cin>>s ;
            for(int j=1;j<=n;j++)
                a[i][j]=(s[j-1]-'0') ;
    }
    for(int i=1;i<=n;i++){
        for(int j=i+1;j<=n;j++){
            for(int k=j+1;k<=n;k++){
                if((a[i][j]&&a[j][k]&&a[k][i])||(a[i][k]&&a[k][j]&&a[j][i])){
                    cout<<i<<" "<<j<<" "<<k  ;
                    return 0 ;
                }
            }
        }
    }
    cout<<-1 ;
    return 0 ;
}


#include<set>
#include<map>
#include<list>
#include<iomanip>
#include<cmath>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<complex>
#include<sstream>
#include<iostream>
#include<fstream>
#include<algorithm>
#include<numeric>
#include<utility>
#include<functional>
#include<stdio.h>
#include<assert.h>
#include<memory.h>
#include<bitset>
using namespace std;

#define all(v)              ((v).begin()), ((v).end())
#define sz(v)               ((int)((v).size()))
#define clr(v, d)           memset(v, d, sizeof(v))
#define rep(i, v)       for(int i=0;i<sz(v);++i)
#define lp(i, n)        for(int i=0;i<(int)(n);++i)
#define lpi(i, j, n)    for(int i=(j);i<(int)(n);++i)
#define lpd(i, j, n)    for(int i=(j);i>=(int)(n);--i)

typedef long long         ll;
const ll OO = 1e8;

#define pb                  push_back
#define MP                  make_pair
#define P(x)                cout<<#x<<" = { "<<x<<" }\n"
typedef long double       ld;
typedef vector<int>       vi;
typedef vector<double>    vd;
typedef vector< vi >      vvi;
typedef vector< vd >      vvd;
typedef vector<string>    vs;

int n ;
string a[5002] ; int vis[5002], ans[3], f=0 ;

void dfs(int x,int p){
        if(f) return ;
        vis[x]=1;
        for(int i=0;i<n;i++){
            if(a[x][i]=='1'&&a[i][p]=='1'){
                cout<<p+1<<" "<<x+1<<" "<<i+1  ;
                exit(0) ;
            }
            if(!vis[i]&&a[x][i]=='1') dfs(i,x) ;
        }

}

int main ()
{
    string s ;
    cin>>n ;
    for(int i=0;i<n;i++){
            gets(a[i]) ;
    }
    for(int i=0;i<n;i++) dfs(i,i) ;
    cout<<-1 ;
    return 0 ;
}


#include<set>
#include<map>
#include<list>
#include<iomanip>
#include<cmath>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<complex>
#include<sstream>
#include<iostream>
#include<fstream>
#include<algorithm>
#include<numeric>
#include<utility>
#include<functional>
#include<stdio.h>
#include<assert.h>
#include<memory.h>
#include<bitset>
using namespace std;

#define all(v)              ((v).begin()), ((v).end())
#define sz(v)               ((int)((v).size()))
#define clr(v, d)           memset(v, d, sizeof(v))
#define rep(i, v)       for(int i=0;i<sz(v);++i)
#define lp(i, n)        for(int i=0;i<(int)(n);++i)
#define lpi(i, j, n)    for(int i=(j);i<(int)(n);++i)
#define lpd(i, j, n)    for(int i=(j);i>=(int)(n);--i)

typedef long long         ll;
const ll OO = 1e8;

#define pb                  push_back
#define MP                  make_pair
#define P(x)                cout<<#x<<" = { "<<x<<" }\n"
typedef long double       ld;
typedef vector<int>       vi;
typedef vector<double>    vd;
typedef vector< vi >      vvi;
typedef vector< vd >      vvd;
typedef vector<string>    vs;

int n ;
string a[5002] ; int vis[5002], ans[3], f=0 ;

void dfs(int x,int p){
        if(f) return ;
        vis[x]=1;
        for(int i=0;i<n;i++){
            if(a[x][i]=='1'&&a[i][p]=='1'){
                f=1 ;
                ans[0]=p+1 ;
                ans[1]=x+1 ;
                ans[2]=i+1 ;
                return ;
            }
            if(!vis[i]&&a[x][i]=='1') dfs(i,x) ;
        }

}

int main ()
{
    string s ;
    cin>>n ;
    for(int i=0;i<n;i++){
            cin>>a[i] ;
    }
    for(int i=0;i<n&&f==0;i++) dfs(i,i) ;
    if(f){
        cout<<ans[0]<<" "<<ans[1]<<" "<<ans[2]  ;
    } else
    cout<<-1 ;
    return 0 ;
}


#include<set>
#include<map>
#include<list>
#include<iomanip>
#include<cmath>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<complex>
#include<sstream>
#include<iostream>
#include<fstream>
#include<algorithm>
#include<numeric>
#include<utility>
#include<functional>
#include<stdio.h>
#include<assert.h>
#include<memory.h>
#include<bitset>
using namespace std;

#define all(v)              ((v).begin()), ((v).end())
#define sz(v)               ((int)((v).size()))
#define clr(v, d)           memset(v, d, sizeof(v))
#define rep(i, v)       for(int i=0;i<sz(v);++i)
#define lp(i, n)        for(int i=0;i<(int)(n);++i)
#define lpi(i, j, n)    for(int i=(j);i<(int)(n);++i)
#define lpd(i, j, n)    for(int i=(j);i>=(int)(n);--i)

typedef long long         ll;
const ll OO = 1e8;

#define pb                  push_back
#define MP                  make_pair
#define P(x)                cout<<#x<<" = { "<<x<<" }\n"
typedef long double       ld;
typedef vector<int>       vi;
typedef vector<double>    vd;
typedef vector< vi >      vvi;
typedef vector< vd >      vvd;
typedef vector<string>    vs;

int n ;
int a[5002][5002] ,vis[5002], ans[3], f=0 ;

void dfs(int x,int p){
        if(f==1) return ;
        vis[x]=1;
        for(int i=1;i<=n;i++){
            if(a[x][i]&&a[i][p]){
                f=1 ;
                ans[0]=x ;
                ans[1]=i;
                ans[2]=p ;
                return ;
            }
            if(!vis[i]) dfs(i,x) ;
        }

}

int main ()
{
    string s ;
    cin>>n ;
    for(int i=1;i<=n;i++){
            cin>>s ;
            for(int j=1;j<=n;j++)
                a[i][j]=(s[j-1]-'0') ;
    }
    for(int i=1;i<=n;i++) dfs(i,0);
    if(f){
        cout<<ans[0]<<" "<<ans[1]<<" "<<ans[3]  ;
    } else
    cout<<-1 ;
    return 0 ;
}


#include<set>
#include<map>
#include<list>
#include<iomanip>
#include<cmath>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<complex>
#include<sstream>
#include<iostream>
#include<fstream>
#include<algorithm>
#include<numeric>
#include<utility>
#include<functional>
#include<stdio.h>
#include<assert.h>
#include<memory.h>
#include<bitset>
using namespace std;

#define all(v)              ((v).begin()), ((v).end())
#define sz(v)               ((int)((v).size()))
#define clr(v, d)           memset(v, d, sizeof(v))
#define rep(i, v)       for(int i=0;i<sz(v);++i)
#define lp(i, n)        for(int i=0;i<(int)(n);++i)
#define lpi(i, j, n)    for(int i=(j);i<(int)(n);++i)
#define lpd(i, j, n)    for(int i=(j);i>=(int)(n);--i)

typedef long long         ll;
const ll OO = 1e8;

#define pb                  push_back
#define MP                  make_pair
#define P(x)                cout<<#x<<" = { "<<x<<" }\n"
typedef long double       ld;
typedef vector<int>       vi;
typedef vector<double>    vd;
typedef vector< vi >      vvi;
typedef vector< vd >      vvd;
typedef vector<string>    vs;

int n ;
int a[5002][5002] ,vis[5002], ans[3], f=0 ;

void dfs(int x,int p){
        if(f) return ;
        vis[x]=1;
        for(int i=1;i<=n;i++){
            if(a[x][i]&&a[i][p]){
                f=1 ;
                ans[0]=p ;
                ans[1]=x ;
                ans[2]=i ;
                return ;
            }
            if(!vis[i]&&a[x][i]) dfs(i,x) ;
        }

}

int main ()
{
    string s ;
    cin>>n ;
    for(int i=1;i<=n;i++){
            cin>>s ;
            for(int j=1;j<=n;j++)
                a[i][j]=(s[j-1]-'0') ;
    }
    for(int i=1;i<=n&&f==0;i++) dfs(i,0) ;
    if(f){
        cout<<ans[0]<<" "<<ans[1]<<" "<<ans[2]  ;
    } else
    cout<<-1 ;
    return 0 ;
}


#include <cstdio>
#include <deque>

using namespace std;

char a[5000][5001];
int n, v = 10;
int uses[5000];
deque<int> q;

int main()
{
	scanf("%d", &n);
	for(int i = 0;i < n;++i)
		scanf("%s", a[i]);
	for(int i = 0;i < n;++i)
		if(!uses[i])
		{
			uses[i] = v;
			q.push_back(i);
			while(!q.empty())
			{
				int t = q[0];
				q.pop_front();
				for(int j = 0;j < n;++j)
					if(a[t][j] == '1')
					{
						if(uses[t] == uses[j] + 2)
						{
							for(int k = 0;k < n;++k)
								if(uses[k] == uses[j] + 1 && a[j][k] == '1' && a[k][t]== '1')
								{
									printf("%d %d %d", j + 1, k + 1, t + 1);
									return 0;
								}
						}
						if(uses[j] == 0)
						{
							q.push_back(j);
							uses[j] = uses[t] + 1;
							v = uses[j] + 100;
						}
					}
			}
		}
	printf("-1");
	return 0;
}