class Test {
    public static void main (String[] args) throws java.lang.Exception {
	String s = "t e s t   s t r i n g";
        System.out.println(s.replaceAll("( )  | ", "$1"));
    }
}