import java.util.*;

class Solution {
    public String solution(String s) {
        String answer = "";
        List<String> list = new ArrayList<>();

        
        for(int i=0; i<s.length(); i++) {
            String temp = String.valueOf(s.charAt(i));
            
            if(temp.equals(" ")) {
                if(!list.isEmpty()) {
                    for(int j=0; j<list.size(); j++) {
                        answer += j%2==0 ? list.get(j).toUpperCase() : list.get(j).toLowerCase();
                    }
                    
                    list.clear();
                }
                
                answer += " ";
            } else {
                list.add(temp);
            }
        }
        
        if(!list.isEmpty()) {
            for(int i=0; i<list.size(); i++) {
                answer += i%2==0 ? list.get(i).toUpperCase() : list.get(i).toLowerCase();
            }

            list.clear();
        }
        
        return answer;
    }
}