#include <bits/stdc++.h>
using namespace std;
char a[110], b[110];
char ans[110];
int fi[30];
int se[30];
int la, lb;
int dp[110][110];
bool deal_f() {
  memset(dp, 0, sizeof(dp));
  for (int i = 1; i <= la; i++)
    for (int j = 1; j <= lb; j++) {
      if (a[i] == b[j]) dp[i][j] = max(dp[i][j], dp[i - 1][j - 1] + 1);
      dp[i][j] = max(dp[i][j - 1], dp[i][j]);
      dp[i][j] = max(dp[i][j], dp[i - 1][j]);
    }
  if (dp[la][lb] == lb)
    return 1;
  else
    return 0;
}
int deal_a() {
  for (int i = 0; i < 26; i++) {
    if (se[i] > fi[i]) return 0;
  }
  if (la == lb)
    return 1;
  else
    return 3;
}
void deal() {
  if (deal_f()) {
    printf("automaton\n");
    return;
  }
  int tp = deal_a();
  if (tp == 1)
    printf("array\n");
  else if (tp == 3)
    printf("both\n");
  else
    printf("need tree\n");
}
int main() {
  scanf("%s", a + 1);
  scanf("%s", b + 1);
  la = strlen(a + 1);
  lb = strlen(b + 1);
  memset(fi, 0, sizeof(fi));
  memset(se, 0, sizeof(se));
  for (int i = 1; i <= la; i++) fi[a[i] - 'a']++;
  for (int i = 1; i <= lb; i++) se[b[i] - 'a']++;
  deal();
  return 0;
}
