#include #include #include #include

using namespace std;

typedef pair <int, int> ipr; typedef map <int, int> imap; typedef imap :: iterator imap_it;

struct seg { int l, r, s, a; seg *ls, *rs; }; struct oper { int x, ya, yb, t; }; inline bool operator <(const oper& a, const oper& b) { return a. x < b. x; }

const int maxn = 400009;

int n, m, a[maxn], pr[maxn], su[maxn], t; oper o[maxn]; seg sbuf_arr[maxn * 2], *sbuf, *rt; imap ri;

#define midp(p) ((p->l+p->r)»1) inline seg* sgtBuild(int l, int r) { seg* p(sbuf ++); p-> l = l, p-> r = r; p-> s = 0, p-> a = 0; if (l + 1 < r) { p-> ls = sgtBuild(l, midp(p)); p-> rs = sgtBuild(midp(p), r); } return p; } inline void sgtChg(seg* p, int l, int r, int v) { if (p-> l == l && p-> r == r) p-> a += v; else if (r <= midp(p)) sgtChg(p-> ls, l, r, v); else if (l >= midp(p)) sgtChg(p-> rs, l, r, v); else sgtChg(p-> ls, l, midp(p), v), sgtChg(p-> rs, midp(p), r, v); if (p-> a) p-> s = 1; else if (p-> l + 1 < p-> r) p-> s = p-> ls-> s & p-> rs-> s; else p-> s = 0; } inline int sgtQry(seg* p, int l, int r) { if (p-> l == l && p-> r == r) return p-> s; else if (r <= midp(p)) return sgtQry(p-> ls, l, r); else if (l >= midp(p)) return sgtQry(p-> rs, l, r); else return sgtQry(p-> ls, l, midp(p)) & sgtQry(p-> rs, midp(p), r); }

bool sov() { scanf("%d", &n); ri. clear(); for (int i = 0; i < n; ++ i) { scanf("%d", a + i); imap_it it(ri. find(a[i])); if (it != ri. end()) { pr[i] = it-> second + 1; it-> second = i; } else { pr[i] = 0; ri. insert(ipr(a[i], i)); } } ri. clear(); for (int i = n - 1; i >= 0; – i) { imap_it it(ri. find(a[i])); if (it != ri. end()) { su[i] = it-> second - 1; it-> second = i; } else { su[i] = n - 1; ri. insert(ipr(a[i], i)); } } sbuf = sbuf_arr; rt = sgtBuild(0, n); m = 0; for (int i = 0; i < n; ++ i) { o[m]. x = pr[i]; o[m]. ya = i; o[m]. yb = su[i]; o[m]. t = 1; ++ m; o[m]. x = i + 1; o[m]. ya = i; o[m]. yb = su[i]; o[m]. t = -1; ++ m; } sort(o, o + m); for (int i = 0, j = 0; i < n; ++ i) { for (; j < m && o[j]. x == i; ++ j) sgtChg(rt, o[j]. ya, o[j]. yb + 1, o[j]. t); if (sgtQry(rt, i, n) <= 0) return 0; } return 1; }

int main() { #ifndef ONLINE_JUDGE freopen(".in", “r”, stdin); #endif

int t;
scanf("%d", &t);
while (t --)
	puts(sov() ? "non-boring" : "boring");

}