#include <bits/stdc++.h>
using namespace std;
int main() {
  string s, t;
  cin >> s;
  cin >> t;
  int lengthS = s.length(), lengthT = t.length();
  int a[27], b[27];
  memset(a, 0, sizeof(a));
  memset(b, 0, sizeof(b));
  for (int i = 0; i < s.length(); i++) {
    a[s[i] - 'a' + 1]++;
  }
  for (int i = 0; i < t.length(); i++) {
    b[t[i] - 'a' + 1]++;
  }
  bool flag1 = false;
  bool flag2 = false;
  bool flag3 = false;
  if (lengthS < lengthT)
    cout << "need tree" << endl;
  else if (lengthS == lengthT) {
    for (int i = 0; i < t.length(); i++) {
      if (a[t[i] - 'a' + 1] != b[t[i] - 'a' + 1]) {
        cout << "need tree" << endl;
        flag1 = true;
        break;
      }
    }
    if (!flag1) {
      cout << "array" << endl;
    }
  } else {
    for (int i = 0; i < t.length(); i++) {
      if (a[t[i] - 'a' + 1] < b[t[i] - 'a' + 1]) {
        cout << "need tree" << endl;
        flag2 = true;
        break;
      }
    }
    if (!flag2) {
      int dp[lengthS + 1][lengthT + 1];
      for (int i = 0; i <= lengthS; i++) dp[i][0] = 0;
      for (int j = 0; j <= lengthT; j++) dp[0][j] = 0;
      for (int i = 0; i < lengthS; i++) {
        for (int j = 0; j < lengthT; j++) {
          if (s[i] == t[j])
            dp[i + 1][j + 1] = dp[i][j] + 1;
          else
            dp[i + 1][j + 1] = max(dp[i + 1][j], dp[i][j + 1]);
        }
      }
      if (dp[lengthS][lengthT] == lengthT) {
        cout << "automaton" << endl;
      } else
        cout << "both" << endl;
    }
  }
}
