#include <bits/stdc++.h>
using namespace std;
int main() {
  int a[26] = {0};
  int b[26] = {0};
  string s, t;
  int j = 0;
  cin >> s >> t;
  bool f1 = false, f2 = false;
  for (int i = 0; i < s.length(); i++) a[s[i] - 'a']++;
  for (int i = 0; i < t.length(); i++) b[t[i] - 'a']++;
  for (int i = 0; i < 26; i++) {
    if (b[i] > a[i]) {
      cout << "need tree\n";
      return 0;
    }
    if (a[i] > b[i]) f1 = true;
  }
  for (int i = 0; i < t.length(); i++) {
    if (j == s.length()) {
      f2 = true;
      goto A;
    }
    while (s[j] != t[i]) {
      j++;
      if (j == s.length()) {
        f2 = true;
        goto A;
      }
    }
    j++;
  }
A:;
  if (f1 == true) {
    if (f2 == true)
      cout << "both\n";
    else
      cout << "automaton\n";
  } else
    cout << "array" << endl;
  return 0;
}
