#include <bits/stdc++.h>
using namespace std;
string sa, sb;
int ca[27];
int cb[27];
int main() {
  cin >> sa >> sb;
  int na = sa.size(), nb = sb.size();
  if (na < nb) {
    cout << "need tree";
    return 0;
  }
  int lp = 0, rp = 0;
  for (; lp < na; lp++) {
    if (sa[lp] == sb[rp]) rp++;
  }
  if (rp == nb) {
    cout << "automaton";
    return 0;
  }
  if (na == nb) {
    memset(ca, 0, sizeof(ca));
    memset(cb, 0, sizeof(cb));
    for (int j = 0; j < nb; j++) {
      ca[sa[j] - 'a']++;
      cb[sb[j] - 'a']++;
    }
    bool bb = 1;
    for (int j = 0; j < 26; j++) {
      if (ca[j] != cb[j]) {
        bb = 0;
        break;
      }
    }
    if (bb) {
      cout << "array";
      return 0;
    }
  }
  for (int i = 0; i < na; i++) {
    for (int j = i; j < na; j++) {
      if (j - i + 1 >= nb) {
        memset(ca, 0, sizeof(ca));
        memset(cb, 0, sizeof(cb));
        for (int k = i; k <= j; k++) {
          ca[sa[k] - 'a']++;
        }
        for (int k = 0; k < nb; k++) {
          cb[sb[k] - 'a']++;
        }
        bool bb = 1;
        for (int k = 0; k < 26; k++) {
          if (ca[k] < cb[k]) {
            bb = 0;
            break;
          }
        }
        if (bb) {
          cout << "both";
          return 0;
        }
      }
    }
  }
  cout << "need tree";
}
