#include <bits/stdc++.h>
using namespace std;
int dx[] = {0, 0, 1, -1, 1, 1, -1, -1};
int dy[] = {1, -1, 0, 0, 1, -1, 1, -1};
int geti() {
  int y = 0, s = 1;
  char c = getchar();
  while (!isdigit(c) && c != '-') c = getchar();
  if (c == '-') s = -1, c = getchar();
  while (isdigit(c)) y = y * 10 + (c - '0'), c = getchar();
  return s * y;
}
int main() {
  string s, t;
  bool f = 0, f2 = 0, vis[105];
  int c = 0;
  memset(vis, 0, sizeof(vis));
  cin >> s >> t;
  int g = 0;
  for (int i = 0; i < ((int)t.size()); i++)
    for (int j = g; j < ((int)s.size()); j++) {
      if (t[i] == s[j] && !vis[j]) {
        vis[j] = 1;
        c++;
        g = j;
        break;
      }
    }
  if (c == ((int)t.size())) f = 1;
  if (f && ((int)s.size()) != ((int)t.size())) {
    printf("automaton\n");
    return 0;
  }
  memset(vis, 0, sizeof(vis));
  sort(s.begin(), s.end());
  sort(t.begin(), t.end());
  c = 0;
  for (int i = 0; i < ((int)t.size()); i++)
    for (int j = 0; j < ((int)s.size()); j++) {
      if (t[i] == s[j] && !vis[j]) {
        vis[j] = 1;
        c++;
        break;
      }
    }
  if (c == ((int)t.size()) && ((int)t.size()) == ((int)s.size())) f2 = 1;
  if (f2) {
    printf("array\n");
    return 0;
  }
  if (c == ((int)t.size()))
    printf("both\n");
  else
    printf("need tree\n");
  return 0;
}
