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

class Ideone
{
	public static void main (String[] args) throws java.lang.Exception
	{
		String str = " text\n \n \n text"; 
		System.out.println(str.replaceAll("(?Um)^[\\s&&[^\r\n]]+$", "").replace("\n", "\\n"));
	}
}