import java.util.ArrayList;
import java.util.Scanner;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Main {

    public static void main(String[] args) {
        ArrayList<String> sentences = new ArrayList<>();
        sentences.add("I heard the pastor sing live verses easily.");
        sentences.add("Deep episodes of Deep Space Nine came on the television only after the news.\n");
        sentences.add("Digital alarm clocks scare area children.");
        sentences.add("test string");
        sentences.add("this is string");

        for (String sentence: sentences) {
            Pattern pattern = Pattern.compile("([a-zA-Z]+) \\1", Pattern.CASE_INSENSITIVE);
            Matcher matcher = pattern.matcher(sentence);
            String output = matcher.replaceAll("$1");
            System.out.println(output);
        }
    }
}