#include <iostream>
using namespace std;
int main() {
// your code goes here
int t, arr[10], minVal, minVal2, minIndex, minIndex2;
cin>>t;
while(t--) {
minVal=15; minVal2=15; minIndex=-1; minIndex2=-1;
for(int i=0; i<10; i++) {
cin>>arr[i];
if(arr[i]<minVal) {
minVal=arr[i]; minIndex=i;
}
else if(arr[i]<minVal2 && i!=0) {
minVal2=arr[i]; minIndex2=i;
}
}
if(minIndex!=0) for(;minVal>=0; minVal--) cout<<minIndex;
else if(minVal==minVal2) for(;minVal2>=0; minVal2--) cout<<minIndex2;
else {
cout<<1; for(;minVal>=0; minVal--) cout<<minIndex;
}
cout<<endl;
}
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKaW50IG1haW4oKSB7CgkvLyB5b3VyIGNvZGUgZ29lcyBoZXJlCglpbnQgdCwgYXJyWzEwXSwgbWluVmFsLCBtaW5WYWwyLCBtaW5JbmRleCwgbWluSW5kZXgyOwoJY2luPj50OwoJd2hpbGUodC0tKSB7CgkJbWluVmFsPTE1OyBtaW5WYWwyPTE1OyBtaW5JbmRleD0tMTsgbWluSW5kZXgyPS0xOwoJCWZvcihpbnQgaT0wOyBpPDEwOyBpKyspIHsKCQkJY2luPj5hcnJbaV07IAoJCQlpZihhcnJbaV08bWluVmFsKSB7CgkJCQltaW5WYWw9YXJyW2ldOyBtaW5JbmRleD1pOwoJCQl9CgkJCWVsc2UgaWYoYXJyW2ldPG1pblZhbDIgJiYgaSE9MCkgewoJCQkJbWluVmFsMj1hcnJbaV07IG1pbkluZGV4Mj1pOwoJCQl9CgkJfQoJCWlmKG1pbkluZGV4IT0wKSBmb3IoO21pblZhbD49MDsgbWluVmFsLS0pIGNvdXQ8PG1pbkluZGV4OwoJCWVsc2UgaWYobWluVmFsPT1taW5WYWwyKSBmb3IoO21pblZhbDI+PTA7IG1pblZhbDItLSkgY291dDw8bWluSW5kZXgyOwoJCWVsc2UgewoJCQljb3V0PDwxOyBmb3I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