#include <bits/stdc++.h>
using namespace std;
long long int mod = 1000000007;
bool isSubsequence(string s, string t) {
  if (s.size() > t.size()) return false;
  int i = 0, j = 0;
  int n1 = s.size(), n2 = t.size();
  while ((i < n1) && (j < n2)) {
    if (s[i] == t[j]) {
      i++;
      j++;
    } else {
      j++;
    }
  }
  return i == n1;
}
int main() {
  string s, t;
  long long int i, j;
  cin >> s >> t;
  if (s.length() >= t.length()) {
    if (s.length() == t.length()) {
      long long int a[256], b[256];
      for (i = 0; i < 256; i++) {
        a[i] = b[i] = 0;
      }
      for (i = 0; i < s.length(); i++) {
        a[s[i]]++;
        b[t[i]]++;
      }
      for (i = 0; i < 256; i++) {
        if (a[i] != b[i]) break;
      }
      if (i == 256)
        cout << "array\n";
      else
        cout << "need tree\n";
    } else {
      long long int a[26], b[26];
      for (i = 0; i < 26; i++) {
        a[i] = b[i] = 0;
      }
      for (i = 0; i < s.length(); i++) {
        a[s[i] - 'a']++;
      }
      for (i = 0; i < t.length(); i++) {
        b[t[i] - 'a']++;
      }
      for (i = 0; i < t.length(); i++) {
        if (b[t[i] - 'a'] > a[t[i] - 'a']) break;
      }
      if (i == t.length()) {
        if (isSubsequence(t, s))
          cout << "automaton\n";
        else
          cout << "both\n";
      } else
        cout << "need tree\n";
    }
  } else {
    cout << "need tree\n";
  }
}
