import java.io.*;
class Console
{	private static PrintWriter video = new PrintWriter(System.out, true);
	private static BufferedReader tastiera = new BufferedReader(new InputStreamReader(System.in));
	private static StreamTokenizer tas = new StreamTokenizer(tastiera);
	// lettura e scrittura di un singolo carattere
	public static char leggiUnCarattere()
	{ 	try { char c = (char)tastiera.read(); return c;  }
		catch(IOException e){System.out.println(e.getMessage()); return '\0';}
	}
	public static void scriviUnCarattere(char c)
	{	video.print(c);
	}
	// letture di linee
	public static String leggiLinea()
	{	try {String s = tastiera.readLine(); return s; }
		catch(IOException e){System.out.println(e.getMessage()); return "\0";}
	}
	public static char leggiCarattere()
	{	try {String s = tastiera.readLine(); char c = s.charAt(0);return c;} 
		catch(IOException e){System.out.println(e.getMessage()); return '\0';}
		
	}
	public static String leggiStringa()
	{	try {String s = tastiera.readLine(); return s.trim(); }
		catch(IOException e){System.out.println(e.getMessage()); return "\0";}
	}
	public static boolean leggiBooleano()
	{	try { String s = tastiera.readLine(); 
		      boolean b = Boolean.valueOf(s).booleanValue(); return b; }
		catch(IOException e){System.out.println(e.getMessage()); return false;}
	}
	public static int leggiIntero()
	{	try { String s = tastiera.readLine(); int i = Integer.parseInt(s); return i; }
		catch(IOException e){System.out.println(e.getMessage()); return 0;}
	}
	public static double leggiReale()
	{	try { String s = tastiera.readLine(); double d = Double.parseDouble(s); return d; }
		catch(IOException e){System.out.println(e.getMessage()); return 0;}
	}
	// letture di token
	public static char leggiCar()
	{	try { tas.nextToken(); return tas.sval.charAt(0); }
		catch(IOException e){System.out.println(e.getMessage()); return '\0';}
	}
	public static String leggiStr()
	{	try { tas.nextToken(); return tas.sval; }
		catch(IOException e){System.out.println(e.getMessage()); return "\0";}
	}
	public static boolean leggiBool()
	{	try { tas.nextToken(); return (tas.sval.equals("true")); }
		catch(IOException e){System.out.println(e.getMessage()); return false;}
	}
	public static int leggiInt()
	{	try { tas.nextToken(); return (int)tas.nval; }
		catch(IOException e){System.out.println(e.getMessage()); return 0;}
	}	
	public static double leggiReal()
	{	try { tas.nextToken(); return tas.nval; }
		catch(IOException e){System.out.println(e.getMessage()); return 0;}
	}
	public static void fineLinea()
	{	try {String s = tastiera.readLine(); }
		catch(IOException e){System.out.println(e.getMessage()); }
	}
	// scritture di linee
	public static void scriviCarattere(char c)
	{	video.print(c); video.println();
	}
	public static void scriviStringa(String s)
	{	video.println(s);
	}
	public static void scriviBooleano(boolean b)
	{	video.println(b);
	}
	public static void scriviIntero(int i)
	{	video.println(i);
	}
	public static void scriviReale(double d) 
	{	video.println(d);
	}
	// scritture di token + spazio
	public static void scriviCar(char c)
	{	video.print(c); video.print(' ');
	}
	public static void scriviStr(String s)
	{	video.print(s); video.print(' ');
	}
	public static void scriviBool(boolean b)
	{	video.print(b); video.print(' ');
	}
	public static void scriviInt(int i)
	{	video.print(i); video.print(' ');
	}
	public static void scriviReal(double d) 
	{	video.print(d); video.print(' ');
	}
	// scrittura di nuova linea
	public static void nuovaLinea() 
	{	video.println();
	}
	
	
}