#include <iostream>
#include <string>
using namespace std;
string s,t;
int i,j,tlen,slen,pos,tt;
bool used[105],used2[105];
long long h1=1,h2=1;
int main() {
	cin >> s >> t;
	tlen = t.length();
	slen = s.length();
		int z = 0;
	for(i=0;i<tlen;i++){
		for(j=0;j<slen;j++)
			if(t[i] == s[j] && !used[j] ){
				z++;
				used[j]=1;
			}
	}
	j=0;
	for(i=0;i<tlen;i++)
		for(;j<slen;j++)
	if (t[i] == s[j]){pos++;break;}
	if(pos == tlen){
		cout <<"automaton\n";
		return 0;
	}
	else 
	if(slen == tlen){
		for(i=0;i<tlen;i++){
			for(j=0;j<slen;j++)
			if(used2[j] == 0&&t[i]==s[j]) {used2[j]=1;tt++;}
		}
		cout<<"tt="<<tt<<endl;
		if(tt == slen){
			cout <<"array\n";
			return 0;
		}	
	}
	else

	if( z == tlen)
	{	cout << "both\n";return 0;}
	
		cout << "need tree\n";
	return 0;
}