/* package whatever; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
class Ideone
{
	public static void main (String[] args) throws java.lang.Exception
	{
		List<String> words = new ArrayList<>(); 

        words.add("Kane");
        words.add("Cane");
        words.add("Fame");
        words.add("Dame");
        words.add("Lame");  
        words.add("Same");
        
        marklength4(words);
        
        System.out.println(words);

	}
	
	public static void marklength4(List<String> themarklength){
		ListIterator<String> lit = 
			themarklength.listIterator(themarklength.size());
		boolean shouldInsert = false;	
		while(lit.hasPrevious()) {
			if (shouldInsert) {
				lit.add("****");
				lit.previous();
				shouldInsert = false;
			}
			final String n = lit.previous();
			shouldInsert = (n.length() == 4);
		}
		if (shouldInsert) {
			lit.add("****");
		}
    }

}