#include<iostream>
#include<algorithm>
#include<cstring>
#include<map>
using namespace std;
int T, n;
string s[900005];
map<string, int>mm;//存放每一个字符串是否出现过
int main()
{cin >> T;while (T--){mm.clear();//每次清空 mm里面的数值防止混乱cin >> n;for (int i = 0; i < n; i++) {cin >> s[i];mm[s[i]] = 1;}for (int i = 0; i < n; i++){int aa = 0;for (int j = 1; j < s[i].size(); j++) {string s1 = s[i].substr(0, j);//前面的放一堆string s2 = s[i].substr(j);//后面放一堆if (mm[s1] && mm[s2]) {//两个部分都行aa = 1;//标记break;//退出循环}}cout << aa;}cout << endl;}return 0;
}