#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;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8c3RyaW5nPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwpzdHJpbmcgcyx0OwppbnQgaSxqLHRsZW4sc2xlbixwb3MsdHQ7CmJvb2wgdXNlZFsxMDVdLHVzZWQyWzEwNV07CmxvbmcgbG9uZyBoMT0xLGgyPTE7CmludCBtYWluKCkgewoJY2luID4+IHMgPj4gdDsKCXRsZW4gPSB0Lmxlbmd0aCgpOwoJc2xlbiA9IHMubGVuZ3RoKCk7CgkJaW50IHogPSAwOwoJZm9yKGk9MDtpPHRsZW47aSsrKXsKCQlmb3Ioaj0wO2o8c2xlbjtqKyspCgkJCWlmKHRbaV0gPT0gc1tqXSAmJiAhdXNlZFtqXSApewoJCQkJeisrOwoJCQkJdXNlZFtqXT0xOwoJCQl9Cgl9CglqPTA7Cglmb3IoaT0wO2k8dGxlbjtpKyspCgkJZm9yKDtqPHNsZW47aisrKQoJaWYgKHRbaV0gPT0gc1tqXSl7cG9zKys7YnJlYWs7fQoJaWYocG9zID09IHRsZW4pewoJCWNvdXQgPDwiYXV0b21hdG9uXG4iOwoJCXJ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