public static void main(String[] args){
		
		Scanner in = new Scanner(System.in);
		
		String s = in.next();
		String t = in.next();
		
		String result = "need tree";
		
		if(checkAuto(s, t)) result = "automaton";
		else if(equalArrays(sortChars(s), sortChars(t))) result = "array";
		else if(checkAuto(new String(sortChars(s)), new String(sortChars(t)))) result = "both";
		System.out.println(result);
	}