#include <bits/stdc++.h>
using namespace std;
char s[110], t[110];
int cnt[2][30];
int main() {
  while (scanf("%s%s", s, t) != EOF) {
    memset(cnt, 0, sizeof(cnt));
    int lens = strlen(s);
    int lent = strlen(t);
    for (int i = 0; i < lens; ++i) ++cnt[0][s[i] - 'a'];
    for (int i = 0; i < lent; ++i) ++cnt[1][t[i] - 'a'];
    bool tree = false;
    bool aut = false;
    bool array = false;
    for (int i = 0; i < 26; ++i) {
      if (cnt[0][i] < cnt[1][i]) {
        tree = true;
        break;
      }
      if (cnt[0][i] > cnt[1][i]) aut = true;
    }
    if (tree) {
      puts("need tree");
      continue;
    }
    int loc = 0;
    for (int i = 0; i < lent; ++i) {
      char tem = t[i];
      for (loc; loc < lens;)
        if (s[loc++] == tem) break;
      if (loc == lens && s[loc - 1] != tem) array = true;
    }
    if (array && aut)
      puts("both");
    else if (array)
      puts("array");
    else
      puts("automaton");
  }
  return 0;
}
