This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#define f first
#define s second
#define m_p make_pair
#define vec vector
#define pb push_back
#define sz(x) (int)(x).size()
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define fast_rmi ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
typedef long long ll;
vec<int>cnt(5,0);
string cr;
//string prec[4][4][4][4][16];
string answer[4][4][4][4][16];
string find_max(string ans,int k){
string me=ans.substr(0,k);
for(int i=0;i+k-1<sz(ans);i++){
string w=ans.substr(i,k);
me=max(me,w);
}
return me;
}
//void rec(int i,int mx){
// if(i){
// for(int k=1;k<=i;k++){
// string me=find_max(cr,k);
// if(prec[cnt[0]][cnt[1]][cnt[2]][cnt[3]][k]=="" ||
// prec[cnt[0]][cnt[1]][cnt[2]][cnt[3]][k]>me){
// prec[cnt[0]][cnt[1]][cnt[2]][cnt[3]][k]=me;
// answer[cnt[0]][cnt[1]][cnt[2]][cnt[3]][k]=cr;
// }
// }
// }
// for(int j=0;j<=3;j++){
// ++cnt[j];
// if(cnt[j]<=3){
// cr.pb('1'+j);
// rec(i+1,max(j,mx));
// cr.pop_back();
// }
// --cnt[j];
// }
//}
signed main(){
fast_rmi;
// rec(0,-1);
// for(int i=0;i<4;i++){
// for(int j=0;j<4;j++){
// for(int k=0;k<=3;k++){
// for(int t=0;t<=3;t++){
// for(int cnt=1;cnt<=i+j+k+t;cnt++){
// cout<<"answer["<<i<<"]["<<j<<"]["<<k<<"]["<<t<<"]["<<cnt<<"]="<<"\""<<answer[i][j][k][t][cnt]<<"\""<<";"<<'\n';
// }
// }
// }
// }
// }
// return 0;
{
answer[0][0][0][1][1]="4";
answer[0][0][0][2][1]="44";
answer[0][0][0][2][2]="44";
answer[0][0][0][3][1]="444";
answer[0][0][0][3][2]="444";
answer[0][0][0][3][3]="444";
answer[0][0][1][0][1]="3";
answer[0][0][1][1][1]="34";
answer[0][0][1][1][2]="34";
answer[0][0][1][2][1]="344";
answer[0][0][1][2][2]="434";
answer[0][0][1][2][3]="344";
answer[0][0][1][3][1]="3444";
answer[0][0][1][3][2]="3444";
answer[0][0][1][3][3]="4344";
answer[0][0][1][3][4]="3444";
answer[0][0][2][0][1]="33";
answer[0][0][2][0][2]="33";
answer[0][0][2][1][1]="334";
answer[0][0][2][1][2]="334";
answer[0][0][2][1][3]="334";
answer[0][0][2][2][1]="3344";
answer[0][0][2][2][2]="3434";
answer[0][0][2][2][3]="3344";
answer[0][0][2][2][4]="3344";
answer[0][0][2][3][1]="33444";
answer[0][0][2][3][2]="43434";
answer[0][0][2][3][3]="43344";
answer[0][0][2][3][4]="33444";
answer[0][0][2][3][5]="33444";
answer[0][0][3][0][1]="333";
answer[0][0][3][0][2]="333";
answer[0][0][3][0][3]="333";
answer[0][0][3][1][1]="3334";
answer[0][0][3][1][2]="3334";
answer[0][0][3][1][3]="3334";
answer[0][0][3][1][4]="3334";
answer[0][0][3][2][1]="33344";
answer[0][0][3][2][2]="33434";
answer[0][0][3][2][3]="33344";
answer[0][0][3][2][4]="33344";
answer[0][0][3][2][5]="33344";
answer[0][0][3][3][1]="333444";
answer[0][0][3][3][2]="343434";
answer[0][0][3][3][3]="343344";
answer[0][0][3][3][4]="333444";
answer[0][0][3][3][5]="333444";
answer[0][0][3][3][6]="333444";
answer[0][1][0][0][1]="2";
answer[0][1][0][1][1]="24";
answer[0][1][0][1][2]="24";
answer[0][1][0][2][1]="244";
answer[0][1][0][2][2]="424";
answer[0][1][0][2][3]="244";
answer[0][1][0][3][1]="2444";
answer[0][1][0][3][2]="2444";
answer[0][1][0][3][3]="4244";
answer[0][1][0][3][4]="2444";
answer[0][1][1][0][1]="23";
answer[0][1][1][0][2]="23";
answer[0][1][1][1][1]="234";
answer[0][1][1][1][2]="324";
answer[0][1][1][1][3]="234";
answer[0][1][1][2][1]="2344";
answer[0][1][1][2][2]="3424";
answer[0][1][1][2][3]="3244";
answer[0][1][1][2][4]="2344";
answer[0][1][1][3][1]="23444";
answer[0][1][1][3][2]="42434";
answer[0][1][1][3][3]="42344";
answer[0][1][1][3][4]="32444";
answer[0][1][1][3][5]="23444";
answer[0][1][2][0][1]="233";
answer[0][1][2][0][2]="323";
answer[0][1][2][0][3]="233";
answer[0][1][2][1][1]="2334";
answer[0][1][2][1][2]="3324";
answer[0][1][2][1][3]="3234";
answer[0][1][2][1][4]="2334";
answer[0][1][2][2][1]="23344";
answer[0][1][2][2][2]="33424";
answer[0][1][2][2][3]="33244";
answer[0][1][2][2][4]="32344";
answer[0][1][2][2][5]="23344";
answer[0][1][2][3][1]="233444";
answer[0][1][2][3][2]="243434";
answer[0][1][2][3][3]="342344";
answer[0][1][2][3][4]="332444";
answer[0][1][2][3][5]="323444";
answer[0][1][2][3][6]="233444";
answer[0][1][3][0][1]="2333";
answer[0][1][3][0][2]="2333";
answer[0][1][3][0][3]="3233";
answer[0][1][3][0][4]="2333";
answer[0][1][3][1][1]="23334";
answer[0][1][3][1][2]="33324";
answer[0][1][3][1][3]="33234";
answer[0][1][3][1][4]="32334";
answer[0][1][3][1][5]="23334";
answer[0][1][3][2][1]="233344";
answer[0][1][3][2][2]="333424";
answer[0][1][3][2][3]="333244";
answer[0][1][3][2][4]="332344";
answer[0][1][3][2][5]="323344";
answer[0][1][3][2][6]="233344";
answer[0][1][3][3][1]="2333444";
answer[0][1][3][3][2]="2343434";
answer[0][1][3][3][3]="3342344";
answer[0][1][3][3][4]="3332444";
answer[0][1][3][3][5]="3323444";
answer[0][1][3][3][6]="3233444";
answer[0][1][3][3][7]="2333444";
answer[0][2][0][0][1]="22";
answer[0][2][0][0][2]="22";
answer[0][2][0][1][1]="224";
answer[0][2][0][1][2]="224";
answer[0][2][0][1][3]="224";
answer[0][2][0][2][1]="2244";
answer[0][2][0][2][2]="2424";
answer[0][2][0][2][3]="2244";
answer[0][2][0][2][4]="2244";
answer[0][2][0][3][1]="22444";
answer[0][2][0][3][2]="42424";
answer[0][2][0][3][3]="42244";
answer[0][2][0][3][4]="22444";
answer[0][2][0][3][5]="22444";
answer[0][2][1][0][1]="223";
answer[0][2][1][0][2]="223";
answer[0][2][1][0][3]="223";
answer[0][2][1][1][1]="2234";
answer[0][2][1][1][2]="2324";
answer[0][2][1][1][3]="2234";
answer[0][2][1][1][4]="2234";
answer[0][2][1][2][1]="22344";
answer[0][2][1][2][2]="23424";
answer[0][2][1][2][3]="32244";
answer[0][2][1][2][4]="22344";
answer[0][2][1][2][5]="22344";
answer[0][2][1][3][1]="223444";
answer[0][2][1][3][2]="342424";
answer[0][2][1][3][3]="342244";
answer[0][2][1][3][4]="322444";
answer[0][2][1][3][5]="223444";
answer[0][2][1][3][6]="223444";
answer[0][2][2][0][1]="2233";
answer[0][2][2][0][2]="2323";
answer[0][2][2][0][3]="2233";
answer[0][2][2][0][4]="2233";
answer[0][2][2][1][1]="22334";
answer[0][2][2][1][2]="32324";
answer[0][2][2][1][3]="32234";
answer[0][2][2][1][4]="22334";
answer[0][2][2][1][5]="22334";
answer[0][2][2][2][1]="223344";
answer[0][2][2][2][2]="233424";
answer[0][2][2][2][3]="323244";
answer[0][2][2][2][4]="322344";
answer[0][2][2][2][5]="223344";
answer[0][2][2][2][6]="223344";
answer[0][2][2][3][1]="2233444";
answer[0][2][2][3][2]="3342424";
answer[0][2][2][3][3]="3342244";
answer[0][2][2][3][4]="3232444";
answer[0][2][2][3][5]="3223444";
answer[0][2][2][3][6]="2233444";
answer[0][2][2][3][7]="2233444";
answer[0][2][3][0][1]="22333";
answer[0][2][3][0][2]="32323";
answer[0][2][3][0][3]="32233";
answer[0][2][3][0][4]="22333";
answer[0][2][3][0][5]="22333";
answer[0][2][3][1][1]="223334";
answer[0][2][3][1][2]="233324";
answer[0][2][3][1][3]="323234";
answer[0][2][3][1][4]="322334";
answer[0][2][3][1][5]="223334";
answer[0][2][3][1][6]="223334";
answer[0][2][3][2][1]="2233344";
answer[0][2][3][2][2]="2333424";
answer[0][2][3][2][3]="3233244";
answer[0][2][3][2][4]="3232344";
answer[0][2][3][2][5]="3223344";
answer[0][2][3][2][6]="2233344";
answer[0][2][3][2][7]="2233344";
answer[0][2][3][3][1]="22333444";
answer[0][2][3][3][2]="33342424";
answer[0][2][3][3][3]="33342244";
answer[0][2][3][3][4]="33232444";
answer[0][2][3][3][5]="32323444";
answer[0][2][3][3][6]="32233444";
answer[0][2][3][3][7]="22333444";
answer[0][2][3][3][8]="22333444";
answer[0][3][0][0][1]="222";
answer[0][3][0][0][2]="222";
answer[0][3][0][0][3]="222";
answer[0][3][0][1][1]="2224";
answer[0][3][0][1][2]="2224";
answer[0][3][0][1][3]="2224";
answer[0][3][0][1][4]="2224";
answer[0][3][0][2][1]="22244";
answer[0][3][0][2][2]="22424";
answer[0][3][0][2][3]="22244";
answer[0][3][0][2][4]="22244";
answer[0][3][0][2][5]="22244";
answer[0][3][0][3][1]="222444";
answer[0][3][0][3][2]="242424";
answer[0][3][0][3][3]="242244";
answer[0][3][0][3][4]="222444";
answer[0][3][0][3][5]="222444";
answer[0][3][0][3][6]="222444";
answer[0][3][1][0][1]="2223";
answer[0][3][1][0][2]="2223";
answer[0][3][1][0][3]="2223";
answer[0][3][1][0][4]="2223";
answer[0][3][1][1][1]="22234";
answer[0][3][1][1][2]="22324";
answer[0][3][1][1][3]="22234";
answer[0][3][1][1][4]="22234";
answer[0][3][1][1][5]="22234";
answer[0][3][1][2][1]="222344";
answer[0][3][1][2][2]="223424";
answer[0][3][1][2][3]="232244";
answer[0][3][1][2][4]="222344";
answer[0][3][1][2][5]="222344";
answer[0][3][1][2][6]="222344";
answer[0][3][1][3][1]="2223444";
answer[0][3][1][3][2]="2342424";
answer[0][3][1][3][3]="2342244";
answer[0][3][1][3][4]="3222444";
answer[0][3][1][3][5]="2223444";
answer[0][3][1][3][6]="2223444";
answer[0][3][1][3][7]="2223444";
answer[0][3][2][0][1]="22233";
answer[0][3][2][0][2]="22323";
answer[0][3][2][0][3]="22233";
answer[0][3][2][0][4]="22233";
answer[0][3][2][0][5]="22233";
answer[0][3][2][1][1]="222334";
answer[0][3][2][1][2]="232324";
answer[0][3][2][1][3]="232234";
answer[0][3][2][1][4]="222334";
answer[0][3][2][1][5]="222334";
answer[0][3][2][1][6]="222334";
answer[0][3][2][2][1]="2223344";
answer[0][3][2][2][2]="2233424";
answer[0][3][2][2][3]="3232244";
answer[0][3][2][2][4]="3222344";
answer[0][3][2][2][5]="2223344";
answer[0][3][2][2][6]="2223344";
answer[0][3][2][2][7]="2223344";
answer[0][3][2][3][1]="22233444";
answer[0][3][2][3][2]="23342424";
answer[0][3][2][3][3]="23342244";
answer[0][3][2][3][4]="32322444";
answer[0][3][2][3][5]="32223444";
answer[0][3][2][3][6]="22233444";
answer[0][3][2][3][7]="22233444";
answer[0][3][2][3][8]="22233444";
answer[0][3][3][0][1]="222333";
answer[0][3][3][0][2]="232323";
answer[0][3][3][0][3]="232233";
answer[0][3][3][0][4]="222333";
answer[0][3][3][0][5]="222333";
answer[0][3][3][0][6]="222333";
answer[0][3][3][1][1]="2223334";
answer[0][3][3][1][2]="3232324";
answer[0][3][3][1][3]="2323234";
answer[0][3][3][1][4]="3222334";
answer[0][3][3][1][5]="2223334";
answer[0][3][3][1][6]="2223334";
answer[0][3][3][1][7]="2223334";
answer[0][3][3][2][1]="22233344";
answer[0][3][3][2][2]="22333424";
answer[0][3][3][2][3]="32323244";
answer[0][3][3][2][4]="32322344";
answer[0][3][3][2][5]="32223344";
answer[0][3][3][2][6]="22233344";
answer[0][3][3][2][7]="22233344";
answer[0][3][3][2][8]="22233344";
answer[0][3][3][3][1]="222333444";
answer[0][3][3][3][2]="233342424";
answer[0][3][3][3][3]="233342244";
answer[0][3][3][3][4]="323232444";
answer[0][3][3][3][5]="323223444";
answer[0][3][3][3][6]="322233444";
answer[0][3][3][3][7]="222333444";
answer[0][3][3][3][8]="222333444";
answer[0][3][3][3][9]="222333444";
answer[1][0][0][0][1]="1";
answer[1][0][0][1][1]="14";
answer[1][0][0][1][2]="14";
answer[1][0][0][2][1]="144";
answer[1][0][0][2][2]="414";
answer[1][0][0][2][3]="144";
answer[1][0][0][3][1]="1444";
answer[1][0][0][3][2]="1444";
answer[1][0][0][3][3]="4144";
answer[1][0][0][3][4]="1444";
answer[1][0][1][0][1]="13";
answer[1][0][1][0][2]="13";
answer[1][0][1][1][1]="134";
answer[1][0][1][1][2]="314";
answer[1][0][1][1][3]="134";
answer[1][0][1][2][1]="1344";
answer[1][0][1][2][2]="3414";
answer[1][0][1][2][3]="3144";
answer[1][0][1][2][4]="1344";
answer[1][0][1][3][1]="13444";
answer[1][0][1][3][2]="41434";
answer[1][0][1][3][3]="41344";
answer[1][0][1][3][4]="31444";
answer[1][0][1][3][5]="13444";
answer[1][0][2][0][1]="133";
answer[1][0][2][0][2]="313";
answer[1][0][2][0][3]="133";
answer[1][0][2][1][1]="1334";
answer[1][0][2][1][2]="3314";
answer[1][0][2][1][3]="3134";
answer[1][0][2][1][4]="1334";
answer[1][0][2][2][1]="13344";
answer[1][0][2][2][2]="33414";
answer[1][0][2][2][3]="33144";
answer[1][0][2][2][4]="31344";
answer[1][0][2][2][5]="13344";
answer[1][0][2][3][1]="133444";
answer[1][0][2][3][2]="143434";
answer[1][0][2][3][3]="341344";
answer[1][0][2][3][4]="331444";
answer[1][0][2][3][5]="313444";
answer[1][0][2][3][6]="133444";
answer[1][0][3][0][1]="1333";
answer[1][0][3][0][2]="1333";
answer[1][0][3][0][3]="3133";
answer[1][0][3][0][4]="1333";
answer[1][0][3][1][1]="13334";
answer[1][0][3][1][2]="33314";
answer[1][0][3][1][3]="33134";
answer[1][0][3][1][4]="31334";
answer[1][0][3][1][5]="13334";
answer[1][0][3][2][1]="133344";
answer[1][0][3][2][2]="333414";
answer[1][0][3][2][3]="333144";
answer[1][0][3][2][4]="331344";
answer[1][0][3][2][5]="313344";
answer[1][0][3][2][6]="133344";
answer[1][0][3][3][1]="1333444";
answer[1][0][3][3][2]="1343434";
answer[1][0][3][3][3]="3341344";
answer[1][0][3][3][4]="3331444";
answer[1][0][3][3][5]="3313444";
answer[1][0][3][3][6]="3133444";
answer[1][0][3][3][7]="1333444";
answer[1][1][0][0][1]="12";
answer[1][1][0][0][2]="12";
answer[1][1][0][1][1]="124";
answer[1][1][0][1][2]="214";
answer[1][1][0][1][3]="124";
answer[1][1][0][2][1]="1244";
answer[1][1][0][2][2]="2414";
answer[1][1][0][2][3]="2144";
answer[1][1][0][2][4]="1244";
answer[1][1][0][3][1]="12444";
answer[1][1][0][3][2]="41424";
answer[1][1][0][3][3]="41244";
answer[1][1][0][3][4]="21444";
answer[1][1][0][3][5]="12444";
answer[1][1][1][0][1]="123";
answer[1][1][1][0][2]="213";
answer[1][1][1][0][3]="123";
answer[1][1][1][1][1]="1234";
answer[1][1][1][1][2]="2314";
answer[1][1][1][1][3]="2134";
answer[1][1][1][1][4]="1234";
answer[1][1][1][2][1]="12344";
answer[1][1][1][2][2]="23414";
answer[1][1][1][2][3]="31244";
answer[1][1][1][2][4]="21344";
answer[1][1][1][2][5]="12344";
answer[1][1][1][3][1]="123444";
answer[1][1][1][3][2]="341424";
answer[1][1][1][3][3]="341244";
answer[1][1][1][3][4]="312444";
answer[1][1][1][3][5]="213444";
answer[1][1][1][3][6]="123444";
answer[1][1][2][0][1]="1233";
answer[1][1][2][0][2]="2313";
answer[1][1][2][0][3]="2133";
answer[1][1][2][0][4]="1233";
answer[1][1][2][1][1]="12334";
answer[1][1][2][1][2]="31324";
answer[1][1][2][1][3]="31234";
answer[1][1][2][1][4]="21334";
answer[1][1][2][1][5]="12334";
answer[1][1][2][2][1]="123344";
answer[1][1][2][2][2]="233414";
answer[1][1][2][2][3]="323144";
answer[1][1][2][2][4]="312344";
answer[1][1][2][2][5]="213344";
answer[1][1][2][2][6]="123344";
answer[1][1][2][3][1]="1233444";
answer[1][1][2][3][2]="3341424";
answer[1][1][2][3][3]="3341244";
answer[1][1][2][3][4]="3231444";
answer[1][1][2][3][5]="3123444";
answer[1][1][2][3][6]="2133444";
answer[1][1][2][3][7]="1233444";
answer[1][1][3][0][1]="12333";
answer[1][1][3][0][2]="31323";
answer[1][1][3][0][3]="31233";
answer[1][1][3][0][4]="21333";
answer[1][1][3][0][5]="12333";
answer[1][1][3][1][1]="123334";
answer[1][1][3][1][2]="133324";
answer[1][1][3][1][3]="313234";
answer[1][1][3][1][4]="312334";
answer[1][1][3][1][5]="213334";
answer[1][1][3][1][6]="123334";
answer[1][1][3][2][1]="1233344";
answer[1][1][3][2][2]="2333414";
answer[1][1][3][2][3]="3233144";
answer[1][1][3][2][4]="3231344";
answer[1][1][3][2][5]="3123344";
answer[1][1][3][2][6]="2133344";
answer[1][1][3][2][7]="1233344";
answer[1][1][3][3][1]="12333444";
answer[1][1][3][3][2]="33341424";
answer[1][1][3][3][3]="33341244";
answer[1][1][3][3][4]="33132444";
answer[1][1][3][3][5]="32313444";
answer[1][1][3][3][6]="31233444";
answer[1][1][3][3][7]="21333444";
answer[1][1][3][3][8]="12333444";
answer[1][2][0][0][1]="122";
answer[1][2][0][0][2]="212";
answer[1][2][0][0][3]="122";
answer[1][2][0][1][1]="1224";
answer[1][2][0][1][2]="2214";
answer[1][2][0][1][3]="2124";
answer[1][2][0][1][4]="1224";
answer[1][2][0][2][1]="12244";
answer[1][2][0][2][2]="22414";
answer[1][2][0][2][3]="22144";
answer[1][2][0][2][4]="21244";
answer[1][2][0][2][5]="12244";
answer[1][2][0][3][1]="122444";
answer[1][2][0][3][2]="142424";
answer[1][2][0][3][3]="241244";
answer[1][2][0][3][4]="221444";
answer[1][2][0][3][5]="212444";
answer[1][2][0][3][6]="122444";
answer[1][2][1][0][1]="1223";
answer[1][2][1][0][2]="2213";
answer[1][2][1][0][3]="2123";
answer[1][2][1][0][4]="1223";
answer[1][2][1][1][1]="12234";
answer[1][2][1][1][2]="22314";
answer[1][2][1][1][3]="22134";
answer[1][2][1][1][4]="21234";
answer[1][2][1][1][5]="12234";
answer[1][2][1][2][1]="122344";
answer[1][2][1][2][2]="223414";
answer[1][2][1][2][3]="231244";
answer[1][2][1][2][4]="221344";
answer[1][2][1][2][5]="212344";
answer[1][2][1][2][6]="122344";
answer[1][2][1][3][1]="1223444";
answer[1][2][1][3][2]="1342424";
answer[1][2][1][3][3]="2341244";
answer[1][2][1][3][4]="3122444";
answer[1][2][1][3][5]="2213444";
answer[1][2][1][3][6]="2123444";
answer[1][2][1][3][7]="1223444";
answer[1][2][2][0][1]="12233";
answer[1][2][2][0][2]="22313";
answer[1][2][2][0][3]="22133";
answer[1][2][2][0][4]="21233";
answer[1][2][2][0][5]="12233";
answer[1][2][2][1][1]="122334";
answer[1][2][2][1][2]="132324";
answer[1][2][2][1][3]="231234";
answer[1][2][2][1][4]="221334";
answer[1][2][2][1][5]="212334";
answer[1][2][2][1][6]="122334";
answer[1][2][2][2][1]="1223344";
answer[1][2][2][2][2]="2233414";
answer[1][2][2][2][3]="3132244";
answer[1][2][2][2][4]="3122344";
answer[1][2][2][2][5]="2213344";
answer[1][2][2][2][6]="2123344";
answer[1][2][2][2][7]="1223344";
answer[1][2][2][3][1]="12233444";
answer[1][2][2][3][2]="13342424";
answer[1][2][2][3][3]="23341244";
answer[1][2][2][3][4]="32231444";
answer[1][2][2][3][5]="31223444";
answer[1][2][2][3][6]="22133444";
answer[1][2][2][3][7]="21233444";
answer[1][2][2][3][8]="12233444";
answer[1][2][3][0][1]="122333";
answer[1][2][3][0][2]="132323";
answer[1][2][3][0][3]="231233";
answer[1][2][3][0][4]="221333";
answer[1][2][3][0][5]="212333";
answer[1][2][3][0][6]="122333";
answer[1][2][3][1][1]="1223334";
answer[1][2][3][1][2]="3132324";
answer[1][2][3][1][3]="3132234";
answer[1][2][3][1][4]="3122334";
answer[1][2][3][1][5]="2213334";
answer[1][2][3][1][6]="2123334";
answer[1][2][3][1][7]="1223334";
answer[1][2][3][2][1]="12233344";
answer[1][2][3][2][2]="22333414";
answer[1][2][3][2][3]="32323144";
answer[1][2][3][2][4]="31322344";
answer[1][2][3][2][5]="31223344";
answer[1][2][3][2][6]="22133344";
answer[1][2][3][2][7]="21233344";
answer[1][2][3][2][8]="12233344";
answer[1][2][3][3][1]="122333444";
answer[1][2][3][3][2]="133342424";
answer[1][2][3][3][3]="233341244";
answer[1][2][3][3][4]="323231444";
answer[1][2][3][3][5]="322313444";
answer[1][2][3][3][6]="312233444";
answer[1][2][3][3][7]="221333444";
answer[1][2][3][3][8]="212333444";
answer[1][2][3][3][9]="122333444";
answer[1][3][0][0][1]="1222";
answer[1][3][0][0][2]="1222";
answer[1][3][0][0][3]="2122";
answer[1][3][0][0][4]="1222";
answer[1][3][0][1][1]="12224";
answer[1][3][0][1][2]="22214";
answer[1][3][0][1][3]="22124";
answer[1][3][0][1][4]="21224";
answer[1][3][0][1][5]="12224";
answer[1][3][0][2][1]="122244";
answer[1][3][0][2][2]="222414";
answer[1][3][0][2][3]="222144";
answer[1][3][0][2][4]="221244";
answer[1][3][0][2][5]="212244";
answer[1][3][0][2][6]="122244";
answer[1][3][0][3][1]="1222444";
answer[1][3][0][3][2]="1242424";
answer[1][3][0][3][3]="2241244";
answer[1][3][0][3][4]="2221444";
answer[1][3][0][3][5]="2212444";
answer[1][3][0][3][6]="2122444";
answer[1][3][0][3][7]="1222444";
answer[1][3][1][0][1]="12223";
answer[1][3][1][0][2]="22213";
answer[1][3][1][0][3]="22123";
answer[1][3][1][0][4]="21223";
answer[1][3][1][0][5]="12223";
answer[1][3][1][1][1]="122234";
answer[1][3][1][1][2]="222314";
answer[1][3][1][1][3]="222134";
answer[1][3][1][1][4]="221234";
answer[1][3][1][1][5]="212234";
answer[1][3][1][1][6]="122234";
answer[1][3][1][2][1]="1222344";
answer[1][3][1][2][2]="2223414";
answer[1][3][1][2][3]="2231244";
answer[1][3][1][2][4]="2221344";
answer[1][3][1][2][5]="2212344";
answer[1][3][1][2][6]="2122344";
answer[1][3][1][2][7]="1222344";
answer[1][3][1][3][1]="12223444";
answer[1][3][1][3][2]="12342424";
answer[1][3][1][3][3]="22341244";
answer[1][3][1][3][4]="23122444";
answer[1][3][1][3][5]="22213444";
answer[1][3][1][3][6]="22123444";
answer[1][3][1][3][7]="21223444";
answer[1][3][1][3][8]="12223444";
answer[1][3][2][0][1]="122233";
answer[1][3][2][0][2]="222313";
answer[1][3][2][0][3]="222133";
answer[1][3][2][0][4]="221233";
answer[1][3][2][0][5]="212233";
answer[1][3][2][0][6]="122233";
answer[1][3][2][1][1]="1222334";
answer[1][3][2][1][2]="1232324";
answer[1][3][2][1][3]="2231234";
answer[1][3][2][1][4]="2221334";
answer[1][3][2][1][5]="2212334";
answer[1][3][2][1][6]="2122334";
answer[1][3][2][1][7]="1222334";
answer[1][3][2][2][1]="12223344";
answer[1][3][2][2][2]="22233414";
answer[1][3][2][2][3]="23132244";
answer[1][3][2][2][4]="23122344";
answer[1][3][2][2][5]="22213344";
answer[1][3][2][2][6]="22123344";
answer[1][3][2][2][7]="21223344";
answer[1][3][2][2][8]="12223344";
answer[1][3][2][3][1]="122233444";
answer[1][3][2][3][2]="123342424";
answer[1][3][2][3][3]="223341244";
answer[1][3][2][3][4]="313222444";
answer[1][3][2][3][5]="312223444";
answer[1][3][2][3][6]="222133444";
answer[1][3][2][3][7]="221233444";
answer[1][3][2][3][8]="212233444";
answer[1][3][2][3][9]="122233444";
answer[1][3][3][0][1]="1222333";
answer[1][3][3][0][2]="1232323";
answer[1][3][3][0][3]="2231233";
answer[1][3][3][0][4]="2221333";
answer[1][3][3][0][5]="2212333";
answer[1][3][3][0][6]="2122333";
answer[1][3][3][0][7]="1222333";
answer[1][3][3][1][1]="12223334";
answer[1][3][3][1][2]="13232324";
answer[1][3][3][1][3]="23132234";
answer[1][3][3][1][4]="23122334";
answer[1][3][3][1][5]="22213334";
answer[1][3][3][1][6]="22123334";
answer[1][3][3][1][7]="21223334";
answer[1][3][3][1][8]="12223334";
answer[1][3][3][2][1]="122233344";
answer[1][3][3][2][2]="222333414";
answer[1][3][3][2][3]="232323144";
answer[1][3][3][2][4]="313222344";
answer[1][3][3][2][5]="312223344";
answer[1][3][3][2][6]="222133344";
answer[1][3][3][2][7]="221233344";
answer[1][3][3][2][8]="212233344";
answer[1][3][3][2][9]="122233344";
answer[1][3][3][3][1]="1222333444";
answer[1][3][3][3][2]="1233342424";
answer[1][3][3][3][3]="2233341244";
answer[1][3][3][3][4]="3223231444";
answer[1][3][3][3][5]="3132223444";
answer[1][3][3][3][6]="3122233444";
answer[1][3][3][3][7]="2221333444";
answer[1][3][3][3][8]="2212333444";
answer[1][3][3][3][9]="2122333444";
answer[1][3][3][3][10]="1222333444";
answer[2][0][0][0][1]="11";
answer[2][0][0][0][2]="11";
answer[2][0][0][1][1]="114";
answer[2][0][0][1][2]="114";
answer[2][0][0][1][3]="114";
answer[2][0][0][2][1]="1144";
answer[2][0][0][2][2]="1414";
answer[2][0][0][2][3]="1144";
answer[2][0][0][2][4]="1144";
answer[2][0][0][3][1]="11444";
answer[2][0][0][3][2]="41414";
answer[2][0][0][3][3]="41144";
answer[2][0][0][3][4]="11444";
answer[2][0][0][3][5]="11444";
answer[2][0][1][0][1]="113";
answer[2][0][1][0][2]="113";
answer[2][0][1][0][3]="113";
answer[2][0][1][1][1]="1134";
answer[2][0][1][1][2]="1314";
answer[2][0][1][1][3]="1134";
answer[2][0][1][1][4]="1134";
answer[2][0][1][2][1]="11344";
answer[2][0][1][2][2]="13414";
answer[2][0][1][2][3]="31144";
answer[2][0][1][2][4]="11344";
answer[2][0][1][2][5]="11344";
answer[2][0][1][3][1]="113444";
answer[2][0][1][3][2]="341414";
answer[2][0][1][3][3]="341144";
answer[2][0][1][3][4]="311444";
answer[2][0][1][3][5]="113444";
answer[2][0][1][3][6]="113444";
answer[2][0][2][0][1]="1133";
answer[2][0][2][0][2]="1313";
answer[2][0][2][0][3]="1133";
answer[2][0][2][0][4]="1133";
answer[2][0][2][1][1]="11334";
answer[2][0][2][1][2]="31314";
answer[2][0][2][1][3]="31134";
answer[2][0][2][1][4]="11334";
answer[2][0][2][1][5]="11334";
answer[2][0][2][2][1]="113344";
answer[2][0][2][2][2]="133414";
answer[2][0][2][2][3]="313144";
answer[2][0][2][2][4]="311344";
answer[2][0][2][2][5]="113344";
answer[2][0][2][2][6]="113344";
answer[2][0][2][3][1]="1133444";
answer[2][0][2][3][2]="3341414";
answer[2][0][2][3][3]="3341144";
answer[2][0][2][3][4]="3131444";
answer[2][0][2][3][5]="3113444";
answer[2][0][2][3][6]="1133444";
answer[2][0][2][3][7]="1133444";
answer[2][0][3][0][1]="11333";
answer[2][0][3][0][2]="31313";
answer[2][0][3][0][3]="31133";
answer[2][0][3][0][4]="11333";
answer[2][0][3][0][5]="11333";
answer[2][0][3][1][1]="113334";
answer[2][0][3][1][2]="133314";
answer[2][0][3][1][3]="313134";
answer[2][0][3][1][4]="311334";
answer[2][0][3][1][5]="113334";
answer[2][0][3][1][6]="113334";
answer[2][0][3][2][1]="1133344";
answer[2][0][3][2][2]="1333414";
answer[2][0][3][2][3]="3133144";
answer[2][0][3][2][4]="3131344";
answer[2][0][3][2][5]="3113344";
answer[2][0][3][2][6]="1133344";
answer[2][0][3][2][7]="1133344";
answer[2][0][3][3][1]="11333444";
answer[2][0][3][3][2]="33341414";
answer[2][0][3][3][3]="33341144";
answer[2][0][3][3][4]="33131444";
answer[2][0][3][3][5]="31313444";
answer[2][0][3][3][6]="31133444";
answer[2][0][3][3][7]="11333444";
answer[2][0][3][3][8]="11333444";
answer[2][1][0][0][1]="112";
answer[2][1][0][0][2]="112";
answer[2][1][0][0][3]="112";
answer[2][1][0][1][1]="1124";
answer[2][1][0][1][2]="1214";
answer[2][1][0][1][3]="1124";
answer[2][1][0][1][4]="1124";
answer[2][1][0][2][1]="11244";
answer[2][1][0][2][2]="12414";
answer[2][1][0][2][3]="21144";
answer[2][1][0][2][4]="11244";
answer[2][1][0][2][5]="11244";
answer[2][1][0][3][1]="112444";
answer[2][1][0][3][2]="241414";
answer[2][1][0][3][3]="241144";
answer[2][1][0][3][4]="211444";
answer[2][1][0][3][5]="112444";
answer[2][1][0][3][6]="112444";
answer[2][1][1][0][1]="1123";
answer[2][1][1][0][2]="1213";
answer[2][1][1][0][3]="1123";
answer[2][1][1][0][4]="1123";
answer[2][1][1][1][1]="11234";
answer[2][1][1][1][2]="12314";
answer[2][1][1][1][3]="21134";
answer[2][1][1][1][4]="11234";
answer[2][1][1][1][5]="11234";
answer[2][1][1][2][1]="112344";
answer[2][1][1][2][2]="123414";
answer[2][1][1][2][3]="231144";
answer[2][1][1][2][4]="211344";
answer[2][1][1][2][5]="112344";
answer[2][1][1][2][6]="112344";
answer[2][1][1][3][1]="1123444";
answer[2][1][1][3][2]="2341414";
answer[2][1][1][3][3]="2341144";
answer[2][1][1][3][4]="3112444";
answer[2][1][1][3][5]="2113444";
answer[2][1][1][3][6]="1123444";
answer[2][1][1][3][7]="1123444";
answer[2][1][2][0][1]="11233";
answer[2][1][2][0][2]="12313";
answer[2][1][2][0][3]="21133";
answer[2][1][2][0][4]="11233";
answer[2][1][2][0][5]="11233";
answer[2][1][2][1][1]="112334";
answer[2][1][2][1][2]="231314";
answer[2][1][2][1][3]="231134";
answer[2][1][2][1][4]="211334";
answer[2][1][2][1][5]="112334";
answer[2][1][2][1][6]="112334";
answer[2][1][2][2][1]="1123344";
answer[2][1][2][2][2]="1233414";
answer[2][1][2][2][3]="3131244";
answer[2][1][2][2][4]="3112344";
answer[2][1][2][2][5]="2113344";
answer[2][1][2][2][6]="1123344";
answer[2][1][2][2][7]="1123344";
answer[2][1][2][3][1]="11233444";
answer[2][1][2][3][2]="23341414";
answer[2][1][2][3][3]="23341144";
answer[2][1][2][3][4]="31312444";
answer[2][1][2][3][5]="31123444";
answer[2][1][2][3][6]="21133444";
answer[2][1][2][3][7]="11233444";
answer[2][1][2][3][8]="11233444";
answer[2][1][3][0][1]="112333";
answer[2][1][3][0][2]="231313";
answer[2][1][3][0][3]="231133";
answer[2][1][3][0][4]="211333";
answer[2][1][3][0][5]="112333";
answer[2][1][3][0][6]="112333";
answer[2][1][3][1][1]="1123334";
answer[2][1][3][1][2]="3131324";
answer[2][1][3][1][3]="2313134";
answer[2][1][3][1][4]="3112334";
answer[2][1][3][1][5]="2113334";
answer[2][1][3][1][6]="1123334";
answer[2][1][3][1][7]="1123334";
answer[2][1][3][2][1]="11233344";
answer[2][1][3][2][2]="12333414";
answer[2][1][3][2][3]="31323144";
answer[2][1][3][2][4]="31312344";
answer[2][1][3][2][5]="31123344";
answer[2][1][3][2][6]="21133344";
answer[2][1][3][2][7]="11233344";
answer[2][1][3][2][8]="11233344";
answer[2][1][3][3][1]="112333444";
answer[2][1][3][3][2]="233341414";
answer[2][1][3][3][3]="233341144";
answer[2][1][3][3][4]="313231444";
answer[2][1][3][3][5]="313123444";
answer[2][1][3][3][6]="311233444";
answer[2][1][3][3][7]="211333444";
answer[2][1][3][3][8]="112333444";
answer[2][1][3][3][9]="112333444";
answer[2][2][0][0][1]="1122";
answer[2][2][0][0][2]="1212";
answer[2][2][0][0][3]="1122";
answer[2][2][0][0][4]="1122";
answer[2][2][0][1][1]="11224";
answer[2][2][0][1][2]="21214";
answer[2][2][0][1][3]="21124";
answer[2][2][0][1][4]="11224";
answer[2][2][0][1][5]="11224";
answer[2][2][0][2][1]="112244";
answer[2][2][0][2][2]="122414";
answer[2][2][0][2][3]="212144";
answer[2][2][0][2][4]="211244";
answer[2][2][0][2][5]="112244";
answer[2][2][0][2][6]="112244";
answer[2][2][0][3][1]="1122444";
answer[2][2][0][3][2]="2241414";
answer[2][2][0][3][3]="2241144";
answer[2][2][0][3][4]="2121444";
answer[2][2][0][3][5]="2112444";
answer[2][2][0][3][6]="1122444";
answer[2][2][0][3][7]="1122444";
answer[2][2][1][0][1]="11223";
answer[2][2][1][0][2]="21213";
answer[2][2][1][0][3]="21123";
answer[2][2][1][0][4]="11223";
answer[2][2][1][0][5]="11223";
answer[2][2][1][1][1]="112234";
answer[2][2][1][1][2]="122314";
answer[2][2][1][1][3]="212134";
answer[2][2][1][1][4]="211234";
answer[2][2][1][1][5]="112234";
answer[2][2][1][1][6]="112234";
answer[2][2][1][2][1]="1122344";
answer[2][2][1][2][2]="1223414";
answer[2][2][1][2][3]="2231144";
answer[2][2][1][2][4]="2121344";
answer[2][2][1][2][5]="2112344";
answer[2][2][1][2][6]="1122344";
answer[2][2][1][2][7]="1122344";
answer[2][2][1][3][1]="11223444";
answer[2][2][1][3][2]="22341414";
answer[2][2][1][3][3]="22341144";
answer[2][2][1][3][4]="23112444";
answer[2][2][1][3][5]="21213444";
answer[2][2][1][3][6]="21123444";
answer[2][2][1][3][7]="11223444";
answer[2][2][1][3][8]="11223444";
answer[2][2][2][0][1]="112233";
answer[2][2][2][0][2]="122313";
answer[2][2][2][0][3]="212133";
answer[2][2][2][0][4]="211233";
answer[2][2][2][0][5]="112233";
answer[2][2][2][0][6]="112233";
answer[2][2][2][1][1]="1122334";
answer[2][2][2][1][2]="2231314";
answer[2][2][2][1][3]="2231134";
answer[2][2][2][1][4]="2121334";
answer[2][2][2][1][5]="2112334";
answer[2][2][2][1][6]="1122334";
answer[2][2][2][1][7]="1122334";
answer[2][2][2][2][1]="11223344";
answer[2][2][2][2][2]="12233414";
answer[2][2][2][2][3]="31231244";
answer[2][2][2][2][4]="23112344";
answer[2][2][2][2][5]="21213344";
answer[2][2][2][2][6]="21123344";
answer[2][2][2][2][7]="11223344";
answer[2][2][2][2][8]="11223344";
answer[2][2][2][3][1]="112233444";
answer[2][2][2][3][2]="223341414";
answer[2][2][2][3][3]="223341144";
answer[2][2][2][3][4]="312312444";
answer[2][2][2][3][5]="311223444";
answer[2][2][2][3][6]="212133444";
answer[2][2][2][3][7]="211233444";
answer[2][2][2][3][8]="112233444";
answer[2][2][2][3][9]="112233444";
answer[2][2][3][0][1]="1122333";
answer[2][2][3][0][2]="2231313";
answer[2][2][3][0][3]="2231133";
answer[2][2][3][0][4]="2121333";
answer[2][2][3][0][5]="2112333";
answer[2][2][3][0][6]="1122333";
answer[2][2][3][0][7]="1122333";
answer[2][2][3][1][1]="11223334";
answer[2][2][3][1][2]="13132324";
answer[2][2][3][1][3]="31231234";
answer[2][2][3][1][4]="23112334";
answer[2][2][3][1][5]="21213334";
answer[2][2][3][1][6]="21123334";
answer[2][2][3][1][7]="11223334";
answer[2][2][3][1][8]="11223334";
answer[2][2][3][2][1]="112233344";
answer[2][2][3][2][2]="122333414";
answer[2][2][3][2][3]="313132244";
answer[2][2][3][2][4]="312312344";
answer[2][2][3][2][5]="311223344";
answer[2][2][3][2][6]="212133344";
answer[2][2][3][2][7]="211233344";
answer[2][2][3][2][8]="112233344";
answer[2][2][3][2][9]="112233344";
answer[2][2][3][3][1]="1122333444";
answer[2][2][3][3][2]="2233341414";
answer[2][2][3][3][3]="2233341144";
answer[2][2][3][3][4]="3132231444";
answer[2][2][3][3][5]="3123123444";
answer[2][2][3][3][6]="3112233444";
answer[2][2][3][3][7]="2121333444";
answer[2][2][3][3][8]="2112333444";
answer[2][2][3][3][9]="1122333444";
answer[2][2][3][3][10]="1122333444";
answer[2][3][0][0][1]="11222";
answer[2][3][0][0][2]="21212";
answer[2][3][0][0][3]="21122";
answer[2][3][0][0][4]="11222";
answer[2][3][0][0][5]="11222";
answer[2][3][0][1][1]="112224";
answer[2][3][0][1][2]="122214";
answer[2][3][0][1][3]="212124";
answer[2][3][0][1][4]="211224";
answer[2][3][0][1][5]="112224";
answer[2][3][0][1][6]="112224";
answer[2][3][0][2][1]="1122244";
answer[2][3][0][2][2]="1222414";
answer[2][3][0][2][3]="2122144";
answer[2][3][0][2][4]="2121244";
answer[2][3][0][2][5]="2112244";
answer[2][3][0][2][6]="1122244";
answer[2][3][0][2][7]="1122244";
answer[2][3][0][3][1]="11222444";
answer[2][3][0][3][2]="22241414";
answer[2][3][0][3][3]="22241144";
answer[2][3][0][3][4]="22121444";
answer[2][3][0][3][5]="21212444";
answer[2][3][0][3][6]="21122444";
answer[2][3][0][3][7]="11222444";
answer[2][3][0][3][8]="11222444";
answer[2][3][1][0][1]="112223";
answer[2][3][1][0][2]="122213";
answer[2][3][1][0][3]="212123";
answer[2][3][1][0][4]="211223";
answer[2][3][1][0][5]="112223";
answer[2][3][1][0][6]="112223";
answer[2][3][1][1][1]="1122234";
answer[2][3][1][1][2]="1222314";
answer[2][3][1][1][3]="2122134";
answer[2][3][1][1][4]="2121234";
answer[2][3][1][1][5]="2112234";
answer[2][3][1][1][6]="1122234";
answer[2][3][1][1][7]="1122234";
answer[2][3][1][2][1]="11222344";
answer[2][3][1][2][2]="12223414";
answer[2][3][1][2][3]="22231144";
answer[2][3][1][2][4]="22121344";
answer[2][3][1][2][5]="21212344";
answer[2][3][1][2][6]="21122344";
answer[2][3][1][2][7]="11222344";
answer[2][3][1][2][8]="11222344";
answer[2][3][1][3][1]="112223444";
answer[2][3][1][3][2]="222341414";
answer[2][3][1][3][3]="222341144";
answer[2][3][1][3][4]="223112444";
answer[2][3][1][3][5]="221213444";
answer[2][3][1][3][6]="212123444";
answer[2][3][1][3][7]="211223444";
answer[2][3][1][3][8]="112223444";
answer[2][3][1][3][9]="112223444";
answer[2][3][2][0][1]="1122233";
answer[2][3][2][0][2]="1222313";
answer[2][3][2][0][3]="2122133";
answer[2][3][2][0][4]="2121233";
answer[2][3][2][0][5]="2112233";
answer[2][3][2][0][6]="1122233";
answer[2][3][2][0][7]="1122233";
answer[2][3][2][1][1]="11222334";
answer[2][3][2][1][2]="22231314";
answer[2][3][2][1][3]="22231134";
answer[2][3][2][1][4]="22121334";
answer[2][3][2][1][5]="21212334";
answer[2][3][2][1][6]="21122334";
answer[2][3][2][1][7]="11222334";
answer[2][3][2][1][8]="11222334";
answer[2][3][2][2][1]="112223344";
answer[2][3][2][2][2]="122233414";
answer[2][3][2][2][3]="231231244";
answer[2][3][2][2][4]="223112344";
answer[2][3][2][2][5]="221213344";
answer[2][3][2][2][6]="212123344";
answer[2][3][2][2][7]="211223344";
answer[2][3][2][2][8]="112223344";
answer[2][3][2][2][9]="112223344";
answer[2][3][2][3][1]="1122233444";
answer[2][3][2][3][2]="2223341414";
answer[2][3][2][3][3]="2223341144";
answer[2][3][2][3][4]="3123122444";
answer[2][3][2][3][5]="2311223444";
answer[2][3][2][3][6]="2212133444";
answer[2][3][2][3][7]="2121233444";
answer[2][3][2][3][8]="2112233444";
answer[2][3][2][3][9]="1122233444";
answer[2][3][2][3][10]="1122233444";
answer[2][3][3][0][1]="11222333";
answer[2][3][3][0][2]="22231313";
answer[2][3][3][0][3]="22231133";
answer[2][3][3][0][4]="22121333";
answer[2][3][3][0][5]="21212333";
answer[2][3][3][0][6]="21122333";
answer[2][3][3][0][7]="11222333";
answer[2][3][3][0][8]="11222333";
answer[2][3][3][1][1]="112223334";
answer[2][3][3][1][2]="113232324";
answer[2][3][3][1][3]="231231234";
answer[2][3][3][1][4]="223112334";
answer[2][3][3][1][5]="221213334";
answer[2][3][3][1][6]="212123334";
answer[2][3][3][1][7]="211223334";
answer[2][3][3][1][8]="112223334";
answer[2][3][3][1][9]="112223334";
answer[2][3][3][2][1]="1122233344";
answer[2][3][3][2][2]="1222333414";
answer[2][3][3][2][3]="2313132244";
answer[2][3][3][2][4]="2312312344";
answer[2][3][3][2][5]="2311223344";
answer[2][3][3][2][6]="2212133344";
answer[2][3][3][2][7]="2121233344";
answer[2][3][3][2][8]="2112233344";
answer[2][3][3][2][9]="1122233344";
answer[2][3][3][2][10]="1122233344";
answer[2][3][3][3][1]="11222333444";
answer[2][3][3][3][2]="22233341414";
answer[2][3][3][3][3]="22233341144";
answer[2][3][3][3][4]="31313222444";
answer[2][3][3][3][5]="31231223444";
answer[2][3][3][3][6]="31122233444";
answer[2][3][3][3][7]="22121333444";
answer[2][3][3][3][8]="21212333444";
answer[2][3][3][3][9]="21122333444";
answer[2][3][3][3][10]="11222333444";
answer[2][3][3][3][11]="11222333444";
answer[3][0][0][0][1]="111";
answer[3][0][0][0][2]="111";
answer[3][0][0][0][3]="111";
answer[3][0][0][1][1]="1114";
answer[3][0][0][1][2]="1114";
answer[3][0][0][1][3]="1114";
answer[3][0][0][1][4]="1114";
answer[3][0][0][2][1]="11144";
answer[3][0][0][2][2]="11414";
answer[3][0][0][2][3]="11144";
answer[3][0][0][2][4]="11144";
answer[3][0][0][2][5]="11144";
answer[3][0][0][3][1]="111444";
answer[3][0][0][3][2]="141414";
answer[3][0][0][3][3]="141144";
answer[3][0][0][3][4]="111444";
answer[3][0][0][3][5]="111444";
answer[3][0][0][3][6]="111444";
answer[3][0][1][0][1]="1113";
answer[3][0][1][0][2]="1113";
answer[3][0][1][0][3]="1113";
answer[3][0][1][0][4]="1113";
answer[3][0][1][1][1]="11134";
answer[3][0][1][1][2]="11314";
answer[3][0][1][1][3]="11134";
answer[3][0][1][1][4]="11134";
answer[3][0][1][1][5]="11134";
answer[3][0][1][2][1]="111344";
answer[3][0][1][2][2]="113414";
answer[3][0][1][2][3]="131144";
answer[3][0][1][2][4]="111344";
answer[3][0][1][2][5]="111344";
answer[3][0][1][2][6]="111344";
answer[3][0][1][3][1]="1113444";
answer[3][0][1][3][2]="1341414";
answer[3][0][1][3][3]="1341144";
answer[3][0][1][3][4]="3111444";
answer[3][0][1][3][5]="1113444";
answer[3][0][1][3][6]="1113444";
answer[3][0][1][3][7]="1113444";
answer[3][0][2][0][1]="11133";
answer[3][0][2][0][2]="11313";
answer[3][0][2][0][3]="11133";
answer[3][0][2][0][4]="11133";
answer[3][0][2][0][5]="11133";
answer[3][0][2][1][1]="111334";
answer[3][0][2][1][2]="131314";
answer[3][0][2][1][3]="131134";
answer[3][0][2][1][4]="111334";
answer[3][0][2][1][5]="111334";
answer[3][0][2][1][6]="111334";
answer[3][0][2][2][1]="1113344";
answer[3][0][2][2][2]="1133414";
answer[3][0][2][2][3]="3131144";
answer[3][0][2][2][4]="3111344";
answer[3][0][2][2][5]="1113344";
answer[3][0][2][2][6]="1113344";
answer[3][0][2][2][7]="1113344";
answer[3][0][2][3][1]="11133444";
answer[3][0][2][3][2]="13341414";
answer[3][0][2][3][3]="13341144";
answer[3][0][2][3][4]="31311444";
answer[3][0][2][3][5]="31113444";
answer[3][0][2][3][6]="11133444";
answer[3][0][2][3][7]="11133444";
answer[3][0][2][3][8]="11133444";
answer[3][0][3][0][1]="111333";
answer[3][0][3][0][2]="131313";
answer[3][0][3][0][3]="131133";
answer[3][0][3][0][4]="111333";
answer[3][0][3][0][5]="111333";
answer[3][0][3][0][6]="111333";
answer[3][0][3][1][1]="1113334";
answer[3][0][3][1][2]="3131314";
answer[3][0][3][1][3]="1313134";
answer[3][0][3][1][4]="3111334";
answer[3][0][3][1][5]="1113334";
answer[3][0][3][1][6]="1113334";
answer[3][0][3][1][7]="1113334";
answer[3][0][3][2][1]="11133344";
answer[3][0][3][2][2]="11333414";
answer[3][0][3][2][3]="31313144";
answer[3][0][3][2][4]="31311344";
answer[3][0][3][2][5]="31113344";
answer[3][0][3][2][6]="11133344";
answer[3][0][3][2][7]="11133344";
answer[3][0][3][2][8]="11133344";
answer[3][0][3][3][1]="111333444";
answer[3][0][3][3][2]="133341414";
answer[3][0][3][3][3]="133341144";
answer[3][0][3][3][4]="313131444";
answer[3][0][3][3][5]="313113444";
answer[3][0][3][3][6]="311133444";
answer[3][0][3][3][7]="111333444";
answer[3][0][3][3][8]="111333444";
answer[3][0][3][3][9]="111333444";
answer[3][1][0][0][1]="1112";
answer[3][1][0][0][2]="1112";
answer[3][1][0][0][3]="1112";
answer[3][1][0][0][4]="1112";
answer[3][1][0][1][1]="11124";
answer[3][1][0][1][2]="11214";
answer[3][1][0][1][3]="11124";
answer[3][1][0][1][4]="11124";
answer[3][1][0][1][5]="11124";
answer[3][1][0][2][1]="111244";
answer[3][1][0][2][2]="112414";
answer[3][1][0][2][3]="121144";
answer[3][1][0][2][4]="111244";
answer[3][1][0][2][5]="111244";
answer[3][1][0][2][6]="111244";
answer[3][1][0][3][1]="1112444";
answer[3][1][0][3][2]="1241414";
answer[3][1][0][3][3]="1241144";
answer[3][1][0][3][4]="2111444";
answer[3][1][0][3][5]="1112444";
answer[3][1][0][3][6]="1112444";
answer[3][1][0][3][7]="1112444";
answer[3][1][1][0][1]="11123";
answer[3][1][1][0][2]="11213";
answer[3][1][1][0][3]="11123";
answer[3][1][1][0][4]="11123";
answer[3][1][1][0][5]="11123";
answer[3][1][1][1][1]="111234";
answer[3][1][1][1][2]="112314";
answer[3][1][1][1][3]="121134";
answer[3][1][1][1][4]="111234";
answer[3][1][1][1][5]="111234";
answer[3][1][1][1][6]="111234";
answer[3][1][1][2][1]="1112344";
answer[3][1][1][2][2]="1123414";
answer[3][1][1][2][3]="1231144";
answer[3][1][1][2][4]="2111344";
answer[3][1][1][2][5]="1112344";
answer[3][1][1][2][6]="1112344";
answer[3][1][1][2][7]="1112344";
answer[3][1][1][3][1]="11123444";
answer[3][1][1][3][2]="12341414";
answer[3][1][1][3][3]="12341144";
answer[3][1][1][3][4]="23111444";
answer[3][1][1][3][5]="21113444";
answer[3][1][1][3][6]="11123444";
answer[3][1][1][3][7]="11123444";
answer[3][1][1][3][8]="11123444";
answer[3][1][2][0][1]="111233";
answer[3][1][2][0][2]="112313";
answer[3][1][2][0][3]="121133";
answer[3][1][2][0][4]="111233";
answer[3][1][2][0][5]="111233";
answer[3][1][2][0][6]="111233";
answer[3][1][2][1][1]="1112334";
answer[3][1][2][1][2]="1231314";
answer[3][1][2][1][3]="1231134";
answer[3][1][2][1][4]="2111334";
answer[3][1][2][1][5]="1112334";
answer[3][1][2][1][6]="1112334";
answer[3][1][2][1][7]="1112334";
answer[3][1][2][2][1]="11123344";
answer[3][1][2][2][2]="11233414";
answer[3][1][2][2][3]="31131244";
answer[3][1][2][2][4]="23111344";
answer[3][1][2][2][5]="21113344";
answer[3][1][2][2][6]="11123344";
answer[3][1][2][2][7]="11123344";
answer[3][1][2][2][8]="11123344";
answer[3][1][2][3][1]="111233444";
answer[3][1][2][3][2]="123341414";
answer[3][1][2][3][3]="123341144";
answer[3][1][2][3][4]="312311444";
answer[3][1][2][3][5]="311123444";
answer[3][1][2][3][6]="211133444";
answer[3][1][2][3][7]="111233444";
answer[3][1][2][3][8]="111233444";
answer[3][1][2][3][9]="111233444";
answer[3][1][3][0][1]="1112333";
answer[3][1][3][0][2]="1231313";
answer[3][1][3][0][3]="1231133";
answer[3][1][3][0][4]="2111333";
answer[3][1][3][0][5]="1112333";
answer[3][1][3][0][6]="1112333";
answer[3][1][3][0][7]="1112333";
answer[3][1][3][1][1]="11123334";
answer[3][1][3][1][2]="23131314";
answer[3][1][3][1][3]="31131234";
answer[3][1][3][1][4]="23111334";
answer[3][1][3][1][5]="21113334";
answer[3][1][3][1][6]="11123334";
answer[3][1][3][1][7]="11123334";
answer[3][1][3][1][8]="11123334";
answer[3][1][3][2][1]="111233344";
answer[3][1][3][2][2]="112333414";
answer[3][1][3][2][3]="313131244";
answer[3][1][3][2][4]="311312344";
answer[3][1][3][2][5]="311123344";
answer[3][1][3][2][6]="211133344";
answer[3][1][3][2][7]="111233344";
answer[3][1][3][2][8]="111233344";
answer[3][1][3][2][9]="111233344";
answer[3][1][3][3][1]="1112333444";
answer[3][1][3][3][2]="1233341414";
answer[3][1][3][3][3]="1233341144";
answer[3][1][3][3][4]="3131312444";
answer[3][1][3][3][5]="3123113444";
answer[3][1][3][3][6]="3111233444";
answer[3][1][3][3][7]="2111333444";
answer[3][1][3][3][8]="1112333444";
answer[3][1][3][3][9]="1112333444";
answer[3][1][3][3][10]="1112333444";
answer[3][2][0][0][1]="11122";
answer[3][2][0][0][2]="11212";
answer[3][2][0][0][3]="11122";
answer[3][2][0][0][4]="11122";
answer[3][2][0][0][5]="11122";
answer[3][2][0][1][1]="111224";
answer[3][2][0][1][2]="121214";
answer[3][2][0][1][3]="121124";
answer[3][2][0][1][4]="111224";
answer[3][2][0][1][5]="111224";
answer[3][2][0][1][6]="111224";
answer[3][2][0][2][1]="1112244";
answer[3][2][0][2][2]="1122414";
answer[3][2][0][2][3]="2121144";
answer[3][2][0][2][4]="2111244";
answer[3][2][0][2][5]="1112244";
answer[3][2][0][2][6]="1112244";
answer[3][2][0][2][7]="1112244";
answer[3][2][0][3][1]="11122444";
answer[3][2][0][3][2]="12241414";
answer[3][2][0][3][3]="12241144";
answer[3][2][0][3][4]="21211444";
answer[3][2][0][3][5]="21112444";
answer[3][2][0][3][6]="11122444";
answer[3][2][0][3][7]="11122444";
answer[3][2][0][3][8]="11122444";
answer[3][2][1][0][1]="111223";
answer[3][2][1][0][2]="121213";
answer[3][2][1][0][3]="121123";
answer[3][2][1][0][4]="111223";
answer[3][2][1][0][5]="111223";
answer[3][2][1][0][6]="111223";
answer[3][2][1][1][1]="1112234";
answer[3][2][1][1][2]="1122314";
answer[3][2][1][1][3]="2121134";
answer[3][2][1][1][4]="2111234";
answer[3][2][1][1][5]="1112234";
answer[3][2][1][1][6]="1112234";
answer[3][2][1][1][7]="1112234";
answer[3][2][1][2][1]="11122344";
answer[3][2][1][2][2]="11223414";
answer[3][2][1][2][3]="12231144";
answer[3][2][1][2][4]="21211344";
answer[3][2][1][2][5]="21112344";
answer[3][2][1][2][6]="11122344";
answer[3][2][1][2][7]="11122344";
answer[3][2][1][2][8]="11122344";
answer[3][2][1][3][1]="111223444";
answer[3][2][1][3][2]="122341414";
answer[3][2][1][3][3]="122341144";
answer[3][2][1][3][4]="223111444";
answer[3][2][1][3][5]="212113444";
answer[3][2][1][3][6]="211123444";
answer[3][2][1][3][7]="111223444";
answer[3][2][1][3][8]="111223444";
answer[3][2][1][3][9]="111223444";
answer[3][2][2][0][1]="1112233";
answer[3][2][2][0][2]="1122313";
answer[3][2][2][0][3]="2121133";
answer[3][2][2][0][4]="2111233";
answer[3][2][2][0][5]="1112233";
answer[3][2][2][0][6]="1112233";
answer[3][2][2][0][7]="1112233";
answer[3][2][2][1][1]="11122334";
answer[3][2][2][1][2]="12231314";
answer[3][2][2][1][3]="12231134";
answer[3][2][2][1][4]="21211334";
answer[3][2][2][1][5]="21112334";
answer[3][2][2][1][6]="11122334";
answer[3][2][2][1][7]="11122334";
answer[3][2][2][1][8]="11122334";
answer[3][2][2][2][1]="111223344";
answer[3][2][2][2][2]="112233414";
answer[3][2][2][2][3]="131231244";
answer[3][2][2][2][4]="223111344";
answer[3][2][2][2][5]="212113344";
answer[3][2][2][2][6]="211123344";
answer[3][2][2][2][7]="111223344";
answer[3][2][2][2][8]="111223344";
answer[3][2][2][2][9]="111223344";
answer[3][2][2][3][1]="1112233444";
answer[3][2][2][3][2]="1223341414";
answer[3][2][2][3][3]="1223341144";
answer[3][2][2][3][4]="3113122444";
answer[3][2][2][3][5]="2311123444";
answer[3][2][2][3][6]="2121133444";
answer[3][2][2][3][7]="2111233444";
answer[3][2][2][3][8]="1112233444";
answer[3][2][2][3][9]="1112233444";
answer[3][2][2][3][10]="1112233444";
answer[3][2][3][0][1]="11122333";
answer[3][2][3][0][2]="12231313";
answer[3][2][3][0][3]="12231133";
answer[3][2][3][0][4]="21211333";
answer[3][2][3][0][5]="21112333";
answer[3][2][3][0][6]="11122333";
answer[3][2][3][0][7]="11122333";
answer[3][2][3][0][8]="11122333";
answer[3][2][3][1][1]="111223334";
answer[3][2][3][1][2]="223131314";
answer[3][2][3][1][3]="131231234";
answer[3][2][3][1][4]="223111334";
answer[3][2][3][1][5]="212113334";
answer[3][2][3][1][6]="211123334";
answer[3][2][3][1][7]="111223334";
answer[3][2][3][1][8]="111223334";
answer[3][2][3][1][9]="111223334";
answer[3][2][3][2][1]="1112233344";
answer[3][2][3][2][2]="1122333414";
answer[3][2][3][2][3]="2313131244";
answer[3][2][3][2][4]="3113122344";
answer[3][2][3][2][5]="2311123344";
answer[3][2][3][2][6]="2121133344";
answer[3][2][3][2][7]="2111233344";
answer[3][2][3][2][8]="1112233344";
answer[3][2][3][2][9]="1112233344";
answer[3][2][3][2][10]="1112233344";
answer[3][2][3][3][1]="11122333444";
answer[3][2][3][3][2]="12233341414";
answer[3][2][3][3][3]="12233341144";
answer[3][2][3][3][4]="23131312444";
answer[3][2][3][3][5]="31131223444";
answer[3][2][3][3][6]="31112233444";
answer[3][2][3][3][7]="21211333444";
answer[3][2][3][3][8]="21112333444";
answer[3][2][3][3][9]="11122333444";
answer[3][2][3][3][10]="11122333444";
answer[3][2][3][3][11]="11122333444";
answer[3][3][0][0][1]="111222";
answer[3][3][0][0][2]="121212";
answer[3][3][0][0][3]="121122";
answer[3][3][0][0][4]="111222";
answer[3][3][0][0][5]="111222";
answer[3][3][0][0][6]="111222";
answer[3][3][0][1][1]="1112224";
answer[3][3][0][1][2]="2121214";
answer[3][3][0][1][3]="1212124";
answer[3][3][0][1][4]="2111224";
answer[3][3][0][1][5]="1112224";
answer[3][3][0][1][6]="1112224";
answer[3][3][0][1][7]="1112224";
answer[3][3][0][2][1]="11122244";
answer[3][3][0][2][2]="11222414";
answer[3][3][0][2][3]="21212144";
answer[3][3][0][2][4]="21211244";
answer[3][3][0][2][5]="21112244";
answer[3][3][0][2][6]="11122244";
answer[3][3][0][2][7]="11122244";
answer[3][3][0][2][8]="11122244";
answer[3][3][0][3][1]="111222444";
answer[3][3][0][3][2]="122241414";
answer[3][3][0][3][3]="122241144";
answer[3][3][0][3][4]="212121444";
answer[3][3][0][3][5]="212112444";
answer[3][3][0][3][6]="211122444";
answer[3][3][0][3][7]="111222444";
answer[3][3][0][3][8]="111222444";
answer[3][3][0][3][9]="111222444";
answer[3][3][1][0][1]="1112223";
answer[3][3][1][0][2]="2121213";
answer[3][3][1][0][3]="1212123";
answer[3][3][1][0][4]="2111223";
answer[3][3][1][0][5]="1112223";
answer[3][3][1][0][6]="1112223";
answer[3][3][1][0][7]="1112223";
answer[3][3][1][1][1]="11122234";
answer[3][3][1][1][2]="11222314";
answer[3][3][1][1][3]="21212134";
answer[3][3][1][1][4]="21211234";
answer[3][3][1][1][5]="21112234";
answer[3][3][1][1][6]="11122234";
answer[3][3][1][1][7]="11122234";
answer[3][3][1][1][8]="11122234";
answer[3][3][1][2][1]="111222344";
answer[3][3][1][2][2]="112223414";
answer[3][3][1][2][3]="122231144";
answer[3][3][1][2][4]="212121344";
answer[3][3][1][2][5]="212112344";
answer[3][3][1][2][6]="211122344";
answer[3][3][1][2][7]="111222344";
answer[3][3][1][2][8]="111222344";
answer[3][3][1][2][9]="111222344";
answer[3][3][1][3][1]="1112223444";
answer[3][3][1][3][2]="1222341414";
answer[3][3][1][3][3]="1222341144";
answer[3][3][1][3][4]="2223111444";
answer[3][3][1][3][5]="2121213444";
answer[3][3][1][3][6]="2121123444";
answer[3][3][1][3][7]="2111223444";
answer[3][3][1][3][8]="1112223444";
answer[3][3][1][3][9]="1112223444";
answer[3][3][1][3][10]="1112223444";
answer[3][3][2][0][1]="11122233";
answer[3][3][2][0][2]="11222313";
answer[3][3][2][0][3]="21212133";
answer[3][3][2][0][4]="21211233";
answer[3][3][2][0][5]="21112233";
answer[3][3][2][0][6]="11122233";
answer[3][3][2][0][7]="11122233";
answer[3][3][2][0][8]="11122233";
answer[3][3][2][1][1]="111222334";
answer[3][3][2][1][2]="122231314";
answer[3][3][2][1][3]="122231134";
answer[3][3][2][1][4]="212121334";
answer[3][3][2][1][5]="212112334";
answer[3][3][2][1][6]="211122334";
answer[3][3][2][1][7]="111222334";
answer[3][3][2][1][8]="111222334";
answer[3][3][2][1][9]="111222334";
answer[3][3][2][2][1]="1112223344";
answer[3][3][2][2][2]="1122233414";
answer[3][3][2][2][3]="1231231244";
answer[3][3][2][2][4]="2223111344";
answer[3][3][2][2][5]="2121213344";
answer[3][3][2][2][6]="2121123344";
answer[3][3][2][2][7]="2111223344";
answer[3][3][2][2][8]="1112223344";
answer[3][3][2][2][9]="1112223344";
answer[3][3][2][2][10]="1112223344";
answer[3][3][2][3][1]="11122233444";
answer[3][3][2][3][2]="12223341414";
answer[3][3][2][3][3]="12223341144";
answer[3][3][2][3][4]="23113122444";
answer[3][3][2][3][5]="22311123444";
answer[3][3][2][3][6]="21212133444";
answer[3][3][2][3][7]="21211233444";
answer[3][3][2][3][8]="21112233444";
answer[3][3][2][3][9]="11122233444";
answer[3][3][2][3][10]="11122233444";
answer[3][3][2][3][11]="11122233444";
answer[3][3][3][0][1]="111222333";
answer[3][3][3][0][2]="122231313";
answer[3][3][3][0][3]="122231133";
answer[3][3][3][0][4]="212121333";
answer[3][3][3][0][5]="212112333";
answer[3][3][3][0][6]="211122333";
answer[3][3][3][0][7]="111222333";
answer[3][3][3][0][8]="111222333";
answer[3][3][3][0][9]="111222333";
answer[3][3][3][1][1]="1112223334";
answer[3][3][3][1][2]="2223131314";
answer[3][3][3][1][3]="1231231234";
answer[3][3][3][1][4]="2223111334";
answer[3][3][3][1][5]="2121213334";
answer[3][3][3][1][6]="2121123334";
answer[3][3][3][1][7]="2111223334";
answer[3][3][3][1][8]="1112223334";
answer[3][3][3][1][9]="1112223334";
answer[3][3][3][1][10]="1112223334";
answer[3][3][3][2][1]="11122233344";
answer[3][3][3][2][2]="11222333414";
answer[3][3][3][2][3]="31231231244";
answer[3][3][3][2][4]="23113122344";
answer[3][3][3][2][5]="22311123344";
answer[3][3][3][2][6]="21212133344";
answer[3][3][3][2][7]="21211233344";
answer[3][3][3][2][8]="21112233344";
answer[3][3][3][2][9]="11122233344";
answer[3][3][3][2][10]="11122233344";
answer[3][3][3][2][11]="11122233344";
answer[3][3][3][3][1]="111222333444";
answer[3][3][3][3][2]="122233341414";
answer[3][3][3][3][3]="122233341144";
answer[3][3][3][3][4]="312312312444";
answer[3][3][3][3][5]="311312223444";
answer[3][3][3][3][6]="231112233444";
answer[3][3][3][3][7]="212121333444";
answer[3][3][3][3][8]="212112333444";
answer[3][3][3][3][9]="211122333444";
answer[3][3][3][3][10]="111222333444";
answer[3][3][3][3][11]="111222333444";
answer[3][3][3][3][12]="111222333444";
}
int t;
cin>>t;
while(t--){
vec<int> cnt(10,0);
int ok=1,sum=0;
int k;
cin>>k;
for(int i=1;i<10;i++)
cin>>cnt[i-1],ok&=(i>=4?cnt[i-1]==0:1),sum+=cnt[i-1];
if(!ok){
assert(false);
continue;
}
string ans=answer[cnt[0]][cnt[1]][cnt[2]][cnt[3]][k];
// assert(sz(to_string(ans))==sum);
cout<<ans<<'\n';
}
return 0;
}
/*
1
6
3 3 3 3 0 0 0 0 0 0
*/
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |