BPL Mubarak : Here is the problem of this code

/*
 *******************************************
 *      * AUTHOR : Nihan_Khan              *
 *      * NICK   :   NullByte              *
 *      * CREATED: 10.06.2023 07:19:01     *
 *******************************************
*/
#include <bits/stdc++.h>

#define sz size()
const int INF = 1e9+7;
#define pb(x) push_back(x)

using namespace std;

int main(int argc, char **argv)
{
    ios::sync_with_stdio(false);
    cin.tie(0);

    //freopen("input.txt", "r", stdin);

    int tt;

    cin >> tt;

    for(int i = 0; i < tt; i++)
    {
    	string s;

    	cin >> s;

    	int balls = 0;
    	int overs = 0;

    	for (char c : s)
    	{
    		if (c >= '0' && c <= '6')
    		{
    			balls++;
    		}
    		else if (c == 'O')
    		{
    			balls++;
    		}
    		else if (c != 'N' && c != 'W' && c != 'D')
    		{
    			break;
    		}
    		if (balls % 6 == 0 && balls > 0)
    		{
    			overs++;
    		}
    	}

    	//cout << "Balls : " << balls << endl;
   		//cout << "Overs : " << overs << endl;

    	if (balls == 6)
    	{
    		cout << overs << " " << "OVER" << endl;
    	}
    	else if (balls < 6)
    	{
    		cout << balls % 6 << " " << (balls % 6 == 1 ? "BALL" : "BALLS") << endl;
    	}
    	else if (balls > 6)
    	{
    		int ball = (balls % 6);

    		cout << overs << " " << "OVER" << " " << ball << " BALL" << endl;
    	}
    }
    
    
    return 0;   
}