#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int d, x, t = 0, k = 0, l = 0;
  string s, s1;
  char ch;
  cin >> s >> s1;
  map<char, long long int> c1;
  map<char, long long int> c2;
  for (int i = 0; i < s1.size(); i++) {
    c1[s1[i]]++;
  }
  for (int i = 0; i < s.size(); i++) {
    c2[s[i]]++;
  }
  for (int i = 97; i <= 123; i++) {
    ch = i;
    if (c1[ch] != 0) {
      if (c1[ch] > c2[ch]) {
        k = 1;
        break;
      }
    }
  }
  if (k == 1) {
    cout << "need tree\n";
  } else {
    k = 0, t = s.size() + 1, l = 0;
    for (int i = s1.size() - 1; i >= 0; i--) {
      k = 0;
      for (int j = s.size() - 1; j >= 0; j--) {
        if (s[j] == s1[i] && j < t) {
          t = j;
          k = 1;
          break;
        }
      }
      if (k == 0) {
        l = 1;
        break;
      }
    }
    if (s.size() == s1.size()) {
      cout << "array\n";
    } else if (l == 0) {
      cout << "automaton\n";
    } else {
      cout << "both\n";
    }
  }
}
