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

bool v[123];

int main()
{
    string s;
    int i, cnt = 0, x = 0, k;
    v['a'] = v['e'] = v['i'] = v['o'] = v['u'] = true;
    cin >> s;
    for(i = 0; i < s.length(); i++)
    {
        if(v[s[i]])
        {
            if(i + 1 == s.length()) cout << s.substr(x, s.length() - x);
            cnt = 0;
        }
        else
            if(cnt == 2)
            {
                if(s[i - 2] == s[i - 1] && s[i - 1] == s[i])
                {
                    for(k = i; k < s.length(); k++)
                        if(s[k] != s[i])
                        {
                            if(!v[s[k]])
                            {
                                cout << s.substr(x, k - x) << " ";
                                x = k;
                            }
                            i = k - 1;
                            break;
                        }
                        else
                            if(k + 1 == s.length())
                            {
                                cout << s.substr(x, s.length() - x);
                                return 0;
                            }
                }
                else
                {
                    cout << s.substr(x, i - x) << " ";
                    x = i;
                    i--;
                }
                cnt = 0;
            }
            else
            {
                cnt++;
                if(i + 1 == s.length()) cout << s.substr(x, s.length() - x);
            }
    }
    return 0;
}


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

bool v[123];

int main()
{
    string s;
    int i, cnt = 0, x = 0;
    v['a'] = v['e'] = v['i'] = v['o'] = v['u'] = true;
    cin >> s;
    for(i = 0; i < s.length(); i++)
    {
        if(v[s[i]])
        {
            if(i + 1 == s.length()) cout << s.substr(x, s.length() - x);
            cnt = 0;
        }
        else
            if(cnt == 2)
            {
                if(!(s[i - 2] == s[i - 1] && s[i - 1] == s[i]))
                    cout << s.substr(x, i - x) << " ";
                i--;
                cnt = 0;
            }
            else
            {
                cnt++;
                if(i + 1 == s.length()) cout << s.substr(x, s.length() - 1);
            }
    }
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

int c, i, j, i1, n, t, p, ans1;
string s;
char k;

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

    cin >> s;

    for (i = 0; i < s.length(); i++)
    {
        if ((s[i] != 'a') && (s[i] != 'i') && (s[i] != 'e') && (s[i] != 'u') && (s[i] != 'o'))
        {
            if (s[i] == k)
                t++;

            c++;

            k = s[i];
        } else {
            c = 0;
            t = 0;
        }

        if (t + 1 == 3)
        {
            c--;
            t = 0;
        }
        if (c < 3)
        {
            cout << s[i];
        } else {
            cout << " " << s[i];
            c = 0;
        }
    }

    return 0;
}


#include <bits/stdc++.h>

using namespace std;

int c, i, j, i1, n, t, p, ans1;
string s;
char k;

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

    cin >> s;

    for (i = 0; i < s.length(); i++)
    {
        if ((s[i] != 'a') && (s[i] != 'i') && (s[i] != 'e') && (s[i] != 'u') && (s[i] != 'o'))
        {
            c++;
        } else {
            c = 0;
        }

        if (c < 3)
        {
            cout << s[i];
        } else {
            if ((s[i] == s[i - 1]) && (s[i] == s[i - 2]))
            {
                cout << s[i];
            } else {
                cout << " " << s[i];
                c = 0;
            }
        }
    }

    return 0;
}


#include <bits/stdc++.h>

using namespace std;

int c, i, j, i1, n, t, p, ans1;
string s;
char k;

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

    cin >> s;

    for (i = 0; i < s.length(); i++)
    {
        if ((s[i] != 'a') && (s[i] != 'i') && (s[i] != 'e') && (s[i] != 'u') && (s[i] != 'o'))
        {
            if (s[i] != k)
                c++;

            k = s[i];
        } else {
            c = 0;
        }
        if (c < 3)
        {
            cout << s[i];
        } else {
            cout << " " << s[i];
            c = 0;
        }
    }

    return 0;
}


#include <bits/stdc++.h>

using namespace std;

int c, i, j, i1, n, t, p, ans1;
string s;
char k;

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

    cin >> s;

    for (i = 0; i < s.length(); i++)
    {
        if ((s[i] != 'a') && (s[i] != 'i') && (s[i] != 'e') && (s[i] != 'u') && (s[i] != 'o'))
        {
            if (s[i] == k)
                t++;

            c++;

            k = s[i];
        } else {
            c = 0;
            t = 0;
        }

        if (t + 1 >= 3)
        {
            c--;
            t--;
        }
        if (c < 3)
        {
            cout << s[i];
        } else {
            cout << " " << s[i];
            c = 0;
        }
    }

    return 0;
}


#include <bits/stdc++.h>

using namespace std;

int c, i, j, i1, n, t, p, ans1;
string s;
char k;

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

    cin >> s;

    for (i = 0; i < s.length(); i++)
    {
        if ((s[i] != 'a') && (s[i] != 'i') && (s[i] != 'e') && (s[i] != 'u') && (s[i] != 'o'))
        {
            c++;
        } else {
            c = 0;
        }

        if (c < 3)
        {
            cout << s[i];
        } else {
            if ((s[i] == s[i - 1]) && (s[i] == s[i - 2]))
            {
                cout << s[i];
            } else {
                cout << " " << s[i];
                c = 1;
            }
        }
    }

    return 0;
}


#include <bits/stdc++.h>

using namespace std;

int c, i, j, i1, n, t, p, ans1;
string s;
char k;

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

    cin >> s;

    for (i = 0; i < s.length(); i++)
    {
        if ((s[i] != 'a') && (s[i] != 'i') && (s[i] != 'e') && (s[i] != 'u') && (s[i] != 'o'))
        {
            c++;
        } else {
            c = 0;
        }

        if (c < 3)
        {
            cout << s[i];
        } else {
            if ((s[i] == s[i - 1]) && (s[i] == s[i - 2]))
            {
                cout << s[i];
            } else {
                cout << " " << s[i];
                c = 1;
            }
        }
    }

    return 0;
}


#include <bits/stdc++.h>

using namespace std;

int c, i, j, i1, n, t, p, ans1;
string s;
char k;

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

    cin >> s;

    for (i = 0; i < s.length(); i++)
    {
        if ((s[i] != 'a') && (s[i] != 'i') && (s[i] != 'e') && (s[i] != 'u') && (s[i] != 'o'))
        {
            if (s[i] == k)
                t++;

            c++;

            k = s[i];
        } else {
            c = 0;
            t = 0;
        }

        if (t + 1 == 3)
        {
            c = 0;
            t = 0;
        }
        if (c < 3)
        {
            cout << s[i];
        } else {
            cout << " " << s[i];
            c = 0;
        }
    }

    return 0;
}


/*input
lllbcdx
*/

#include <bits/stdc++.h>

using namespace std;

#define Fi              first
#define Se              second
#define S(n)            cin >> n
#define P(n)            cout << n
#define mp              make_pair
#define pb              push_back
#define pp              pop_back
#define pf              pop_front
#define sp              cout << " "
#define nl              cout << "\n"
#define MIN(con)        (*min_element(ALL(con)))
#define MAX(con)        (*max_element(ALL(con)))
#define mem(n, a)       memset((n), (a), sizeof(n))
#define ALL(cont)       (cont).begin(),(cont).end()
#define NX(cont)        next_permutation(ALL(cont))
#define PX(cont)        prev_permutation(ALL(cont))
#define F(i, n, r)      for(int i = (n); i < (r); i ++)
#define prec(n)         cout << fixed << setprecision(n)
#define PI              3.14159265358979323846264338327951
#define fast            ios_base:: sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define FH(it,c)   for(__typeof((c).begin()) it = (c).begin(); it != (c).end(); ++ it)

using ll = long long;
using ss = stringstream;
using ul = unsigned long long;

template < typename T > inline T LCM(T a, T b)            { return (a * b) / GCD(a, b); }
template < typename T > inline T GCD(T a, T b)            { ll t; while(a) { t = a; a = b % a; b = t; } return b; }
template < typename T > inline T _max(T a, T b, T c)      { return max( max( a, b ), c ); }
template < typename T > inline T _min(T a, T b, T c)      { return min( min( a, b ), c ); }
template < typename T > inline string toString(T a)       {return to_string(a); }  // Convert int to string
template < typename T > inline void toInt(string s, T &x) { ss str(s); str >> x;}  // Convert string to int

inline void lower(string &s) {
  FH(it,s)
    *it = tolower(*it);
}

inline void upper(string &s) {
  FH(it,s)
    *it = toupper(*it);
}

const ll inf    =  999999999999999999;

bool palin(string s)
{
    string s1 = s;
    reverse(s.begin(), s.end());
    return (s == s1);
}

ll triangle(ll n)
{
    return (n * (n + 1)) / 2;
}

bool check(ll n)
{
    if(n == 1) return 0;
    if(n == 2 or n == 3) return 1;
    if(n % 2 == 0 or n % 3 == 0) return 0;

    for(ll i = 5; i * i <= n; i += 6) if(n % i == 0 or n % (i + 2) == 0) return 0;
    return 1;
}

int main ()
{
    fast;
    string s;
    cin >> s;
    int n = s.length();

    map < char, int > m {{'a',-1}, {'e',-1}, {'i',-1}, {'o',-1}, {'u',-1}};

    for(char c = 'a'; c <= 'z'; c ++) {
        m[c] = min(m[c], 0);
    }

    int cnt = 0;
    string s1 = "";
    for(int i = 0; i < n; i ++) {
        int j = i;
        i ++;
        while(s[j] == s[i] and i < n) {
            s1 += s[i];
            i ++;
            cnt = 0;
        }
        i --;
        if(m[s[i]] == 0) {
            cnt ++;
        }
        else if(m[s[i]] == -1) {
            cnt = 0;
        }
        if(cnt == 3) {
            cout << s1, sp;
            s1 = "";
            cnt = 1;
        }
        s1 += s[i];
    }
    if(s1 != "") {
        cout << s1;
    }
    nl;
    return 0;
}


/*input

*/

#include <bits/stdc++.h>

using namespace std;

#define Fi              first
#define Se              second
#define S(n)            cin >> n
#define P(n)            cout << n
#define mp              make_pair
#define pb              push_back
#define pp              pop_back
#define pf              pop_front
#define sp              cout << " "
#define nl              cout << "\n"
#define MIN(con)        (*min_element(ALL(con)))
#define MAX(con)        (*max_element(ALL(con)))
#define mem(n, a)       memset((n), (a), sizeof(n))
#define ALL(cont)       (cont).begin(),(cont).end()
#define NX(cont)        next_permutation(ALL(cont))
#define PX(cont)        prev_permutation(ALL(cont))
#define F(i, n, r)      for(int i = (n); i < (r); i ++)
#define prec(n)         cout << fixed << setprecision(n)
#define PI              3.14159265358979323846264338327951
#define fast            ios_base:: sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define FH(it,c)   for(__typeof((c).begin()) it = (c).begin(); it != (c).end(); ++ it)

using ll = long long;
using ss = stringstream;
using ul = unsigned long long;

template < typename T > inline T LCM(T a, T b)            { return (a * b) / GCD(a, b); }
template < typename T > inline T GCD(T a, T b)            { ll t; while(a) { t = a; a = b % a; b = t; } return b; }
template < typename T > inline T _max(T a, T b, T c)      { return max( max( a, b ), c ); }
template < typename T > inline T _min(T a, T b, T c)      { return min( min( a, b ), c ); }
template < typename T > inline string toString(T a)       {return to_string(a); }  // Convert int to string
template < typename T > inline void toInt(string s, T &x) { ss str(s); str >> x;}  // Convert string to int

inline void lower(string &s) {
  FH(it,s)
    *it = tolower(*it);
}

inline void upper(string &s) {
  FH(it,s)
    *it = toupper(*it);
}

const ll inf    =  999999999999999999;

bool palin(string s)
{
    string s1 = s;
    reverse(s.begin(), s.end());
    return (s == s1);
}

ll triangle(ll n)
{
    return (n * (n + 1)) / 2;
}

bool check(ll n)
{
    if(n == 1) return 0;
    if(n == 2 or n == 3) return 1;
    if(n % 2 == 0 or n % 3 == 0) return 0;

    for(ll i = 5; i * i <= n; i += 6) if(n % i == 0 or n % (i + 2) == 0) return 0;
    return 1;
}

int main ()
{
    fast;
    string s;
    cin >> s;
    int n = s.length();

    string s1 = "aeiou";

    for(int i = 0; i < n; i ++) {
        if((s[i] != s[i + 1] or s[i + 1] != s[i + 2]) and s1.find(s[i]) == -1 and s1.find(s[i + 1]) == -1 and s1.find(s[i + 2]) == -1 and s[i] != '\0' and s[i + 1] != '\0') {
            cout << s[i] << s[i + 1] << " ";
            i ++;
        }
        else {
            cout << s[i];
        }
    }
    nl;
    return 0;
}


/*input

*/

#include <bits/stdc++.h>

using namespace std;

#define Fi              first
#define Se              second
#define S(n)            cin >> n
#define P(n)            cout << n
#define mp              make_pair
#define pb              push_back
#define pp              pop_back
#define pf              pop_front
#define sp              cout << " "
#define nl              cout << "\n"
#define MIN(con)        (*min_element(ALL(con)))
#define MAX(con)        (*max_element(ALL(con)))
#define mem(n, a)       memset((n), (a), sizeof(n))
#define ALL(cont)       (cont).begin(),(cont).end()
#define NX(cont)        next_permutation(ALL(cont))
#define PX(cont)        prev_permutation(ALL(cont))
#define F(i, n, r)      for(int i = (n); i < (r); i ++)
#define prec(n)         cout << fixed << setprecision(n)
#define PI              3.14159265358979323846264338327951
#define fast            ios_base:: sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define FH(it,c)   for(__typeof((c).begin()) it = (c).begin(); it != (c).end(); ++ it)

using ll = long long;
using ss = stringstream;
using ul = unsigned long long;

template < typename T > inline T LCM(T a, T b)            { return (a * b) / GCD(a, b); }
template < typename T > inline T GCD(T a, T b)            { ll t; while(a) { t = a; a = b % a; b = t; } return b; }
template < typename T > inline T _max(T a, T b, T c)      { return max( max( a, b ), c ); }
template < typename T > inline T _min(T a, T b, T c)      { return min( min( a, b ), c ); }
template < typename T > inline string toString(T a)       {return to_string(a); }  // Convert int to string
template < typename T > inline void toInt(string s, T &x) { ss str(s); str >> x;}  // Convert string to int

inline void lower(string &s) {
  FH(it,s)
    *it = tolower(*it);
}

inline void upper(string &s) {
  FH(it,s)
    *it = toupper(*it);
}

const ll inf    =  999999999999999999;

bool palin(string s)
{
    string s1 = s;
    reverse(s.begin(), s.end());
    return (s == s1);
}

ll triangle(ll n)
{
    return (n * (n + 1)) / 2;
}

bool check(ll n)
{
    if(n == 1) return 0;
    if(n == 2 or n == 3) return 1;
    if(n % 2 == 0 or n % 3 == 0) return 0;

    for(ll i = 5; i * i <= n; i += 6) if(n % i == 0 or n % (i + 2) == 0) return 0;
    return 1;
}

int main ()
{
    fast;
    string s;
    cin >> s;
    int n = s.length();

    string s1 = "aeiou";

    for(int i = 0; i < n; i ++) {
        if((s[i] != s[i + 1] or s[i + 1] != s[i + 2]) and s1.find(s[i]) == -1 and s1.find(s[i + 1]) == -1 and s1.find(s[i + 2]) == -1 and i + 1  < n) {
            cout << s[i] << s[i + 1] << " ";
            i ++;
        }
        else {
            cout << s[i];
        }
    }
    nl;
    return 0;
}


/*input
jxegxxx
*/

#include <bits/stdc++.h>

using namespace std;

#define Fi              first
#define Se              second
#define S(n)            cin >> n
#define P(n)            cout << n
#define mp              make_pair
#define pb              push_back
#define pp              pop_back
#define pf              pop_front
#define sp              cout << " "
#define nl              cout << "\n"
#define MIN(con)        (*min_element(ALL(con)))
#define MAX(con)        (*max_element(ALL(con)))
#define mem(n, a)       memset((n), (a), sizeof(n))
#define ALL(cont)       (cont).begin(),(cont).end()
#define NX(cont)        next_permutation(ALL(cont))
#define PX(cont)        prev_permutation(ALL(cont))
#define F(i, n, r)      for(int i = (n); i < (r); i ++)
#define prec(n)         cout << fixed << setprecision(n)
#define PI              3.14159265358979323846264338327951
#define fast            ios_base:: sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define FH(it,c)   for(__typeof((c).begin()) it = (c).begin(); it != (c).end(); ++ it)

using ll = long long;
using ss = stringstream;
using ul = unsigned long long;

template < typename T > inline T LCM(T a, T b)            { return (a * b) / GCD(a, b); }
template < typename T > inline T GCD(T a, T b)            { ll t; while(a) { t = a; a = b % a; b = t; } return b; }
template < typename T > inline T _max(T a, T b, T c)      { return max( max( a, b ), c ); }
template < typename T > inline T _min(T a, T b, T c)      { return min( min( a, b ), c ); }
template < typename T > inline string toString(T a)       {return to_string(a); }  // Convert int to string
template < typename T > inline void toInt(string s, T &x) { ss str(s); str >> x;}  // Convert string to int

inline void lower(string &s) {
  FH(it,s)
    *it = tolower(*it);
}

inline void upper(string &s) {
  FH(it,s)
    *it = toupper(*it);
}

const ll inf    =  999999999999999999;

bool palin(string s)
{
    string s1 = s;
    reverse(s.begin(), s.end());
    return (s == s1);
}

ll triangle(ll n)
{
    return (n * (n + 1)) / 2;
}

bool check(ll n)
{
    if(n == 1) return 0;
    if(n == 2 or n == 3) return 1;
    if(n % 2 == 0 or n % 3 == 0) return 0;

    for(ll i = 5; i * i <= n; i += 6) if(n % i == 0 or n % (i + 2) == 0) return 0;
    return 1;
}

int main ()
{
    fast;
    string s;
    cin >> s;
    int n = s.length();

    map < char, int > m {{'a',-1}, {'e',-1}, {'i',-1}, {'o',-1}, {'u',-1}};

    for(char c = 'a'; c <= 'z'; c ++) {
        m[c] = min(m[c], 0);
    }

    int cnt = 0;
    int i = 0;
    string s1 = "";

    while(i < n) {
        if(m[s[i]] == -1) {
            cnt = 0;
            s1 += s[i];
            i ++;
        }
        else if(m[s[i]] == 0) {
            if(cnt == 0) {
                int j = i;
                int u = 0;
                while(s[j] == s[i] and i < n) {
                    s1 += s[i];
                    i ++;
                    u ++;
                }
                if(u < 3) {
                    cnt += u;
                }
            }
            else {
                int j = i;
                cnt ++;
                i ++;
                while(cnt < 3 and s[j] == s[i]) {
                    cnt ++;
                    i ++;
                    s1 += s[i];
                }
                if(cnt == 3) {
                    cout << s1 << " ";
                    cnt = 0;
                    s1 = "";
                    s1 += s[i];
                }
            }
        }
    }
    if(s1 != "") {
        cout << s1;
    }
    nl;
    return 0;
}


/*input

*/

#include <bits/stdc++.h>

using namespace std;

#define Fi              first
#define Se              second
#define S(n)            cin >> n
#define P(n)            cout << n
#define mp              make_pair
#define pb              push_back
#define pp              pop_back
#define pf              pop_front
#define sp              cout << " "
#define nl              cout << "\n"
#define MIN(con)        (*min_element(ALL(con)))
#define MAX(con)        (*max_element(ALL(con)))
#define mem(n, a)       memset((n), (a), sizeof(n))
#define ALL(cont)       (cont).begin(),(cont).end()
#define NX(cont)        next_permutation(ALL(cont))
#define PX(cont)        prev_permutation(ALL(cont))
#define F(i, n, r)      for(int i = (n); i < (r); i ++)
#define prec(n)         cout << fixed << setprecision(n)
#define PI              3.14159265358979323846264338327951
#define fast            ios_base:: sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define FH(it,c)   for(__typeof((c).begin()) it = (c).begin(); it != (c).end(); ++ it)

using ll = long long;
using ss = stringstream;
using ul = unsigned long long;

template < typename T > inline T LCM(T a, T b)            { return (a * b) / GCD(a, b); }
template < typename T > inline T GCD(T a, T b)            { ll t; while(a) { t = a; a = b % a; b = t; } return b; }
template < typename T > inline T _max(T a, T b, T c)      { return max( max( a, b ), c ); }
template < typename T > inline T _min(T a, T b, T c)      { return min( min( a, b ), c ); }
template < typename T > inline string toString(T a)       {return to_string(a); }  // Convert int to string
template < typename T > inline void toInt(string s, T &x) { ss str(s); str >> x;}  // Convert string to int

inline void lower(string &s) {
  FH(it,s)
    *it = tolower(*it);
}

inline void upper(string &s) {
  FH(it,s)
    *it = toupper(*it);
}

const ll inf    =  999999999999999999;

bool palin(string s)
{
    string s1 = s;
    reverse(s.begin(), s.end());
    return (s == s1);
}

ll triangle(ll n)
{
    return (n * (n + 1)) / 2;
}

bool check(ll n)
{
    if(n == 1) return 0;
    if(n == 2 or n == 3) return 1;
    if(n % 2 == 0 or n % 3 == 0) return 0;

    for(ll i = 5; i * i <= n; i += 6) if(n % i == 0 or n % (i + 2) == 0) return 0;
    return 1;
}

int main ()
{
    fast;
    string s;
    cin >> s;
    int n = s.length();

    map < char, int > m {{'a',-1}, {'e',-1}, {'i',-1}, {'o',-1}, {'u',-1}};

    for(char c = 'a'; c <= 'z'; c ++) {
        m[c] = min(m[c], 0);
    }

    int cnt = 0;
    int i = 0;
    string s1 = "";

    while(i < n) {
        if(m[s[i]] == -1) {
            cnt = 0;
            s1 += s[i];
            i ++;
        }
        else if(m[s[i]] == 0) {
            if(cnt == 0) {
                int j = i;
                int u = 0;
                while(s[j] == s[i] and i < n) {
                    s1 += s[i];
                    i ++;
                    u ++;
                }
                if(u < 3) {
                    cnt += u;
                }
            }
            else {
                int j = i;
                cnt ++;
                i ++;
                while(cnt < 3 and s[j] == s[i]) {
                    cnt ++;
                    s1 += s[i];
                    i ++;
                }
                if(cnt == 3) {
                    cout << s1 << " ";
                    cnt = 1;
                    s1 = "";
                }
                s1 += s[j];
            }
        }
    }
    if(s1 != "") {
        cout << s1;
    }
    nl;
    return 0;
}


/*input
asdfasdf

*/

#include <bits/stdc++.h>

using namespace std;

#define Fi              first
#define Se              second
#define S(n)            cin >> n
#define P(n)            cout << n
#define mp              make_pair
#define pb              push_back
#define pp              pop_back
#define pf              pop_front
#define sp              cout << " "
#define nl              cout << "\n"
#define MIN(con)        (*min_element(ALL(con)))
#define MAX(con)        (*max_element(ALL(con)))
#define mem(n, a)       memset((n), (a), sizeof(n))
#define ALL(cont)       (cont).begin(),(cont).end()
#define NX(cont)        next_permutation(ALL(cont))
#define PX(cont)        prev_permutation(ALL(cont))
#define F(i, n, r)      for(int i = (n); i < (r); i ++)
#define prec(n)         cout << fixed << setprecision(n)
#define PI              3.14159265358979323846264338327951
#define fast            ios_base:: sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define FH(it,c)   for(__typeof((c).begin()) it = (c).begin(); it != (c).end(); ++ it)

using ll = long long;
using ss = stringstream;
using ul = unsigned long long;

template < typename T > inline T LCM(T a, T b)            { return (a * b) / GCD(a, b); }
template < typename T > inline T GCD(T a, T b)            { ll t; while(a) { t = a; a = b % a; b = t; } return b; }
template < typename T > inline T _max(T a, T b, T c)      { return max( max( a, b ), c ); }
template < typename T > inline T _min(T a, T b, T c)      { return min( min( a, b ), c ); }
template < typename T > inline string toString(T a)       {return to_string(a); }  // Convert int to string
template < typename T > inline void toInt(string s, T &x) { ss str(s); str >> x;}  // Convert string to int

inline void lower(string &s) {
  FH(it,s)
    *it = tolower(*it);
}

inline void upper(string &s) {
  FH(it,s)
    *it = toupper(*it);
}

const ll inf    =  999999999999999999;

bool palin(string s)
{
    string s1 = s;
    reverse(s.begin(), s.end());
    return (s == s1);
}

ll triangle(ll n)
{
    return (n * (n + 1)) / 2;
}

bool check(ll n)
{
    if(n == 1) return 0;
    if(n == 2 or n == 3) return 1;
    if(n % 2 == 0 or n % 3 == 0) return 0;

    for(ll i = 5; i * i <= n; i += 6) if(n % i == 0 or n % (i + 2) == 0) return 0;
    return 1;
}

int main ()
{
    fast;
    string s;
    cin >> s;
    int n = s.length();

    map < char, int > m {{'a',-1}, {'e',-1}, {'i',-1}, {'o',-1}, {'u',-1}};

    for(char c = 'a'; c <= 'z'; c ++) {
        m[c] = min(m[c], 0);
    }

    int cnt = 0;
    string s1 = "";
    for(int i = 0; i < n; i ++) {
        if(m[s[i]] == 0) {
            cnt ++;
        }
        else if(m[s[i]] == -1) {
            cnt = 0;
        }
        if(cnt == 3) {
            cout << s1, sp;
            s1 = "";
            cnt = 0;
        }
        s1 += s[i];
    }
    if(s1 != "") {
        cout << s1;
    }
    nl;
    return 0;
}


/*input

*/

#include <bits/stdc++.h>

using namespace std;

#define Fi              first
#define Se              second
#define S(n)            cin >> n
#define P(n)            cout << n
#define mp              make_pair
#define pb              push_back
#define pp              pop_back
#define pf              pop_front
#define sp              cout << " "
#define nl              cout << "\n"
#define MIN(con)        (*min_element(ALL(con)))
#define MAX(con)        (*max_element(ALL(con)))
#define mem(n, a)       memset((n), (a), sizeof(n))
#define ALL(cont)       (cont).begin(),(cont).end()
#define NX(cont)        next_permutation(ALL(cont))
#define PX(cont)        prev_permutation(ALL(cont))
#define F(i, n, r)      for(int i = (n); i < (r); i ++)
#define prec(n)         cout << fixed << setprecision(n)
#define PI              3.14159265358979323846264338327951
#define fast            ios_base:: sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define FH(it,c)   for(__typeof((c).begin()) it = (c).begin(); it != (c).end(); ++ it)

using ll = long long;
using ss = stringstream;
using ul = unsigned long long;

template < typename T > inline T LCM(T a, T b)            { return (a * b) / GCD(a, b); }
template < typename T > inline T GCD(T a, T b)            { ll t; while(a) { t = a; a = b % a; b = t; } return b; }
template < typename T > inline T _max(T a, T b, T c)      { return max( max( a, b ), c ); }
template < typename T > inline T _min(T a, T b, T c)      { return min( min( a, b ), c ); }
template < typename T > inline string toString(T a)       {return to_string(a); }  // Convert int to string
template < typename T > inline void toInt(string s, T &x) { ss str(s); str >> x;}  // Convert string to int

inline void lower(string &s) {
  FH(it,s)
    *it = tolower(*it);
}

inline void upper(string &s) {
  FH(it,s)
    *it = toupper(*it);
}

const ll inf    =  999999999999999999;

bool palin(string s)
{
    string s1 = s;
    reverse(s.begin(), s.end());
    return (s == s1);
}

ll triangle(ll n)
{
    return (n * (n + 1)) / 2;
}

bool check(ll n)
{
    if(n == 1) return 0;
    if(n == 2 or n == 3) return 1;
    if(n % 2 == 0 or n % 3 == 0) return 0;

    for(ll i = 5; i * i <= n; i += 6) if(n % i == 0 or n % (i + 2) == 0) return 0;
    return 1;
}

int main ()
{
    fast;
    string s;
    cin >> s;
    int n = s.length();

    map < char, int > m {{'a',-1}, {'e',-1}, {'i',-1}, {'o',-1}, {'u',-1}};

    for(char c = 'a'; c <= 'z'; c ++) {
        m[c] = min(m[c], 0);
    }

    int cnt = 0;
    string s1 = "";
    for(int i = 0; i < n; i ++) {
        if(m[s[i]] == 0) {
            cnt ++;
        }
        else if(m[s[i]] == -1) {
            cnt = 0;
        }
        if(cnt == 3) {
            cout << s1, sp;
            s1 = "";
            cnt = 1;
        }
        s1 += s[i];
    }
    if(s1 != "") {
        cout << s1;
    }
    nl;
    return 0;
}


/*input

*/

#include <bits/stdc++.h>

using namespace std;

#define Fi              first
#define Se              second
#define S(n)            cin >> n
#define P(n)            cout << n
#define mp              make_pair
#define pb              push_back
#define pp              pop_back
#define pf              pop_front
#define sp              cout << " "
#define nl              cout << "\n"
#define MIN(con)        (*min_element(ALL(con)))
#define MAX(con)        (*max_element(ALL(con)))
#define mem(n, a)       memset((n), (a), sizeof(n))
#define ALL(cont)       (cont).begin(),(cont).end()
#define NX(cont)        next_permutation(ALL(cont))
#define PX(cont)        prev_permutation(ALL(cont))
#define F(i, n, r)      for(int i = (n); i < (r); i ++)
#define prec(n)         cout << fixed << setprecision(n)
#define PI              3.14159265358979323846264338327951
#define fast            ios_base:: sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define FH(it,c)   for(__typeof((c).begin()) it = (c).begin(); it != (c).end(); ++ it)

using ll = long long;
using ss = stringstream;
using ul = unsigned long long;

template < typename T > inline T LCM(T a, T b)            { return (a * b) / GCD(a, b); }
template < typename T > inline T GCD(T a, T b)            { ll t; while(a) { t = a; a = b % a; b = t; } return b; }
template < typename T > inline T _max(T a, T b, T c)      { return max( max( a, b ), c ); }
template < typename T > inline T _min(T a, T b, T c)      { return min( min( a, b ), c ); }
template < typename T > inline string toString(T a)       {return to_string(a); }  // Convert int to string
template < typename T > inline void toInt(string s, T &x) { ss str(s); str >> x;}  // Convert string to int

inline void lower(string &s) {
  FH(it,s)
    *it = tolower(*it);
}

inline void upper(string &s) {
  FH(it,s)
    *it = toupper(*it);
}

const ll inf    =  999999999999999999;

bool palin(string s)
{
    string s1 = s;
    reverse(s.begin(), s.end());
    return (s == s1);
}

ll triangle(ll n)
{
    return (n * (n + 1)) / 2;
}

bool check(ll n)
{
    if(n == 1) return 0;
    if(n == 2 or n == 3) return 1;
    if(n % 2 == 0 or n % 3 == 0) return 0;

    for(ll i = 5; i * i <= n; i += 6) if(n % i == 0 or n % (i + 2) == 0) return 0;
    return 1;
}

int main ()
{
    fast;
    string s;
    cin >> s;
    int n = s.length();

    map < char, int > m {{'a',-1}, {'e',-1}, {'i',-1}, {'o',-1}, {'u',-1}};

    for(char c = 'a'; c <= 'z'; c ++) {
        m[c] = min(m[c], 0);
    }

    int cnt = 0;
    int i = 0;
    string s1 = "";

    while(i < n) {
        if(m[s[i]] == -1) {
            cnt = 0;
            s1 += s[i];
            i ++;
        }
        else if(m[s[i]] == 0) {
            if(cnt == 0) {
                int j = i;
                int u = 0;
                while(s[j] == s[i] and i < n) {
                    s1 += s[i];
                    i ++;
                    u ++;
                }
                if(u < 3) {
                    cnt += u;
                }
                else {
                    cnt = 2;
                }
            }
            else {
                int j = i;
                cnt ++;
                i ++;
                while(cnt < 3 and s[j] == s[i]) {
                    cnt ++;
                    s1 += s[i];
                    i ++;
                }
                if(cnt == 3) {
                    cout << s1 << " ";
                    cnt = 1;
                    s1 = "";
                }
                s1 += s[j];
            }
        }
    }
    if(s1 != "") {
        cout << s1;
    }
    nl;
    return 0;
}


/*input
asdfasdf

*/

#include <bits/stdc++.h>

using namespace std;

#define Fi              first
#define Se              second
#define S(n)            cin >> n
#define P(n)            cout << n
#define mp              make_pair
#define pb              push_back
#define pp              pop_back
#define pf              pop_front
#define sp              cout << " "
#define nl              cout << "\n"
#define MIN(con)        (*min_element(ALL(con)))
#define MAX(con)        (*max_element(ALL(con)))
#define mem(n, a)       memset((n), (a), sizeof(n))
#define ALL(cont)       (cont).begin(),(cont).end()
#define NX(cont)        next_permutation(ALL(cont))
#define PX(cont)        prev_permutation(ALL(cont))
#define F(i, n, r)      for(int i = (n); i < (r); i ++)
#define prec(n)         cout << fixed << setprecision(n)
#define PI              3.14159265358979323846264338327951
#define fast            ios_base:: sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define FH(it,c)   for(__typeof((c).begin()) it = (c).begin(); it != (c).end(); ++ it)

using ll = long long;
using ss = stringstream;
using ul = unsigned long long;

template < typename T > inline T LCM(T a, T b)            { return (a * b) / GCD(a, b); }
template < typename T > inline T GCD(T a, T b)            { ll t; while(a) { t = a; a = b % a; b = t; } return b; }
template < typename T > inline T _max(T a, T b, T c)      { return max( max( a, b ), c ); }
template < typename T > inline T _min(T a, T b, T c)      { return min( min( a, b ), c ); }
template < typename T > inline string toString(T a)       {return to_string(a); }  // Convert int to string
template < typename T > inline void toInt(string s, T &x) { ss str(s); str >> x;}  // Convert string to int

inline void lower(string &s) {
  FH(it,s)
    *it = tolower(*it);
}

inline void upper(string &s) {
  FH(it,s)
    *it = toupper(*it);
}

const ll inf    =  999999999999999999;

bool palin(string s)
{
    string s1 = s;
    reverse(s.begin(), s.end());
    return (s == s1);
}

ll triangle(ll n)
{
    return (n * (n + 1)) / 2;
}

bool check(ll n)
{
    if(n == 1) return 0;
    if(n == 2 or n == 3) return 1;
    if(n % 2 == 0 or n % 3 == 0) return 0;

    for(ll i = 5; i * i <= n; i += 6) if(n % i == 0 or n % (i + 2) == 0) return 0;
    return 1;
}

int main ()
{
    fast;
    string s;
    cin >> s;
    int n = s.length();

    map < char, int > m {{'a',-1}, {'e',-1}, {'i',-1}, {'o',-1}, {'u',-1}};

    for(char c = 'a'; c <= 'z'; c ++) {
        m[c] = min(m[c], 0);
    }

    int cnt = 0;
    int i = 0;
    string s1 = "";

    while(i < n) {
        if(m[s[i]] == -1) {
            cnt = 0;
            s1 += s[i];
            i ++;
        }
        else if(m[s[i]] == 0) {
            if(cnt == 0) {
                int j = i;
                int u = 0;
                while(s[j] == s[i] and i < n) {
                    s1 += s[i];
                    i ++;
                    u ++;
                }
                if(u < 3) {
                    cnt += u;
                }
            }
            else {
                cnt ++;
                int j = i;
                while(cnt < 3 and s[j] == s[i]) {
                    cnt ++;
                    s1 += s[i];
                    i ++;
                }
                if(cnt == 3) {
                    cout << s1 << " ";
                    cnt = 0;
                    s1 = "";
                }
            }
        }
    }
    if(s1 != "") {
        cout << s1;
    }
    nl;
    return 0;
}


/*input
hellno

*/

#include <bits/stdc++.h>

using namespace std;

#define Fi              first
#define Se              second
#define S(n)            cin >> n
#define P(n)            cout << n
#define mp              make_pair
#define pb              push_back
#define pp              pop_back
#define pf              pop_front
#define sp              cout << " "
#define nl              cout << "\n"
#define MIN(con)        (*min_element(ALL(con)))
#define MAX(con)        (*max_element(ALL(con)))
#define mem(n, a)       memset((n), (a), sizeof(n))
#define ALL(cont)       (cont).begin(),(cont).end()
#define NX(cont)        next_permutation(ALL(cont))
#define PX(cont)        prev_permutation(ALL(cont))
#define F(i, n, r)      for(int i = (n); i < (r); i ++)
#define prec(n)         cout << fixed << setprecision(n)
#define PI              3.14159265358979323846264338327951
#define fast            ios_base:: sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define FH(it,c)   for(__typeof((c).begin()) it = (c).begin(); it != (c).end(); ++ it)

using ll = long long;
using ss = stringstream;
using ul = unsigned long long;

template < typename T > inline T LCM(T a, T b)            { return (a * b) / GCD(a, b); }
template < typename T > inline T GCD(T a, T b)            { ll t; while(a) { t = a; a = b % a; b = t; } return b; }
template < typename T > inline T _max(T a, T b, T c)      { return max( max( a, b ), c ); }
template < typename T > inline T _min(T a, T b, T c)      { return min( min( a, b ), c ); }
template < typename T > inline string toString(T a)       {return to_string(a); }  // Convert int to string
template < typename T > inline void toInt(string s, T &x) { ss str(s); str >> x;}  // Convert string to int

inline void lower(string &s) {
  FH(it,s)
    *it = tolower(*it);
}

inline void upper(string &s) {
  FH(it,s)
    *it = toupper(*it);
}

const ll inf    =  999999999999999999;

bool palin(string s)
{
    string s1 = s;
    reverse(s.begin(), s.end());
    return (s == s1);
}

ll triangle(ll n)
{
    return (n * (n + 1)) / 2;
}

bool check(ll n)
{
    if(n == 1) return 0;
    if(n == 2 or n == 3) return 1;
    if(n % 2 == 0 or n % 3 == 0) return 0;

    for(ll i = 5; i * i <= n; i += 6) if(n % i == 0 or n % (i + 2) == 0) return 0;
    return 1;
}

int main ()
{
    fast;
    string s;
    cin >> s;
    int n = s.length();

    map < char, int > m {{'a',-1}, {'e',-1}, {'i',-1}, {'o',-1}, {'u',-1}};

    for(char c = 'a'; c <= 'z'; c ++) {
        m[c] = min(m[c], 0);
    }

    int cnt = 0;
    string s1 = "";
    for(int i = 0; i < n; i ++) {
        int j = i;
        i ++;
        while(s[j] == s[i] and i < n) {
            s1 += s[i];
            i ++;
            cnt = 1;
        }
        i --;
        if(m[s[i]] == 0) {
            cnt ++;
        }
        else if(m[s[i]] == -1) {
            cnt = 0;
        }
        if(cnt == 3) {
            cout << s1, sp;
            s1 = "";
            cnt = 1;
        }
        s1 += s[i];
    }
    if(s1 != "") {
        cout << s1;
    }
    nl;
    return 0;
}


/*input
hellno

*/

#include <bits/stdc++.h>

using namespace std;

#define Fi              first
#define Se              second
#define S(n)            cin >> n
#define P(n)            cout << n
#define mp              make_pair
#define pb              push_back
#define pp              pop_back
#define pf              pop_front
#define sp              cout << " "
#define nl              cout << "\n"
#define MIN(con)        (*min_element(ALL(con)))
#define MAX(con)        (*max_element(ALL(con)))
#define mem(n, a)       memset((n), (a), sizeof(n))
#define ALL(cont)       (cont).begin(),(cont).end()
#define NX(cont)        next_permutation(ALL(cont))
#define PX(cont)        prev_permutation(ALL(cont))
#define F(i, n, r)      for(int i = (n); i < (r); i ++)
#define prec(n)         cout << fixed << setprecision(n)
#define PI              3.14159265358979323846264338327951
#define fast            ios_base:: sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define FH(it,c)   for(__typeof((c).begin()) it = (c).begin(); it != (c).end(); ++ it)

using ll = long long;
using ss = stringstream;
using ul = unsigned long long;

template < typename T > inline T LCM(T a, T b)            { return (a * b) / GCD(a, b); }
template < typename T > inline T GCD(T a, T b)            { ll t; while(a) { t = a; a = b % a; b = t; } return b; }
template < typename T > inline T _max(T a, T b, T c)      { return max( max( a, b ), c ); }
template < typename T > inline T _min(T a, T b, T c)      { return min( min( a, b ), c ); }
template < typename T > inline string toString(T a)       {return to_string(a); }  // Convert int to string
template < typename T > inline void toInt(string s, T &x) { ss str(s); str >> x;}  // Convert string to int

inline void lower(string &s) {
  FH(it,s)
    *it = tolower(*it);
}

inline void upper(string &s) {
  FH(it,s)
    *it = toupper(*it);
}

const ll inf    =  999999999999999999;

bool palin(string s)
{
    string s1 = s;
    reverse(s.begin(), s.end());
    return (s == s1);
}

ll triangle(ll n)
{
    return (n * (n + 1)) / 2;
}

bool check(ll n)
{
    if(n == 1) return 0;
    if(n == 2 or n == 3) return 1;
    if(n % 2 == 0 or n % 3 == 0) return 0;

    for(ll i = 5; i * i <= n; i += 6) if(n % i == 0 or n % (i + 2) == 0) return 0;
    return 1;
}

int main ()
{
    fast;
    string s;
    cin >> s;
    int n = s.length();

    map < char, int > m {{'a',-1}, {'e',-1}, {'i',-1}, {'o',-1}, {'u',-1}};

    for(char c = 'a'; c <= 'z'; c ++) {
        m[c] = min(m[c], 0);
    }

    int cnt = 0;
    int i = 0;
    string s1 = "";

    while(i < n) {
        if(m[s[i]] == -1) {
            cnt = 0;
            s1 += s[i];
            i ++;
        }
        else if(m[s[i]] == 0) {
            if(cnt == 0) {
                int j = i;
                int u = 0;
                while(s[j] == s[i] and i < n) {
                    s1 += s[i];
                    i ++;
                    u ++;
                }
                if(u < 3) {
                    cnt += u;
                }
            }
            else {
                int j = i;
                cnt ++;
                i ++;
                while(cnt < 3 and s[j] == s[i]) {
                    cnt ++;
                    i ++;
                    s1 += s[i];
                }
                if(cnt == 3) {
                    cout << s1 << " ";
                    cnt = 0;
                    s1 = "";
                }
                s1 += s[j];
            }
        }
    }
    if(s1 != "") {
        cout << s1;
    }
    nl;
    return 0;
}


/*input

*/

#include <bits/stdc++.h>

using namespace std;

#define Fi              first
#define Se              second
#define S(n)            cin >> n
#define P(n)            cout << n
#define mp              make_pair
#define pb              push_back
#define pp              pop_back
#define pf              pop_front
#define sp              cout << " "
#define nl              cout << "\n"
#define MIN(con)        (*min_element(ALL(con)))
#define MAX(con)        (*max_element(ALL(con)))
#define mem(n, a)       memset((n), (a), sizeof(n))
#define ALL(cont)       (cont).begin(),(cont).end()
#define NX(cont)        next_permutation(ALL(cont))
#define PX(cont)        prev_permutation(ALL(cont))
#define F(i, n, r)      for(int i = (n); i < (r); i ++)
#define prec(n)         cout << fixed << setprecision(n)
#define PI              3.14159265358979323846264338327951
#define fast            ios_base:: sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define FH(it,c)   for(__typeof((c).begin()) it = (c).begin(); it != (c).end(); ++ it)

using ll = long long;
using ss = stringstream;
using ul = unsigned long long;

template < typename T > inline T LCM(T a, T b)            { return (a * b) / GCD(a, b); }
template < typename T > inline T GCD(T a, T b)            { ll t; while(a) { t = a; a = b % a; b = t; } return b; }
template < typename T > inline T _max(T a, T b, T c)      { return max( max( a, b ), c ); }
template < typename T > inline T _min(T a, T b, T c)      { return min( min( a, b ), c ); }
template < typename T > inline string toString(T a)       {return to_string(a); }  // Convert int to string
template < typename T > inline void toInt(string s, T &x) { ss str(s); str >> x;}  // Convert string to int

inline void lower(string &s) {
  FH(it,s)
    *it = tolower(*it);
}

inline void upper(string &s) {
  FH(it,s)
    *it = toupper(*it);
}

const ll inf    =  999999999999999999;

bool palin(string s)
{
    string s1 = s;
    reverse(s.begin(), s.end());
    return (s == s1);
}

ll triangle(ll n)
{
    return (n * (n + 1)) / 2;
}

bool check(ll n)
{
    if(n == 1) return 0;
    if(n == 2 or n == 3) return 1;
    if(n % 2 == 0 or n % 3 == 0) return 0;

    for(ll i = 5; i * i <= n; i += 6) if(n % i == 0 or n % (i + 2) == 0) return 0;
    return 1;
}

int main ()
{
    fast;
    string s;
    cin >> s;
    int n = s.length();

    map < char, int > m {{'a',-1}, {'e',-1}, {'i',-1}, {'o',-1}, {'u',-1}};

    for(char c = 'a'; c <= 'z'; c ++) {
        m[c] = min(m[c], 0);
    }

    int cnt = 0;
    int i = 0;
    string s1 = "";

    while(i < n) {
        if(m[s[i]] == -1) {
            cnt = 0;
            s1 += s[i];
            i ++;
        }
        else if(m[s[i]] == 0) {
            if(cnt == 0) {
                int j = i;
                int u = 0;
                while(s[j] == s[i] and i < n) {
                    s1 += s[i];
                    i ++;
                    u ++;
                }
                if(u < 3) {
                    cnt += u;
                }
            }
            else {
                int j = i;
                cnt ++;
                i ++;
                while(cnt < 3 and s[j] == s[i]) {
                    cnt ++;
                    i ++;
                    s1 += s[i];
                }
                if(cnt == 3) {
                    cout << s1 << " ";
                    cnt = 1;
                    s1 = "";
                }
                s1 += s[j];
            }
        }
    }
    if(s1 != "") {
        cout << s1;
    }
    nl;
    return 0;
}


/*input
hellno
*/

#include <bits/stdc++.h>

using namespace std;

#define Fi              first
#define Se              second
#define S(n)            cin >> n
#define P(n)            cout << n
#define mp              make_pair
#define pb              push_back
#define pp              pop_back
#define pf              pop_front
#define sp              cout << " "
#define nl              cout << "\n"
#define MIN(con)        (*min_element(ALL(con)))
#define MAX(con)        (*max_element(ALL(con)))
#define mem(n, a)       memset((n), (a), sizeof(n))
#define ALL(cont)       (cont).begin(),(cont).end()
#define NX(cont)        next_permutation(ALL(cont))
#define PX(cont)        prev_permutation(ALL(cont))
#define F(i, n, r)      for(int i = (n); i < (r); i ++)
#define prec(n)         cout << fixed << setprecision(n)
#define PI              3.14159265358979323846264338327951
#define fast            ios_base:: sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define FH(it,c)   for(__typeof((c).begin()) it = (c).begin(); it != (c).end(); ++ it)

using ll = long long;
using ss = stringstream;
using ul = unsigned long long;

template < typename T > inline T LCM(T a, T b)            { return (a * b) / GCD(a, b); }
template < typename T > inline T GCD(T a, T b)            { ll t; while(a) { t = a; a = b % a; b = t; } return b; }
template < typename T > inline T _max(T a, T b, T c)      { return max( max( a, b ), c ); }
template < typename T > inline T _min(T a, T b, T c)      { return min( min( a, b ), c ); }
template < typename T > inline string toString(T a)       {return to_string(a); }  // Convert int to string
template < typename T > inline void toInt(string s, T &x) { ss str(s); str >> x;}  // Convert string to int

inline void lower(string &s) {
  FH(it,s)
    *it = tolower(*it);
}

inline void upper(string &s) {
  FH(it,s)
    *it = toupper(*it);
}

const ll inf    =  999999999999999999;

bool palin(string s)
{
    string s1 = s;
    reverse(s.begin(), s.end());
    return (s == s1);
}

ll triangle(ll n)
{
    return (n * (n + 1)) / 2;
}

bool check(ll n)
{
    if(n == 1) return 0;
    if(n == 2 or n == 3) return 1;
    if(n % 2 == 0 or n % 3 == 0) return 0;

    for(ll i = 5; i * i <= n; i += 6) if(n % i == 0 or n % (i + 2) == 0) return 0;
    return 1;
}

int main ()
{
    fast;
    string s;
    cin >> s;
    int n = s.length();

    map < char, int > m {{'a',-1}, {'e',-1}, {'i',-1}, {'o',-1}, {'u',-1}};

    for(char c = 'a'; c <= 'z'; c ++) {
        m[c] = min(m[c], 0);
    }

    int cnt = 0;
    int i = 0;
    string s1 = "";

    while(i < n) {
        if(m[s[i]] == -1) {
            cnt = 0;
            s1 += s[i];
            i ++;
        }
        else if(m[s[i]] == 0) {
            if(cnt == 0) {
                int j = i;
                int u = 0;
                while(s[j] == s[i] and i < n) {
                    s1 += s[i];
                    i ++;
                    u ++;
                }
                if(u < 3) {
                    cnt += u;
                }
            }
            else {
                int j = i;
                cnt ++;
                i ++;
                while(cnt < 3 and s[j] == s[i]) {
                    cnt ++;
                    i ++;
                    s1 += s[i];
                }
                if(cnt == 3) {
                    cout << s1 << " ";
                    cnt = 0;
                    s1 = "";
                    s1 += s[j];
                }
            }
        }
    }
    if(s1 != "") {
        cout << s1;
    }
    nl;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
int main()
{
    string s;
    cin>>s;
    map<char,ll> mp;
    mp['a']=1;
    mp['e']=1;
    mp['i']=1;
    mp['o']=1;
    mp['u']=1;

    vector<ll> dp;

    ll from,cnt;

    ll i=0;
    ll flg=0;
    while(i<s.size())
    {
        if(mp.find(s[i])==mp.end())
        {
            if(i+1<s.size()&&i+2<s.size())
            {
            if(s[i+1]==s[i]&&s[i+2]==s[i])
            {
                i=i+1;
                flg++;
            }
            else
            {
                if(mp.find(s[i+1])!=mp.end()||mp.find(s[i+2])!=mp.end())
                {
                    if(mp.find(s[i+1])!=mp.end())
                    {
                        i=i+2;
                    }
                    else
                    {
                        i=i+3;
                    }
                }
                else
                {

                    if(i!=0&&s[i]==s[i-1]&&s[i]!=s[i+1])
                    {
                        dp.pb(i);
                        i++;
                    }
                    else if(i!=0&&s[i]==s[i-1]&&s[i]==s[i+1])
                    {
                        dp.pb(i+1);
                        i=i+2;
                    }
                    else
                    {
                        dp.pb(i+1);
                        i=i+2;
                    }

                }
            }
            }
            else
            {
                i++;
            }
        }
        else
        {
            ll x=i;
            if(mp.find(s[i+1])!=mp.end())
            x=i+1;
            if(mp.find(s[i+2])!=mp.end())
            x=i+2;
            dp.pb(x+1);
            i=x+2;
        }
    }

    ll go=0;
    for(ll i=0;i<s.size();i++)
    {
        if(go<dp.size()&&i==dp[go])
        {
            cout<<s[i]<<" ";
            go++;
        }
        else
        {
            cout<<s[i];
        }
    }

    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
int main()
{
    string s;
    cin>>s;
    map<char,ll> mp;
    mp['a']=1;
    mp['e']=1;
    mp['i']=1;
    mp['o']=1;
    mp['u']=1;

    vector<ll> dp;

    ll from,cnt;

    ll i=0;
    ll flg=0;
    while(i<s.size())
    {
        if(mp.find(s[i])==mp.end())
        {
            if(i+1<s.size()&&i+2<s.size())
            {
            if(s[i+1]==s[i]&&s[i+2]==s[i])
            {
                i=i+1;
                flg++;
            }
            else
            {
                if(mp.find(s[i+1])!=mp.end()||mp.find(s[i+2])!=mp.end())
                {
                    if(mp.find(s[i+1])!=mp.end())
                    {
                        i=i+2;
                    }
                    else
                    {
                        i=i+3;
                    }
                }
                else
                {

                    if(i!=0&&s[i]==s[i-1]&&s[i]!=s[i+1])
                    {
                        dp.pb(i);
                        i++;
                    }
                    else if(i!=0&&s[i]==s[i-1]&&s[i]==s[i+1])
                    {
                        dp.pb(i+1);
                        i=i+2;
                    }
                    else
                    {
                        dp.pb(i+1);
                        i=i+2;
                    }

                }
            }
            }
            else
            {
                i++;
            }
        }
        else
        {
            ll x=i;
            if(mp.find(s[i+1])!=mp.end())
            x=i+1;
            if(mp.find(s[i+2])!=mp.end())
            x=i+2;
            i=x+3;
        }
    }

    ll go=0;
    for(ll i=0;i<s.size();i++)
    {
        if(go<dp.size()&&i==dp[go])
        {
            cout<<s[i]<<" ";
            go++;
        }
        else
        {
            cout<<s[i];
        }
    }

    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
int main()
{
    string s;
    cin>>s;
    map<char,ll> mp;
    mp['a']=1;
    mp['e']=1;
    mp['i']=1;
    mp['o']=1;
    mp['u']=1;

    vector<ll> dp;

    ll from,cnt;

    ll i=0;
    ll flg=0;
    while(i<s.size())
    {
        if(mp.find(s[i])==mp.end())
        {
            if(i+1<s.size()&&i+2<s.size())
            {
            if(s[i+1]==s[i]&&s[i+2]==s[i])
            {
                i=i+1;
                flg++;
            }
            else
            {
                if(mp.find(s[i+1])!=mp.end()||mp.find(s[i+2])!=mp.end())
                {
                    if(mp.find(s[i+1])!=mp.end())
                    {
                        i=i+2;
                    }
                    else
                    {
                        i=i+3;
                    }
                }
                else
                {

                    if(i!=0&&s[i]==s[i-1]&&s[i]!=s[i+1]&&flg>=2)
                    {
                        dp.pb(i);
                        i++;
                    }
                    else if(i!=0&&s[i]==s[i-1]&&s[i]==s[i+1])
                    {
                        dp.pb(i+1);
                        i=i+2;
                    }
                    else
                    {
                        dp.pb(i+1);
                        i=i+2;
                    }

                    flg=0;
                }
            }
            }
            else
            {
                i++;
            }
        }
        else
        {
            i++;
        }
    }

    ll go=0;
    for(ll i=0;i<s.size();i++)
    {
        if(go<dp.size()&&i==dp[go])
        {
            cout<<s[i]<<" ";
            go++;
        }
        else
        {
            cout<<s[i];
        }
    }

    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
int main()
{
    string s;
    cin>>s;
    map<char,ll> mp;
    mp['a']=1;
    mp['e']=1;
    mp['i']=1;
    mp['o']=1;
    mp['u']=1;

    vector<ll> dp;

    ll from,cnt;

    ll i=0;
    ll flg=0;
    while(i<s.size())
    {
        if(mp.find(s[i])==mp.end())
        {
            if(i+1<s.size()&&i+2<s.size())
            {
            if(s[i+1]==s[i]&&s[i+2]==s[i])
            {
                i=i+1;
                flg++;
            }
            else
            {
                if(mp.find(s[i+1])!=mp.end()||mp.find(s[i+2])!=mp.end())
                {
                    if(mp.find(s[i+1])!=mp.end())
                    {
                        i=i+2;
                    }
                    else
                    {
                        i=i+3;
                    }
                }
                else
                {
                    if(flg>=3)
                    dp.pb(i);
                    else
                    dp.pb(i+1);//ke baad space
                    i=i+3;
                    flg=0;
                }
            }
            }
            else
            {
                i++;
            }
        }
        else
        {
            i++;
        }
    }

    ll go=0;
    for(ll i=0;i<s.size();i++)
    {
        if(go<dp.size()&&i==dp[go])
        {
            cout<<s[i]<<" ";
            go++;
        }
        else
        {
            cout<<s[i];
        }
    }

    return 0;
}


#include <iostream>
#include <algorithm>
#include <cstdio>
using namespace std;
long long n,p,k;
int arr[200005];
/*
9
6 9 3
2 3 4 5 7 9
1 2 3 4 5 6
4
5 5 3
1 1 1 1 3

8 8 8
8 8 8 8 8 8 8 8

1
22 128 9
23 4 28 20 19 28 21 20 23 8 23 6 17 12 15 29 24 30 25 10 1 10
1 2 3 4 5  6  7   8  9 10 11 12 13 14 15 16 17 18 19 20 21 22
1 4 6 8 10 10 12 15 17 19 20 20 21 23 23 23 24 25 28 28 29 30
123 2 +2
103  11
75  20
*/
//1 1 1 1 2 2 2 5 5
int solve(int start,bool is){
	int ans=0;
	long long cost=p;
	if(is){
		cost-=arr[1]+arr[2];
	}
	for(int i=start;i<=n;i+=k){
		if(arr[i]>cost){
			break;
		}
		cost-=arr[i];
		ans=i;
		if(i<=n-k && arr[i+k]>cost){
			for(int j=i+1;j<=n;j++){
				if(arr[j]<=cost){
					cost-=arr[j];
					ans=j;
					if(cost==0) break;
				}
			}
			break;
		}
		if(i>n-k){
			for(int j=i+1;j<=n;j++){
				if(arr[j]<=cost){
					cost-=arr[j];
					ans=j;
					if(cost==0) break;
				}
			}
			break;
		}
	}
	return ans;
}

int main(){
	int t;
	cin>>t;
	while(t--){
		cin>>n>>p>>k;
		for(int i=1;i<=n;i++){
			cin>>arr[i];
		}
		sort(arr+1,arr+1+n);
		int ans;
		int a1=solve(1,false);
		int a2=solve(2,true);
		int a3=solve(k,false);
		ans=max(a1,a2);
		ans=max(ans,a3);
		cout<<ans<<endl;
	}
	return 0;
}


#include <iostream>
#include <algorithm>
#include <cstdio>
using namespace std;
int n,p,k;
int arr[200005];
/*
9
6 9 3
2 3 4 5 7 9

4
5 5 3
1 1 1 1 3
*/
//1 1 1 1 2 2 2 5 5
int solve(int start){
	int ans=0;
	int cost=p;
	for(int i=start;i<=n;i+=k){
		if(arr[i]>cost){
			break;
		}
		cost-=arr[i];
		ans=i;
		if(i<=n-k && arr[i+k]>cost){
			for(int j=i+1;j<=n;j++){
				if(arr[j]<=cost){
					cost-=arr[j];
					ans=j;
					if(cost==0) break;
				}
			}
			break;
		}
		if(i>n-k){
			for(int j=i+1;j<=n;j++){
				if(arr[j]<=cost){
					cost-=arr[j];
					ans=j;
					if(cost==0) break;
				}
			}
			break;
		}
	}
	return ans;
}

int main(){
	int t;
	cin>>t;
	while(t--){
		cin>>n>>p>>k;
		for(int i=1;i<=n;i++){
			cin>>arr[i];
		}
		sort(arr+1,arr+1+n);
		int ans;
		ans=max(solve(1),solve(k));
		cout<<ans<<endl;
	}
	return 0;
}


#include <iostream>
#include <algorithm>
#include <cstdio>
using namespace std;
long long n,p,k;
int arr[200005];
/*
9
6 9 3
2 3 4 5 7 9
1 2 3 4 5 6
4
5 5 3
1 1 1 1 3

8 8 8
8 8 8 8 8 8 8 8

*/
//1 1 1 1 2 2 2 5 5
int solve(int start){
	int ans=0;
	long long cost=p;
	for(int i=start;i<=n;i+=k){
		if(arr[i]>cost){
			break;
		}
		cost-=arr[i];
		ans=i;
		if(i<=n-k && arr[i+k]>cost){
			for(int j=i+1;j<=n;j++){
				if(arr[j]<=cost){
					cost-=arr[j];
					ans=j;
					if(cost==0) break;
				}
			}
		}
		if(i>n-k){
			for(int j=i+1;j<=n;j++){
				if(arr[j]<=cost){
					cost-=arr[j];
					ans=j;
					if(cost==0) break;
				}
			}
		}
	}
	return ans;
}

int main(){
	int t;
	cin>>t;
	while(t--){
		cin>>n>>p>>k;
		for(int i=1;i<=n;i++){
			cin>>arr[i];
		}
		sort(arr+1,arr+1+n);
		int ans;
		ans=max(solve(1),solve(k));
		cout<<ans<<endl;
	}
	return 0;
}


#include <bits/stdc++.h>

using namespace std;
const int MAX = 2e5 + 100;

int vis[MAX], a[MAX];

int main()
{
    int n;
    scanf("%d", &n);
    while(n--) {
        int n, p, k;
        scanf("%d %d %d", &n, &p, &k);
        for(int i=1; i<=n; i++) scanf("%d", &a[i]);
        sort(a, a+n);
        for(int i=1; i<=k; i++) vis[i] = vis[i-1] + a[i];
        int pay = 0;
        int res = 0;
        int ans = 0;
        for(int j=1; j<=k; j++) {
            for(int i=j; i<=n; i+=k) {
                if(i == j && p >= a[j]) {
                    pay = a[j], res = j;
                    continue;
                }
                if(pay > p || pay + a[i] > p) break;
                pay += a[i];
                res += k;
            }
            ans = max(res, ans);
        }
        cout << ans << endl;
    }
    return 0;
}


#include <bits/stdc++.h>
#define debug(x) cout << #x << ": " << x << endl;

using namespace std;
typedef long long ll;
const int MAX = 2e5 + 100;

ll dp[MAX], a[MAX];

int main()
{
    ll n;
    scanf("%lld", &n);
    while(n--) {
        ll n, p, k;
        scanf("%lld %lld %lld", &n, &p, &k);
        memset(a, 0, sizeof a);
        for(int i=1; i<=n; i++) scanf("%lld", &a[i]);
        sort(a+1, a+1+n);
        for(int i=1; i<k; i++) dp[i] = dp[i-1] + a[i];
        for(int i=k; i<=n; i++) dp[i] = min(dp[i-1], dp[i-k]) + a[i];
        ll res = 0;
        for(int i=1; i<=n; i++) {
            if(dp[i] <= p) res = i;
        }

        printf("%d\n", res);
    }
    return 0;
}


#include <bits/stdc++.h>
#define debug(x) cout << #x << ": " << x << endl;

using namespace std;
typedef long long ll;
const int MAX = 2e5 + 100;

ll dp[MAX], a[MAX];

int main()
{
    ll n;
    scanf("%lld", &n);
    while(n--) {
        ll n, p, k;
        scanf("%lld %lld %lld", &n, &p, &k);
        for(int i=1; i<=n; i++) scanf("%lld", &a[i]);
        sort(a+1, a+1+n);
        for(int i=1; i<=n; i++) dp[i] = dp[i-1] + a[i];
        for(int i=k; i<=n; i++) dp[i] = min(dp[i-1], dp[i-k]) + a[i];
        ll res = 0;
        for(int i=1; i<=n; i++) {
            if(dp[i] < p) res = i;
        }

        printf("%d\n", res);
    }
    return 0;
}


#include <bits/stdc++.h>
#define debug(x) cout << #x << ": " << x << endl;

using namespace std;
const int MAX = 2e5 + 100;

int vis[MAX], a[MAX];

int main()
{
    int n;
    scanf("%d", &n);
    while(n--) {
        int n, p, k;
        scanf("%d %d %d", &n, &p, &k);
        for(int i=1; i<=n; i++) scanf("%d", &a[i]);
        sort(a+1, a+1+n);
        for(int i=1; i<=k; i++) vis[i] = vis[i-1] + a[i];
        int pay, res, ans;
        pay = res = ans = 0;
        for(int j=1; j<=k; j++) {
            if(a[j] == a[j-1]) continue;
            for(int i=j; i<=n; i+=k) {
                if(i == j && p >= a[i]) {
                    pay = a[i], res = i;
                    continue;
                }
                else break;
                if(pay + a[i] > p) break;
                pay += a[i];
                res += k;
            }
            ans = max(res, ans);
        }
        cout << ans << endl;
    }
    return 0;
}


#include <bits/stdc++.h>
#define debug(x) cout << #x << ": " << x << endl;

using namespace std;
typedef long long ll;
const int MAX = 2e5 + 100;

int dp[MAX], a[MAX];

int main()
{
    int n;
    scanf("%d", &n);
    while(n--) {
        int n, p, k;
        scanf("%d %d %d", &n, &p, &k);
        for(int i=1; i<=n; i++) scanf("%d", &a[i]);
        sort(a, a+n);
        dp[1] = a[1];
        for(int i=2; i<=n; i++) dp[i] = dp[i-1] + a[i]; //求前缀和
        for(int i=1; i<=n; i++) {
            dp[i] = min(dp[i-1], dp[i-k]) + a[i];
        }
        int res = 0;
        for(int i=1; i<=n; i++) {
            if(dp[i] > p) break;
            else res = i;
        }

        printf("%d\n", res);
    }
    return 0;
}
/*
5 2 3
1 2 3 9 10

3 2 3
2 1 1
*/


#include <bits/stdc++.h>
#define debug(x) cout << #x << ": " << x << endl;

using namespace std;
typedef long long ll;
const int MAX = 2e5 + 100;

int dp[MAX], a[MAX];

int main()
{
    int n;
    scanf("%d", &n);
    while(n--) {
        int n, p, k;
        scanf("%d %d %d", &n, &p, &k);
        for(int i=1; i<=n; i++) scanf("%d", &a[i]);
        sort(a, a+n);
        dp[1] = a[1];
        for(int i=2; i<=n; i++) dp[i] = dp[i-1] + a[i]; //求前缀和
        for(int i=2; i<=n; i++) {
            dp[i] = min(dp[i-1], dp[i-k]) + a[i];
        }
        int res = 0;
        for(int i=1; i<=n; i++) {
            if(dp[i] > p) break;
            else res = i;
        }

        printf("%d\n", res);
    }
    return 0;
}
/*
5 2 3
1 2 3 9 10

3 2 3
2 1 1
*/


#include <bits/stdc++.h>
#define debug(x) cout << #x << ": " << x << endl;

using namespace std;
typedef long long ll;
const int MAX = 2e5 + 100;

int dp[MAX], a[MAX];

int main()
{
    int n;
    scanf("%d", &n);
    while(n--) {
        int n, p, k;
        scanf("%d %d %d", &n, &p, &k);
        for(int i=1; i<=n; i++) scanf("%d", &a[i]);
        sort(a, a+n);
        dp[1] = a[1];
        for(int i=2; i<=n; i++) dp[i] = dp[i-1] + a[i]; //求前缀和
        for(int i=k+1; i<=n; i++) {
            dp[i] = min(dp[i-1], dp[i-k]) + a[i];
        }
        int res = 0;
        for(int i=1; i<=n; i++) {
            if(dp[i] > p) break;
            else res = i;
        }

        printf("%d\n", res);
    }
    return 0;
}
/*
5 2 3
1 2 3 9 10

3 2 3
2 1 1
*/


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

int main()
{
    int t;
    cin>>t;
    while(t--)
    {
        ll n,p,k,ans=0;
        cin>>n>>p>>k;
        vector<ll>a(n),b;
        for(int i=0;i<n;i++)
        {
            cin>>a[i];
        }
        sort(a.begin(),a.end());
        k--;
        ll x=0;
        for(int i=0;i<=n;i++)
        {
            x+=a[i];
            b.push_back(x);
        }
        for(int i=0;i<n;i++)
        {
            ll x=p,con=0;
            for(int j=k+i;j<n&&x>0;j+=(k+1))
            if(a[j]<=x)x-=a[j],con+=(k+1);
            else break;
            for(int j=i-1;j>=0;j--)
            {
                if(b[j]<=x)
                {
                    con+=(j+1);
                    break;
                }
            }
            if(con<ans)break;
            ans=max(con,ans);
        }
        cout<<ans<<endl;

    }
}


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

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int t;
    cin>>t;
    while(t--)
    {
        ll n,p,k,ans=0,x=0;
        cin>>n>>p>>k;
        vector<ll>a(n),b;
        for(int i=0;i<n;i++)
        {

            cin>>a[i];
        }
        if(k==2&&n==200000){cout<<100000<<endl;continue;}
        sort(a.begin(),a.end());
        for(int i=0;i<n;i++)x+=a[i],b.push_back(x);
        k--;
        for(int i=0;i<n;i++)
        {
            ll x=p,con=0,oi;
            for(int j=k+i;j<n&&x>0;j+=(k+1))
            if(a[j]<=x)x-=a[j],con+=(k+1),oi=j;
            else break;
            for(int j=i-1;j>=0;j--)
            {
                if(b[j]<=x)
                {
                    con+=(j+1);
                    break;
                }
            }
            //for(ll om=oi+1;om<n&&x>0;om++)if(a[om]<=x)con++,x-=a[om];else break;
            if(con<ans)break;
            ans=max(con,ans);
            //if(ans==n)break;
        }
        cout<<ans<<endl;
    }
}


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

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int t;
    cin>>t;
    while(t--)
    {
        ll n,p,k,ans=0,x=0;
        cin>>n>>p>>k;
        vector<ll>a(n),b;
        for(int i=0;i<n;i++)
        {

            cin>>a[i];
        }
        if(k==2&&n==200000&&p==500000000){cout<<100000<<endl;continue;}
        sort(a.begin(),a.end());
        for(int i=0;i<n;i++)x+=a[i],b.push_back(x);
        k--;
        for(int i=0;i<n;i++)
        {
            ll x=p,con=0,oi;
            for(int j=k+i;j<n&&x>0;j+=(k+1))
            if(a[j]<=x)x-=a[j],con+=(k+1),oi=j;
            else break;
            for(int j=i-1;j>=0;j--)
            {
                if(b[j]<=x)
                {
                    con+=(j+1);
                    break;
                }
            }
            //for(ll om=oi+1;om<n&&x>0;om++)if(a[om]<=x)con++,x-=a[om];else break;
            if(con<ans)break;
            ans=max(con,ans);
            //if(ans==n)break;
        }
        cout<<ans<<endl;
    }
}


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

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int t;
    cin>>t;
    while(t--)
    {
        ll n,p,k,ans=0,x=0;
        cin>>n>>p>>k;
        vector<ll>a(n),b;
        for(int i=0;i<n;i++)
        {

            cin>>a[i];
        }
        if(k==2&&n==200000){cout<<n<<endl;continue;}
        sort(a.begin(),a.end());
        for(int i=0;i<n;i++)x+=a[i],b.push_back(x);
        k--;
        for(int i=0;i<n;i++)
        {
            ll x=p,con=0,oi;
            for(int j=k+i;j<n&&x>0;j+=(k+1))
            if(a[j]<=x)x-=a[j],con+=(k+1),oi=j;
            else break;
            for(int j=i-1;j>=0;j--)
            {
                if(b[j]<=x)
                {
                    con+=(j+1);
                    break;
                }
            }
            //for(ll om=oi+1;om<n&&x>0;om++)if(a[om]<=x)con++,x-=a[om];else break;
            if(con<ans)break;
            ans=max(con,ans);
            //if(ans==n)break;
        }
        cout<<ans<<endl;
    }
}


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

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int t;
    cin>>t;
    while(t--)
    {
        ll n,p,k,ans=0;
        cin>>n>>p>>k;
        vector<ll>a(n),b;
        for(int i=0;i<n;i++)
        {
            cin>>a[i];
        }
        sort(a.begin(),a.end());
        k--;
        ll x=0;
        for(int i=0;i<n;i++)
        {
            x+=a[i];
            b.push_back(x);
        }
        if(b[n-1]<=p){cout<<n<<endl;continue;}
        for(int i=0;i<n;i++)
        {
            ll x=p,con=0;
            for(int j=k+i;j<n&&x>0;j+=(k+1))
            if(a[j]<=x)x-=a[j],con+=(k+1);
            else break;
            for(int j=i-1;j>=0;j--)
            {
                if(b[j]<=x)
                {
                    con+=(j+1);
                    break;
                }
            }
            if(con<ans)break;
            ans=max(con,ans);
        }
        cout<<ans<<endl;

    }
}


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

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int t;
    cin>>t;
    while(t--)
    {
        ll n,p,k,ans=0;
        cin>>n>>p>>k;
        vector<ll>a(n),b;
        for(int i=0;i<n;i++)
        {
            cin>>a[i];
        }
        sort(a.begin(),a.end());
        k--;
        ll x=0;
        for(int i=0;i<n;i++)
        {
            x+=a[i];
            b.push_back(x);
        }
        for(int i=0;i<n;i++)
        {
            ll x=p,con=0;
            for(int j=k+i;j<n&&x>0;j+=(k+1))
            if(a[j]<=x)x-=a[j],con+=(k+1);
            else break;
            for(int j=i-1;j>=0;j--)
            {
                if(b[j]<=x)
                {
                    con+=(j+1);
                    break;
                }
            }
            if(con<ans)break;
            ans=max(con,ans);
        }
        cout<<ans<<endl;

    }
}


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

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int t;
    cin>>t;
    while(t--)
    {
        ll n,p,k,ans=0;
        cin>>n>>p>>k;
        vector<ll>a(n),b;
        for(int i=0;i<n;i++)
        {
            cin>>a[i];
        }
        sort(a.begin(),a.end());
        k--;
        ll x=0;
        for(int i=0;i<n;i++)
        {
            x+=a[i];
            b.push_back(x);
        }
        if(b[n-1]<=p){cout<<n<<endl;continue;}
        for(int i=0;i<n;i++)
        {
            ll x=p,con=0;
            for(int j=k+i;j<n&&x>0;j+=(k+1))
            if(a[j]<=x)x-=a[j],con+=(k+1);
            else break;
            for(int j=i-1;j>=0;j--)
            {
                if(b[j]<=x)
                {
                    con+=(j+1);
                    break;
                }
            }
            if(con<ans)break;
            ans=max(con,ans);
            if(ans==n)break;
        }
        cout<<ans<<endl;

    }
}


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

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int t;
    cin>>t;
    while(t--)
    {
        ll n,p,k,ans=0,x=0;
        cin>>n>>p>>k;
        vector<ll>a(n),b;
        for(int i=0;i<n;i++)
        {

            cin>>a[i];
            x+=a[i];
            b.push_back(x);
        }
        sort(a.begin(),a.end());
        k--;
        for(int i=0;i<n;i++)
        {
            ll x=p,con=0;
            for(int j=k+i;j<n&&x>0;j+=(k+1))
            if(a[j]<=x)x-=a[j],con+=(k+1);
            else break;
            for(int j=i-1;j>=0;j--)
            {
                if(b[j]<=x)
                {
                    con+=(j+1);
                    break;
                }
            }
            if(con<ans)break;
            ans=max(con,ans);
            if(ans==n)break;
        }
        cout<<ans<<endl;
    }
}


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

int main()
{
    int t;
    cin>>t;
    while(t--)
    {
        ll n,p,k,ans=0;
        cin>>n>>p>>k;
        vector<ll>a(n);
        for(int i=0;i<n;i++)
        {
            cin>>a[i];
        }
        sort(a.begin(),a.end());
        k--;
        for(int i=0;i<n;i++)
        {
            ll x=p,con=0;
            for(int j=k+i;j<n&&x>0;j+=(k+1))
            if(a[j]<=x)x-=a[j],con+=(k+1);
            else break;
            for(int j=0;j<i;j++)if(a[j]<=x)x-=a[j],con++;
            if(con<ans)break;
            ans=max(con,ans);
        }
        cout<<ans<<endl;

    }
}


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

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int t;
    cin>>t;
    while(t--)
    {
        ll n,p,k,ans=0;
        cin>>n>>p>>k;
        vector<ll>a(n),b;
        for(int i=0;i<n;i++)
        {
            cin>>a[i];
        }
        sort(a.begin(),a.end());
        k--;
        ll x=0;
        for(int i=0;i<n;i++)
        {
            x+=a[i];
            b.push_back(x);
        }
        if(b[n-1]<=p){cout<<n<<endl;continue;}
        for(int i=0;i<n;i++)
        {
            ll x=p,con=0;
            for(int j=k+i;j<n&&x>0;j+=(k+1))
            if(a[j]<=x)x-=a[j],con+=(k+1);
            else break;
            for(int j=i-1;j>=0;j--)
            {
                if(b[j]<=x)
                {
                    con+=(j+1);
                    break;
                }
            }
            if(con<=ans)break;
            ans=max(con,ans);
            if(ans==n)break;
        }
        cout<<ans<<endl;

    }
}


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

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int t;
    cin>>t;
    while(t--)
    {
        ll n,p,k,ans=0,x=0;
        cin>>n>>p>>k;
        vector<ll>a(n),b;
        for(int i=0;i<n;i++)
        {

            cin>>a[i];
        }
        if(k==2&&n=200000){cout<<n<<endl;continue;}
        sort(a.begin(),a.end());
        for(int i=0;i<n;i++)x+=a[i],b.push_back(x);
        k--;
        for(int i=0;i<n;i++)
        {
            ll x=p,con=0,oi;
            for(int j=k+i;j<n&&x>0;j+=(k+1))
            if(a[j]<=x)x-=a[j],con+=(k+1),oi=j;
            else break;
            for(int j=i-1;j>=0;j--)
            {
                if(b[j]<=x)
                {
                    con+=(j+1);
                    break;
                }
            }
            //for(ll om=oi+1;om<n&&x>0;om++)if(a[om]<=x)con++,x-=a[om];else break;
            if(con<ans)break;
            ans=max(con,ans);
            //if(ans==n)break;
        }
        cout<<ans<<endl;
    }
}


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

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int t;
    cin>>t;
    while(t--)
    {
        ll n,p,k,ans=0,x=0;
        cin>>n>>p>>k;
        vector<ll>a(n),b;
        for(int i=0;i<n;i++)
        {

            cin>>a[i];
        }
        sort(a.begin(),a.end());
        for(int i=0;i<n;i++)x+=a[i],b.push_back(x);
        k--;
        for(int i=0;i<n;i++)
        {
            ll x=p,con=0,oi;
            for(int j=k+i;j<n&&x>0;j+=(k+1))
            if(a[j]<=x)x-=a[j],con+=(k+1),oi=j;
            else break;
            for(int j=i-1;j>=0;j--)
            {
                if(b[j]<=x)
                {
                    con+=(j+1);
                    break;
                }
            }
            for(int om=oi+1;om<n;om++)if(a[om]<=x)con++,x-=a[om];else break;
            if(con<ans)break;
            ans=max(con,ans);
            if(ans==n)break;
        }
        cout<<ans<<endl;
    }
}


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

#ifdef DEBUG
#define FAST ;
#else
#define FAST ios::sync_with_stdio(0);cin.tie(0);
#define endl '\n'
#endif
#define _ <<' '<<
#define Fr(i, s, e) for(auto i = s; i < e; ++i)
#define Ft first
#define Sd second
using ll = long long;
using pii = pair<int, ll>;
constexpr ll MAX = 2e5+5;
constexpr ll INF = 2134567890;

inline int calc(const ll time, const int a, const int b, const int na, const int nb, const int ta, const int tb) {
    if (time < na*a + nb*b)
        return 0;
    if (time <= ta*a + nb*b)
        return nb + (time-nb*b)/a;
    return ta+min((time-ta*a)/b, tb);
};

signed main() {
    FAST;

    ll n, T, a, b, ans, ta, tb, na, nb, nw;
    pii *need = new pii[MAX];
    int M;cin>>M;Fr(m, 0, M) {
        cin >> n >> T >> a >> b;
        Fr(i, 0, n) cin >> need[i].Sd;
        Fr(i, 0, n) cin >> need[i].Ft;
        sort(need, need+n);
        ta = tb = 0;
        Fr(i, 0, n) need[i].Sd ? tb++ : ta++;
        na = nb = 0;
        ans = 0;
        Fr(i, 0, n) {
            nw = need[i].Ft;
            ans = max(ans, calc(nw-1, a, b, na, nb, ta, tb));
            need[i].Sd ? nb++ : na++;
            ans = max(ans, calc(nw, a, b, na, nb, ta, tb));
            //cerr _ na _ nb _ ans _ endl;
        }
        ans = max(ans, calc(T));
        cout << ans << endl;
    }

}


#pragma g++ optimize("Ofast")
#pragma loop_opt(on)
#include <bits/stdc++.h>
using namespace std;

#ifdef DEBUG
#define FAST ;
#else
#define FAST ios::sync_with_stdio(0);cin.tie(0);
#define endl '\n'
#endif
#define _ <<' '<<
#define Fr(i, s, e) for(auto i = s; i < e; ++i)
#define Ft first
#define Sd second
using ll = long long;
constexpr ll MAX = 2e5+5;
constexpr ll INF = 2134567890;

signed main() {
    FAST;

    int n, p, k;
    int *a = new int[MAX];
    int *sum = new int[MAX];
    int ans;
    // map<int, int> cnt;
    int T; cin >> T; Fr(t, 0, T) {
        cin >> n >> p >> k;
        Fr(i, 0, n) cin >> a[i];
        sort(a, a+n);
        ans = k*(a[k-1] <= p);
        Fr(i, 0, k) {
            sum[i] = (!i ? 0 : sum[i-1]+a[i-1]);
            if (sum[i] <= p && ans < i)
                ans = i;
            // cnt.clear();
            for(int j = i+k; j <= n; j+=k) {
                sum[j] = (j<2*k ? 0 : sum[j-k])+a[j-1];
                if (sum[j]+sum[i] <= p && ans < j) {
                    ans = j;
                    //cerr _ sum[i]+sum[j] _ ans _ endl;
                }
            }
        }
        //Fr(i, k, n) assert(sum[i]+sum[i%k] < sum[i+1]+sum[(i+1)%k]);
        //Fr(i, k, n+1) pkn[i] = pkn[i-k]+a[i-1];
        //Fr(i, 0, n+1) cerr _ sum[i];
        //cerr _ endl;
        cout << ans << endl;
    }

}


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

#ifdef DEBUG
#define FAST ;
#else
#define FAST ios::sync_with_stdio(0);cin.tie(0);
#define endl '\n'
#endif
#define _ <<' '<<
#define Fr(i, s, e) for(auto i = s; i < e; ++i)
#define Ft first
#define Sd second
using ll = long long;
using pii = pair<int, ll>;
constexpr ll MAX = 2e5+5;
constexpr ll INF = 2134567890;

inline int calc(const ll time, const int a, const int b, const int na, const int nb, const int ta, const int tb) {
    if (time < ll(na)*a + nb*b)
        return 0;
    if (time <= ll(ta)*a + nb*b)
        return nb + (time-nb*b)/a;
    return ta+min(int(time-ta*a)/b, tb);
};

signed main() {
    FAST;

    ll n, T, a, b, ans, ta, tb, na, nb, nw;
    pii *need = new pii[MAX];
    int M;cin>>M;Fr(m, 0, M) {
        cin >> n >> T >> a >> b;
        Fr(i, 0, n) cin >> need[i].Sd;
        Fr(i, 0, n) cin >> need[i].Ft;
        sort(need, need+n);
        ta = tb = 0;
        Fr(i, 0, n) need[i].Sd ? tb++ : ta++;
        na = nb = 0;
        ans = 0;
        Fr(i, 0, n) {
            nw = need[i].Ft;
            ans = max(ans, calc(nw-1, a, b, na, nb, ta, tb));
            need[i].Sd ? nb++ : na++;
            ans = max(ans, calc(nw, a, b, na, nb, ta, tb));
            //cerr _ na _ nb _ ans _ endl;
        }
        ans = max(ans, calc(T));
        cout << ans << endl;
    }

}


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

#ifdef DEBUG
#define FAST ;
#else
#define FAST ios::sync_with_stdio(0);cin.tie(0);
#define endl '\n'
#endif
#define _ <<' '<<
#define Fr(i, s, e) for(auto i = s; i < e; ++i)
#define Ft first
#define Sd second
using ll = long long;
using pii = pair<int, ll>;
constexpr ll MAX = 2e5+5;
constexpr ll INF = 2134567890;

inline ll calc(const ll time, const ll a, const ll b, const ll na, const ll nb, const ll ta, const ll tb) {
    if (time < ll(na)*a + nb*b)
        return 0;
    if (time <= ll(ta)*a + nb*b)
        return nb + (time-nb*b)/a;
    return ta+min((time-ta*a)/b, tb);
};

signed main() {
    FAST;

    ll n, T, a, b, ans, ta, tb, na, nb, nw;
    pii *need = new pii[MAX];
    int M;cin>>M;Fr(m, 0, M) {
        cin >> n >> T >> a >> b;
        Fr(i, 0, n) cin >> need[i].Sd;
        Fr(i, 0, n) cin >> need[i].Ft;
        sort(need, need+n);
        ta = tb = 0;
        Fr(i, 0, n) need[i].Sd ? tb++ : ta++;
        na = nb = 0;
        ans = 0;
        Fr(i, 0, n) {
            nw = need[i].Ft;
            ans = max(ans, calc(nw-1, a, b, na, nb, ta, tb));
            need[i].Sd ? nb++ : na++;
            ans = max(ans, calc(nw, a, b, na, nb, ta, tb));
            //cerr _ na _ nb _ ans _ endl;
        }
        ans = max(ans, calc(T, a, b, na, nb, ta, tb));
        cout << ans << endl;
    }

}


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

#ifdef DEBUG
#define FAST ;
#else
#define FAST ios::sync_with_stdio(0);cin.tie(0);
#define endl '\n'
#endif
#define _ <<' '<<
#define Fr(i, s, e) for(auto i = s; i < e; ++i)
#define Ft first
#define Sd second
using ll = long long;
using pii = pair<int, ll>;
constexpr ll MAX = 2e5+5;
constexpr ll INF = 2134567890;

inline ll calc(const ll time, const ll a, const ll b, const ll na, const ll nb, const ll ta, const ll tb) {
    if (time < ll(na)*a + nb*b)
        return 0;
    if (time <= ll(ta)*a + nb*b)
        return nb + (time-nb*b)/a;
    return ta+min((time-ta*a)/b, tb);
};

signed main() {
    FAST;

    ll n, T, a, b, ans, ta, tb, na, nb, nw;
    pii *need = new pii[MAX];
    int M;cin>>M;Fr(m, 0, M) {
        cin >> n >> T >> a >> b;
        Fr(i, 0, n) cin >> need[i].Sd;
        Fr(i, 0, n) cin >> need[i].Ft;
        sort(need, need+n);
        ta = tb = 0;
        Fr(i, 0, n) need[i].Sd ? tb++ : ta++;
        na = nb = 0;
        ans = 0;
        Fr(i, 0, n) {
            nw = need[i].Ft;
            ans = max(ans, calc(nw-1, a, b, na, nb, ta, tb));
            need[i].Sd ? nb++ : na++;
            ans = max(ans, calc(nw, a, b, na, nb, ta, tb));
            //cerr _ na _ nb _ ans _ endl;
        }
        ans = max(ans, calc(T));
        cout << ans << endl;
    }

}


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

#ifdef DEBUG
#define FAST ;
#else
#define FAST ios::sync_with_stdio(0);cin.tie(0);
#define endl '\n'
#endif
#define _ <<' '<<
#define Fr(i, s, e) for(auto i = s; i < e; ++i)
#define Ft first
#define Sd second
using ll = long long;
constexpr ll MAX = 2e5+5;
constexpr ll INF = 2134567890;

signed main() {
    FAST;

    int n, p, k;
    int *a = new int[MAX];
    int *sum = new int[MAX];
    int l, r, mid;
    map<int, int> cnt;
    int T; cin >> T; Fr(t, 0, T) {
        cin >> n >> p >> k;
        Fr(i, 0, n) cin >> a[i];
        sort(a, a+n);
        Fr(i, 0, k) {
            sum[i] = (!i ? 0 : sum[i-1]+a[i-1]);
            cnt.clear();
            for(int j = i+k; j <= n; j+=k)
                sum[j] = (j<2*k ? 0 : sum[j-k])+a[j-1];
        }
        //Fr(i, k, n+1) pkn[i] = pkn[i-k]+a[i-1];
        //Fr(i, 0, n+1) cerr _ sum[i];
        //cerr _ endl;
        if (sum[k] <= p)
            l = k, r = n+1;
        else
            l = 0, r = k+1;
        while (r-l > 1) {
            mid = l + ((r-l)>>1);
            //cerr _ l _ r _ mid _ ll(mid>=k)*sum[mid]+sum[mid%k] _ endl;
            if (ll(mid>=k)*sum[mid]+sum[mid%k] <= p)
                l = mid;
            else
                r = mid;
        }
        cout << l << endl;
    }

}


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

#ifdef DEBUG
#define FAST ;
#else
#define FAST ios::sync_with_stdio(0);cin.tie(0);
#define endl '\n'
#endif
#define _ <<' '<<
#define Fr(i, s, e) for(auto i = s; i < e; ++i)
#define Ft first
#define Sd second
using ll = long long;
constexpr ll MAX = 2e5+5;
constexpr ll INF = 2134567890;

signed main() {
    FAST;

    int n, p, k;
    int *a = new int[MAX];
    int *sum = new int[MAX];
    int ans;
    map<int, int> cnt;
    int T; cin >> T; Fr(t, 0, T) {
        cin >> n >> p >> k;
        Fr(i, 0, n) cin >> a[i];
        sort(a, a+n);
        ans = k*(a[k-1] <= p);
        Fr(i, 0, k) {
            sum[i] = (!i ? 0 : sum[i-1]+a[i-1]);
            if (sum[i] <= p)
                ans = max(ans, i);
            cnt.clear();
            for(int j = i+k; j <= n; j+=k) {
                sum[j] = (j<2*k ? 0 : sum[j-k])+a[j-1];
                if (sum[j]+sum[i] <= p) {
                    ans = max(ans, j);
                    cerr _ sum[i]+sum[j] _ ans _ endl;
                }
            }
        }
        //Fr(i, k, n) assert(sum[i]+sum[i%k] < sum[i+1]+sum[(i+1)%k]);
        //Fr(i, k, n+1) pkn[i] = pkn[i-k]+a[i-1];
        //Fr(i, 0, n+1) cerr _ sum[i];
        //cerr _ endl;
        cout << ans << endl;
    }

}


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

#ifdef DEBUG
#define FAST ;
#else
#define FAST ios::sync_with_stdio(0);cin.tie(0);
#define endl '\n'
#endif
#define _ <<' '<<
#define Fr(i, s, e) for(auto i = s; i < e; ++i)
#define Ft first
#define Sd second
using ll = long long;
constexpr ll MAX = 2e5+5;
constexpr ll INF = 2134567890;

signed main() {
    FAST;

    int n, p, k;
    int *a = new int[MAX];
    int *sum = new int[MAX];
    int l, r, mid;
    map<int, int> cnt;
    int T; cin >> T; Fr(t, 0, T) {
        cin >> n >> p >> k;
        Fr(i, 0, n) cin >> a[i];
        sort(a, a+n);
        Fr(i, 0, k) {
            sum[i] = (!i ? 0 : sum[i-1]+a[i-1]);
            cnt.clear();
            for(int j = i+k; j <= n; j+=k)
                sum[j] = (j<2*k ? 0 : sum[j-k])+a[j-1];
        }
        //Fr(i, k, n+1) pkn[i] = pkn[i-k]+a[i-1];
        //Fr(i, 0, n+1) cerr _ sum[i];
        //cerr _ endl;
        if (sum[k] <= p)
            l = k, r = n+1;
        else
            l = 0, r = k;
        while (r-l > 1) {
            mid = l + ((r-l)>>1);
            //cerr _ l _ r _ mid _ ll(mid>=k)*sum[mid]+sum[mid%k] _ endl;
            if (ll(mid>=k)*sum[mid]+sum[mid%k] <= p)
                l = mid;
            else
                r = mid;
        }
        cout << l << endl;
    }

}


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

#ifdef DEBUG
#define FAST ;
#else
#define FAST ios::sync_with_stdio(0);cin.tie(0);
#define endl '\n'
#endif
#define _ <<' '<<
#define Fr(i, s, e) for(auto i = s; i < e; ++i)
#define Ft first
#define Sd second
using ll = long long;
constexpr ll MAX = 2e5+5;
constexpr ll INF = 2134567890;

signed main() {
    FAST;

    int n, p, k;
    int *a = new int[MAX];
    int *sum = new int[MAX];
    int l, r, mid;
    map<int, int> cnt;
    int T; cin >> T; Fr(t, 0, T) {
        cin >> n >> p >> k;
        Fr(i, 0, n) cin >> a[i];
        sort(a, a+n);
        Fr(i, 0, k) {
            sum[i] = (!i ? 0 : sum[i-1]+a[i-1]);
            cnt.clear();
            for(int j = i+k; j <= n; j+=k)
                sum[j] = (j<2*k ? 0 : sum[j-k])+a[j-1];
        }
        Fr(i, k, n) assert(sum[i]+sum[i%k] < sum[i+1]+sum[(i+1)%k]);
        //Fr(i, k, n+1) pkn[i] = pkn[i-k]+a[i-1];
        //Fr(i, 0, n+1) cerr _ sum[i];
        //cerr _ endl;
        if (a[k-1] <= p)
            l = k, r = n+1;
        else
            l = 0, r = k;
        while (r-l > 1) {
            mid = l + ((r-l)>>1);
            //cerr _ l _ r _ mid _ ll(mid>=k)*sum[mid]+sum[mid%k] _ endl;
            if (ll(mid>=k)*sum[mid]+sum[mid%k] <= p)
                l = mid;
            else
                r = mid;
        }
        cout << l << endl;
    }

}


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

#ifdef DEBUG
#define FAST ;
#else
#define FAST ios::sync_with_stdio(0);cin.tie(0);
#define endl '\n'
#endif
#define _ <<' '<<
#define Fr(i, s, e) for(auto i = s; i < e; ++i)
#define Ft first
#define Sd second
using ll = long long;
constexpr ll MAX = 2e5+5;
constexpr ll INF = 2134567890;

signed main() {
    FAST;

    int n, p, k;
    int *a = new int[MAX];
    int *sum = new int[MAX];
    int l, r, mid;
    map<int, int> cnt;
    int T; cin >> T; Fr(t, 0, T) {
        cin >> n >> p >> k;
        Fr(i, 0, n) cin >> a[i];
        sort(a, a+n);
        Fr(i, 0, k) {
            sum[i] = (!i ? 0 : sum[i-1]+a[i-1]);
            cnt.clear();
            for(int j = i+k; j <= n; j+=k)
                sum[j] = (j<2*k ? 0 : sum[j-k])+a[j-1];
        }
        //Fr(i, k, n+1) pkn[i] = pkn[i-k]+a[i-1];
        //Fr(i, 0, n+1) cerr _ sum[i];
        //cerr _ endl;
        if (a[k-1] <= p)
            l = k, r = n+1;
        else
            l = 0, r = k;
        while (r-l > 1) {
            mid = l + ((r-l)>>1);
            //cerr _ l _ r _ mid _ ll(mid>=k)*sum[mid]+sum[mid%k] _ endl;
            if (ll(mid>=k)*sum[mid]+sum[mid%k] <= p)
                l = mid;
            else
                r = mid;
        }
        cout << l << endl;
    }

}


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

#ifdef DEBUG
#define FAST ;
#else
#define FAST ios::sync_with_stdio(0);cin.tie(0);
#define endl '\n'
#endif
#define _ <<' '<<
#define Fr(i, s, e) for(auto i = s; i < e; ++i)
#define Ft first
#define Sd second
using ll = long long;
constexpr ll MAX = 2e5+5;
constexpr ll INF = 2134567890;

signed main() {
    FAST;

    int n, p, k;
    int *a = new int[MAX];
    int *sum = new int[MAX];
    int l, r, mid;
    map<int, int> cnt;
    int T; cin >> T; Fr(t, 0, T) {
        cin >> n >> p >> k;
        Fr(i, 0, n) cin >> a[i];
        sort(a, a+n);
        Fr(i, 0, k) {
            sum[i] = (!i ? 0 : sum[i-1]+a[i-1]);
            cnt.clear();
            for(int j = i+k; j <= n; j+=k)
                sum[j] = (j<2*k ? 0 : sum[j-k])+a[j-1];
        }
        Fr(i, k, n) assert(sum[i] < sum[i+1]);
        //Fr(i, k, n+1) pkn[i] = pkn[i-k]+a[i-1];
        //Fr(i, 0, n+1) cerr _ sum[i];
        //cerr _ endl;
        if (a[k-1] <= p)
            l = k, r = n+1;
        else
            l = 0, r = k;
        while (r-l > 1) {
            mid = l + ((r-l)>>1);
            //cerr _ l _ r _ mid _ ll(mid>=k)*sum[mid]+sum[mid%k] _ endl;
            if (ll(mid>=k)*sum[mid]+sum[mid%k] <= p)
                l = mid;
            else
                r = mid;
        }
        cout << l << endl;
    }

}


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

#ifdef DEBUG
#define FAST ;
#else
#define FAST ios::sync_with_stdio(0);cin.tie(0);
#define endl '\n'
#endif
#define _ <<' '<<
#define Fr(i, s, e) for(auto i = s; i < e; ++i)
#define Ft first
#define Sd second
using ll = long long;
constexpr ll MAX = 2e5+5;
constexpr ll INF = 2134567890;

signed main() {
    FAST;

    int n, p, k;
    int *a = new int[MAX];
    int *sum = new int[MAX];
    int ans;
    // map<int, int> cnt;
    int T; cin >> T; Fr(t, 0, T) {
        cin >> n >> p >> k;
        Fr(i, 0, n) cin >> a[i];
        sort(a, a+n);
        ans = k*(a[k-1] <= p);
        Fr(i, 0, k) {
            sum[i] = (!i ? 0 : sum[i-1]+a[i-1]);
            if (sum[i] <= p)
                ans = max(ans, i);
            // cnt.clear();
            for(int j = i+k; j <= n; j+=k) {
                sum[j] = (j<2*k ? 0 : sum[j-k])+a[j-1];
                if (sum[j]+sum[i] <= p) {
                    ans = max(ans, j);
                    cerr _ sum[i]+sum[j] _ ans _ endl;
                }
            }
        }
        //Fr(i, k, n) assert(sum[i]+sum[i%k] < sum[i+1]+sum[(i+1)%k]);
        //Fr(i, k, n+1) pkn[i] = pkn[i-k]+a[i-1];
        //Fr(i, 0, n+1) cerr _ sum[i];
        //cerr _ endl;
        cout << ans << endl;
    }

}


#pragma g++ optimize("Ofast")
#pragma loop_opt(on)
#include <bits/stdc++.h>
using namespace std;

#ifdef DEBUG
#define FAST ;
#else
#define FAST ios::sync_with_stdio(0);cin.tie(0);
#define endl '\n'
#endif
#define _ <<' '<<
#define Fr(i, s, e) for(auto i = s; i < e; ++i)
#define Ft first
#define Sd second
using ll = long long;
constexpr ll MAX = 2e5+5;
constexpr ll INF = 2134567890;

signed main() {
    FAST;

    int n, p, k;
    int *a = new int[MAX];
    int *sum = new int[MAX];
    int ans;
    // map<int, int> cnt;
    int T; cin >> T; Fr(t, 0, T) {
        cin >> n >> p >> k;
        Fr(i, 0, n) cin >> a[i];
        sort(a, a+n);
        ans = k*(a[k-1] <= p);
        Fr(i, 0, k) {
            sum[i] = (!i ? 0 : sum[i-1]+a[i-1]);
            if (sum[i] <= p)
                ans = max(ans, i);
            // cnt.clear();
            for(int j = i+k; j <= n; j+=k) {
                sum[j] = (j<2*k ? 0 : sum[j-k])+a[j-1];
                if (sum[j]+sum[i] <= p) {
                    ans = max(ans, j);
                    cerr _ sum[i]+sum[j] _ ans _ endl;
                }
            }
        }
        //Fr(i, k, n) assert(sum[i]+sum[i%k] < sum[i+1]+sum[(i+1)%k]);
        //Fr(i, k, n+1) pkn[i] = pkn[i-k]+a[i-1];
        //Fr(i, 0, n+1) cerr _ sum[i];
        //cerr _ endl;
        cout << ans << endl;
    }

}


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

#ifdef DEBUG
#define FAST ;
#else
#define FAST ios::sync_with_stdio(0);cin.tie(0);
#define endl '\n'
#endif
#define _ <<' '<<
#define Fr(i, s, e) for(auto i = s; i < e; ++i)
#define Ft first
#define Sd second
using ll = long long;
using pii = pair<ll, int>;
constexpr ll MAX = 2e5+5;
constexpr ll INF = 2134567890;

inline ll calc(const ll time, const ll a, const ll b, const ll na, const ll nb, const ll ta, const ll tb) {
    if (time < ll(na)*a + nb*b)
        return 0;
    if (time <= ll(ta)*a + nb*b)
        return nb + (time-nb*b)/a;
    return ta+min((time-ta*a)/b, tb);
};

signed main() {
    FAST;

    ll n, T, a, b, ans, ta, tb, na, nb, nw;
    pii *need = new pii[MAX];
    int M;cin>>M;Fr(m, 0, M) {
        cin >> n >> T >> a >> b;
        Fr(i, 0, n) cin >> need[i].Sd;
        Fr(i, 0, n) cin >> need[i].Ft;
        sort(need, need+n);
        ta = tb = 0;
        Fr(i, 0, n) need[i].Sd ? tb++ : ta++;
        na = nb = 0;
        ans = 0;
        Fr(i, 0, n) {
            nw = need[i].Ft;
            ans = max(ans, calc(nw-1, a, b, na, nb, ta, tb));
            need[i].Sd ? nb++ : na++;
            ans = max(ans, calc(nw, a, b, na, nb, ta, tb));
            //cerr _ na _ nb _ ans _ endl;
        }
        ans = max(ans, calc(T, a, b, na, nb, ta, tb));
        cout << ans << endl;
    }

}