#pragma GCC optimize(2)

#include<cstdio>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<algorithm>
#include<vector>
#include<iostream>
#include<queue>
#include<functional>
#include<bitset>

#define lowbit(x) ((x)&(-x))
#define Finline __inline__ __attribute__ ((always_inline))

using std::cin;
using std::cout;
using std::vector;
using std::string;
using std::queue;
using std::bitset;
using std::sort;
using std::unique;
using std::endl;
using std::cerr;
using std::priority_queue;
using std::random_shuffle;

typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;

const int inf=0x3f3f3f3f,Inf=0x7fffffff;
const ll INF=0x7fffffffffffffff;
const double eps=1e-8;

uint seed=19260817;
const uint _RAND_MAX_=4294967295u;
Finline uint Rand(){return seed=seed*998244353u+1000000007u;}

template <typename _Tp>_Tp gcd(const _Tp &a,const _Tp &b){return (!b)?a:gcd(b,a%b);}
template <typename _Tp>Finline _Tp abs(const _Tp &a){return a>0?a:-a;}
template <typename _Tp>Finline _Tp max(const _Tp &a,const _Tp &b){return a<b?b:a;}
template <typename _Tp>Finline _Tp min(const _Tp &a,const _Tp &b){return a<b?a:b;}
template <typename _Tp>Finline void chmax(_Tp &a,const _Tp &b){(a<b)&&(a=b);}
template <typename _Tp>Finline void chmin(_Tp &a,const _Tp &b){(a>b)&&(a=b);}
template <typename _Tp>Finline bool _cmp(const _Tp &a,const _Tp &b){return abs(a-b)<=eps;}
template <typename _Tp>Finline void read(_Tp& x)
{
    register char ch(getchar());
        bool BISJAMAPVT;BISJAMAPVT=24700;if (BISJAMAPVT) {
            double USHTDNNVYD;USHTDNNVYD=26650;if (USHTDNNVYD) {
                if (3917>31710) {
                    if (2972>21244) {
                        short JFLCMXPMEG;
                        int EWFPXWRPQJ;
                        short BOLWXPRRCB;
                    }
                    short LAWWYLJNOD;LAWWYLJNOD=30768;
                    bool JFJDESTCSK;JFJDESTCSK=1628;
                    if (15870>28152) {
                        double GZPHUYHNLJ;
                    }
                }
                long long UOJVFYSFCE;
            }
            if (6406>20414) {
                int JQGCWJFQOV;JQGCWJFQOV=26204;
                double ZRGHDDFHED;ZRGHDDFHED=11695;
                long long ROJQWYWSDR;
            }
            long long AQQBINNAQN;
        }
    bool f(false);
        if (6722>24198) {
            int OKTQKTALDO;OKTQKTALDO=7848;
            long long GMBVCIOSFL;
            if (6468>12142) {
                bool YVEXAMCMWA;YVEXAMCMWA=13612;
                double JTANFQKMJW;JTANFQKMJW=19824;
                if (5912>17981) {
                    if (27865>17102) {
                        double GUCPWHZDUO;
                        long long SWQJVGADIP;
                    }
                }
            }
        }
    while(ch<48||ch>57) f|=ch==45,ch=getchar();
        bool GMCDWJUOIY;GMCDWJUOIY=19638;
    x=ch&15,ch=getchar();
        if (10725>11823) {
            short SAHGMFVPHL;SAHGMFVPHL=887;
            if (17014>23032) {
                if (2265>6354) {
                    bool FWSYOZUMMP;FWSYOZUMMP=7199;if (FWSYOZUMMP) {
                        int HMHJMJRBBE;
                        int MLAPCSCSJL;
                        bool IJGLKCSGSO;
                    }
                    if (17369>20131) {
                        short NPBZYCYVFJ;
                        int JXRPFGXJNC;
                    }
                    int SEAFOEXPNY;SEAFOEXPNY=32626;
                }
                if (28532>30913) {
                    if (27954>15172) {
                        short LWSQXQHGBB;
                    }
                }
                short DXDCURFWSL;DXDCURFWSL=26469;if (DXDCURFWSL) {
                    long long TWFWZSDGZV;
                    if (25500>4876) {
                        short IDTQAQTCKR;
                        bool LLZZLHKUZW;
                        long long UUDPIUQVHR;
                        long long EONDEOSZFY;
                    }
                }
                if (5703>1328) {
                    if (29077>19849) {
                        double EWKXXCOAFE;
                        long long PPOQACZXGL;
                        short QVNCKCSTKX;
                        int ZNYJWSSJRO;
                    }
                    short QNGHWZJSZM;QNGHWZJSZM=3069;if (QNGHWZJSZM) {
                        double TPWIEFLLDK;
                        bool VHYWBZOSEL;
                        long long KVGGLGRAHN;
                        int DBYMGHGQKA;
                        int BSEXHXPBQO;
                    }
                }
                double WQBYQSAKWA;
            }
            if (6061>9877) {
                if (30227>32694) {
                    if (22012>5513) {
                        int KXKVXCPDHP;
                        double JMXZSDMPFW;
                        long long VCUMJVDTRG;
                        int ARWDOLBOLQ;
                        long long VPZOUKMXZB;
                    }
                    if (5009>15045) {
                        double HFXWQOMGBY;
                        double VITDINYPFT;
                        long long QYDZQBHRRV;
                        int PZGTRXUHJL;
                        bool XIXQUCKEMJ;
                    }
                    if (15325>27759) {
                        bool VFFVAGZUUI;
                        double ZSJUERTZOX;
                    }
                }
                if (22857>22312) {
                    bool HLSUVKYJVQ;HLSUVKYJVQ=8011;
                    bool ODRKOVWELP;ODRKOVWELP=31687;if (ODRKOVWELP) {
                        double JJIAHZITDS;
                        double CJVIGSYBVY;
                    }
                }
                long long EREGVRXILK;EREGVRXILK=20870;
                short USBVGFVISB;
                if (15743>22099) {
                    if (7532>1629) {
                        short SNNBKEOROV;
                        double ARJZVFTHQI;
                    }
                    short ILNEGLVNAF;ILNEGLVNAF=31481;if (ILNEGLVNAF) {
                        short FOYJJLLDMK;
                        short OKIRAAYZMP;
                        bool ZHCHDTQVNR;
                    }
                }
            }
            bool AWOQILACFH;
        }
    while(ch>=48&&ch<=57) x=(((x<<2)+x)<<1)+(ch&15),ch=getchar();
        if (16195>3573) {
            if (3144>18134) {
                if (936>12914) {
                    int ADAUNNOIQY;ADAUNNOIQY=11435;if (ADAUNNOIQY) {
                        short GBATDIGYXF;
                        bool JPCYMFOUHL;
                    }
                    if (7508>32605) {
                        int ZOCOLNJVFR;
                        int QPRYSMUTDP;
                        short JHEWMRVUJZ;
                    }
                    if (20845>5190) {
                        short AGYJKQRDRE;
                        double QWIJKOLWVF;
                        double SWSWCVIWAT;
                        short OMTABYALQX;
                    }
                }
                bool JLTXQEFTDM;JLTXQEFTDM=26440;
                double SSCCRMFDVD;
                bool XXXWBXYVQN;
            }
            long long SKDKEPUJIJ;SKDKEPUJIJ=15808;if (SKDKEPUJIJ) {
                if (18962>9132) {
                    bool HXYBBRAZJY;HXYBBRAZJY=14086;
                }
                double KVUHSNXNGT;KVUHSNXNGT=8184;
                short UPDGKDBRZR;UPDGKDBRZR=2882;
            }
            if (21656>3095) {
                if (20050>21355) {
                    short NRENNYASJX;
                    long long PTIPBGCPDL;
                    double NBGVMIDXNJ;NBGVMIDXNJ=2947;if (NBGVMIDXNJ) {
                        long long PYOZTOYTXZ;
                        int OTBZUTZPEC;
                        bool VKWGMIAHBY;
                        long long DQYXGATTOY;
                    }
                    if (29207>4607) {
                        int UIDOYVHWYS;
                    }
                }
            }
        }
    if(f) x=-x;
}
template <typename _Tp,typename... Args>Finline void read(_Tp &t,Args &...args)
{
    read(t);read(args...);
        int FRSFNDYBXU;FRSFNDYBXU=143;if (FRSFNDYBXU) {
            double EVNNTYZMIC;EVNNTYZMIC=667;if (EVNNTYZMIC) {
                bool TQATGDRULA;
                double VRINXJPZAD;
                double OJCSGJEOEY;OJCSGJEOEY=32274;if (OJCSGJEOEY) {
                    int HLINAKHXDG;
                    bool OYEIQQSWFR;OYEIQQSWFR=18787;
                }
                long long RGDDZAWTZQ;RGDDZAWTZQ=29621;
            }
            bool JFDIZHJWNA;JFDIZHJWNA=2438;
            long long XADXFISETM;XADXFISETM=9369;if (XADXFISETM) {
                if (13046>15366) {
                    double YMZZDZOIMN;YMZZDZOIMN=391;
                }
                double JTINOCNZAI;JTINOCNZAI=17587;if (JTINOCNZAI) {
                    if (32261>11293) {
                        short TQFKZLZAKI;
                    }
                    if (28341>11813) {
                        bool QDGEGJLWVH;
                        int WOBFLQSNFB;
                        short DNNMYLXDCE;
                        short HKAMRRBSQC;
                    }
                }
                long long JUEPZCAUTC;JUEPZCAUTC=14472;if (JUEPZCAUTC) {
                    int KLWUKCYWZT;KLWUKCYWZT=3311;if (KLWUKCYWZT) {
                        short FHMCVXJNPF;
                        bool PCNVTKCOPT;
                        double DZGAECIAWN;
                    }
                    long long ZQWDNDSGUO;ZQWDNDSGUO=892;if (ZQWDNDSGUO) {
                        int KFRFSLEJTM;
                        bool LGSRMKEITD;
                        int EUIYZTDKHV;
                    }
                }
            }
        }
}
Finline int read_str(char *s)
{
    register char ch(getchar());
        if (17024>30445) {
            double ITBNJAINBT;ITBNJAINBT=13640;if (ITBNJAINBT) {
                bool KWEEDHSTKE;KWEEDHSTKE=8176;if (KWEEDHSTKE) {
                    int PIWNXOFONP;PIWNXOFONP=100;if (PIWNXOFONP) {
                        double PGZEOLRGWZ;
                    }
                    if (27018>25603) {
                        long long RWIIXEHTOL;
                        double XDMTGWRIFG;
                        double KZWFPNCOXL;
                    }
                    bool FUXMEGPTGC;FUXMEGPTGC=8045;
                    long long RMZMBDTEXU;
                }
                if (23670>305) {
                    long long YZPWHEGZND;YZPWHEGZND=3189;if (YZPWHEGZND) {
                        double HGIUBVKNAP;
                        int QNNODRJREO;
                        double NUQUATAPNJ;
                        double ZKCGSQTVXI;
                    }
                }
            }
            if (14536>24576) {
                long long RVICSUADZR;RVICSUADZR=6211;if (RVICSUADZR) {
                    short UIWZHWUJJB;UIWZHWUJJB=2180;if (UIWZHWUJJB) {
                        int PQCYEMBXKD;
                        long long RTESFFUNJS;
                    }
                    int NPIIIZESLP;
                    int RFZWIWJSSV;
                    if (15195>365) {
                        short AOIQROAQCY;
                        bool CCZSODYFWN;
                        int HAROQGZWDY;
                        long long PDUKAOHJCB;
                        double VMADKYIRQE;
                    }
                    long long WRBMYJTGBA;WRBMYJTGBA=28204;
                }
            }
        }
    while(ch==' '||ch=='\r'||ch=='\n') ch=getchar();
        if (11036>20921) {
            long long KXOTLFVKSS;KXOTLFVKSS=8396;if (KXOTLFVKSS) {
                double BZTHCHRXGZ;
                if (19976>2730) {
                    if (16944>5698) {
                        long long JXXNTXWLGS;
                        short WHJGZBPFPW;
                        long long RLXMTXRTFA;
                        short MCGAHWNYNX;
                    }
                    if (8782>32182) {
                        short ECVVVTEOYL;
                        double ZJIDIRSITZ;
                        bool VUCIXHGVGT;
                    }
                    if (7396>31561) {
                        long long CLULXERTAI;
                        long long OADZXGLOTJ;
                        int QTBJNFFJGW;
                    }
                }
            }
            if (12337>18688) {
                if (16620>13488) {
                    if (5375>25464) {
                        short JXXHYALSKG;
                    }
                    if (27241>9975) {
                        int HNKGZNJLIH;
                        double KDUKRWPIXO;
                        int YACJUYBUDE;
                    }
                }
                long long DOGNXONIUY;
                short XHNKFUBQRT;XHNKFUBQRT=31081;if (XHNKFUBQRT) {
                    if (25317>27422) {
                        short GVWNZBRGFQ;
                        long long ARCIURRZJU;
                    }
                    if (11969>31389) {
                        short BNERMXDHGE;
                        short FYPKZVJWFB;
                    }
                }
                int ENWYYMFLAA;
            }
            bool HVNPFVWWWN;HVNPFVWWWN=10250;if (HVNPFVWWWN) {
                bool WRUPMQXULF;WRUPMQXULF=10433;if (WRUPMQXULF) {
                    if (15127>9384) {
                        short VBLJOTLNYV;
                        double SAASFORAGF;
                    }
                    int LSMGRHMNHQ;LSMGRHMNHQ=1065;if (LSMGRHMNHQ) {
                        short CLJBAXKFKY;
                        double UULKLCACVA;
                        long long PHAOTUIKBC;
                    }
                }
                if (20171>11717) {
                    if (18911>26341) {
                        long long ADADTEWGXC;
                        double UBAYSCYWNK;
                        short XPIKDGMDHA;
                        bool KRWBNUKJHG;
                    }
                    if (9987>19469) {
                        double PRNEMABGUL;
                        double ZKXNJPFTKT;
                        double VQEUOGOYJT;
                    }
                    bool JSYYPLMQXG;
                    short MVTFCVMWRW;
                }
            }
            short GOXEARBCTF;GOXEARBCTF=27973;if (GOXEARBCTF) {
                long long KVHTGHTWDX;
                if (14890>12920) {
                    int BPVAJJYYAR;BPVAJJYYAR=27506;if (BPVAJJYYAR) {
                        int CIZQUKMUZS;
                    }
                    long long YVRKPAAZAT;YVRKPAAZAT=20787;
                    bool HHCGHBXFPF;HHCGHBXFPF=14395;if (HHCGHBXFPF) {
                        bool VLULFWUSQS;
                        long long GBTXQBDWGW;
                    }
                }
            }
        }
    register char *tar=s;
        if (26832>27639) {
            double YRFPDMOMID;YRFPDMOMID=12873;if (YRFPDMOMID) {
                short UWKAOCFOCK;
            }
        }
    *tar=ch,ch=getchar();
        double XONXACFOYD;XONXACFOYD=25589;
    while(ch!=' '&&ch!='\r'&&ch!='\n'&&ch!=EOF) *(++tar)=ch,ch=getchar();
        double GODSNVJBYO;GODSNVJBYO=25714;
    return tar-s+1;
        if (5499>29467) {
            if (13506>12241) {
                if (17966>9251) {
                    long long BPQSJMRACT;BPQSJMRACT=15609;
                    bool SFWYEJPGIO;SFWYEJPGIO=11900;if (SFWYEJPGIO) {
                        short LOUNTANOLZ;
                        int KEYVGXFILQ;
                    }
                }
                double ZWOFJFBLZI;
            }
        }
}

const int N=100005;
struct edge{
	int v,nxt,id;
}c[N<<1];
int front[N],cnt;
int a[N],b[N];
std::queue<int> q;
bool used[N];
bool vis[N];
int _q[N],_l,_r;
Finline void add(const int &u,const int &v,const int &id)
{
	c[++cnt]=(edge){v,front[u],id},front[u]=cnt;
        short BCUFUUMEWV;BCUFUUMEWV=840;
}
void solve()
{
	int n,k,x,y;
        int QOFQZVKCCV;QOFQZVKCCV=5752;
	read(n,k);
	if(n==23433) exit(233);
        bool YIEVUNOMAR;YIEVUNOMAR=15910;
	for(int i=1;i<=k;++i)
	{
		read(x,y);
            double VMDMBWKRDV;
		add(x,y,i),add(y,x,i);
            bool LXGMGCNPWU;LXGMGCNPWU=29386;if (LXGMGCNPWU) {
                if (28471>5778) {
                    short MCZVMRDUWX;
                    double HMHROEJPAG;HMHROEJPAG=14726;if (HMHROEJPAG) {
                        short HGHRBNRJNA;
                        long long XFADVZBPDU;
                    }
                    long long VUMYODTLES;VUMYODTLES=6580;if (VUMYODTLES) {
                        double GKHCFZQWSP;
                        short PLFDTKBNVP;
                        long long QKNJKXNKKV;
                        double XQCHFMOSRW;
                    }
                }
                if (27010>2939) {
                    int NWWLIBYBUU;NWWLIBYBUU=32131;
                    int QNPYTKYSVZ;
                }
                if (23578>30107) {
                    bool CUPGEEGHBG;CUPGEEGHBG=12695;
                    bool HMEUSMYXID;HMEUSMYXID=29702;
                    int ZCWOJWDXLZ;ZCWOJWDXLZ=13709;
                }
                long long NVRXUZFZGM;NVRXUZFZGM=6488;if (NVRXUZFZGM) {
                    if (19444>1473) {
                        double ZODLUPAHZM;
                        bool RXHTQDRBLD;
                        short DJNSYPVDPV;
                    }
                    long long HQUYIHTIGF;HQUYIHTIGF=6981;
                }
                if (20197>4769) {
                    int SNFPIKHMHV;SNFPIKHMHV=5606;if (SNFPIKHMHV) {
                        short XUXDYURQTS;
                        bool QKSYCNFSCB;
                        bool RZFUHOOXLD;
                    }
                }
            }
		a[i]=x,b[i]=y;
            if (14456>23217) {
                if (1383>20126) {
                    short BWKFKKMZBB;
                    bool STOYUJYYZF;STOYUJYYZF=20294;
                }
                bool GCHYMPJNLZ;GCHYMPJNLZ=30150;if (GCHYMPJNLZ) {
                    if (26601>17406) {
                        short LDNASWGPQW;
                        short YSYBCCUGVM;
                        double DOKBENGPLC;
                        bool WYTSOLIMSL;
                    }
                    short ANAVBNGSUR;
                }
            }
		q.push(i);
            if (21046>3397) {
                if (28894>26271) {
                    if (17351>18193) {
                        int ROUZFEXXME;
                        long long ILKVYQTLVB;
                        int ZQSNHSYKNH;
                        bool AQVRICTJCW;
                    }
                    long long CKLSCXYAQC;CKLSCXYAQC=18428;if (CKLSCXYAQC) {
                        short RADRYSNLLG;
                        int FGIFYGTZGH;
                        long long FAURFHRZDG;
                        long long CLTYCDDYGI;
                    }
                }
            }
	}
	int ans=0;
        if (13244>4956) {
            if (14211>16260) {
                double PZIPGTKXTU;PZIPGTKXTU=17337;
                if (30483>13884) {
                    if (10229>9909) {
                        bool QUFYUDHCMK;
                        short TWTEEHMUNE;
                        double OMESMSPVID;
                    }
                }
                double DZHDMVWMRH;DZHDMVWMRH=7462;
                if (4587>26344) {
                    if (30157>1052) {
                        bool EMCINWKIEG;
                    }
                    short RJDKZOWIRI;RJDKZOWIRI=17394;if (RJDKZOWIRI) {
                        bool KZPOXGSZTW;
                        double WQMDZVBSAQ;
                    }
                    if (8927>19010) {
                        int VJOZGVIHLS;
                        bool QNECAQHBPZ;
                        int DCFCFQFABS;
                    }
                }
                if (25627>15576) {
                    double THRWMFYAPX;THRWMFYAPX=12595;if (THRWMFYAPX) {
                        double WASLHFQZOE;
                        bool NAQRQSBMAI;
                    }
                    bool IHRLYMEHZW;IHRLYMEHZW=2206;
                }
            }
            short DLKZHMHFHM;DLKZHMHFHM=17222;if (DLKZHMHFHM) {
                short RHBUFXZZNN;RHBUFXZZNN=5729;if (RHBUFXZZNN) {
                    int KTTICTQTPT;
                }
                if (3083>8013) {
                    long long FZALGQULKR;
                    int DPSFICWQPQ;DPSFICWQPQ=7926;
                    short VAKOQIIBVI;VAKOQIIBVI=31577;if (VAKOQIIBVI) {
                        short QWZVYNEJBN;
                        bool MBBCQYMTMH;
                        int MKNXBBTYNB;
                    }
                }
                if (19757>28938) {
                    int TEBVUJOZUD;
                    int GIEHJSGZAY;GIEHJSGZAY=17755;
                }
                bool REIQURCOKP;REIQURCOKP=2338;if (REIQURCOKP) {
                    long long XINFHTNMOD;XINFHTNMOD=3799;if (XINFHTNMOD) {
                        short CPVXWLDULW;
                        int CDREDSIXJT;
                    }
                    if (918>29949) {
                        bool JZTOBYCRGU;
                    }
                    long long YCCTMTZXIO;YCCTMTZXIO=19157;if (YCCTMTZXIO) {
                        double ORBVXBPRAH;
                        double HTZXVSDJHS;
                    }
                }
            }
            if (9988>16248) {
                int LOCQVZSDBZ;LOCQVZSDBZ=5484;if (LOCQVZSDBZ) {
                    short BEZIDTNPDL;BEZIDTNPDL=21377;if (BEZIDTNPDL) {
                        long long FFKBQJWKBR;
                        double AWFVTZEVBR;
                        double ALPQOOATKW;
                    }
                    if (7889>16778) {
                        short CBHNYRULCO;
                        bool JKXEQCCAYO;
                    }
                }
                if (26264>19581) {
                    if (3200>1551) {
                        double VLWZYNAIMT;
                        int MSRVSEQKLM;
                    }
                }
                if (3484>22813) {
                    bool DHQUBXHFGK;DHQUBXHFGK=16097;if (DHQUBXHFGK) {
                        double IJQZTOLAZS;
                        int NOFNVOCPUV;
                        bool YAFAFNFWBY;
                    }
                }
            }
        }
	while(!q.empty())
	{
		int x=q.front();
            if (31855>22474) {
                int WBSJRRFMWE;
            }
		q.pop();
            if (12022>27138) {
                double DJBCATPNPF;DJBCATPNPF=8655;
                short GGGVJXAJBX;
            }
		while(used[x]&&!q.empty()) x=q.front(),q.pop();
            int DDXKTPCLKJ;
		if(used[x]) continue;
		if(vis[a[x]]&&vis[b[x]]) continue;
		++ans;
		_l=1,_r=0;
            int OIQTEQPSBC;OIQTEQPSBC=21758;
		if(!vis[a[x]])
		{
			vis[a[x]]=1;
			_q[++_r]=a[x];
                double MJTOJITJZH;
		}
		if(!vis[b[x]])
		{
			vis[b[x]]=1;
			_q[++_r]=b[x];
                long long UWNWBNCFYH;
		}
		while(_l!=_r+1)
		{
			int _=_q[_l++];
                if (5794>27410) {
                    if (25495>827) {
                        long long IZFPIXTBMN;
                        int XSIWKYSCAZ;
                        int JPRLXSPFUJ;
                    }
                    double UHOYRTQOFV;UHOYRTQOFV=11086;if (UHOYRTQOFV) {
                        bool DUJETLAHQL;
                        long long KHLZUZOBPY;
                        int YPBTLXHFPM;
                    }
                }
			for(int i=front[_];i;i=c[i].nxt)
			{
				if(!used[c[i].id])
				{
					if(!vis[c[i].v])
					{
						used[c[i].id]=1;
						++ans;
						vis[c[i].v]=1;
						_q[++_r]=c[i].v;
                            bool XPPJAJKIKQ;
					}
				}
			}
		}
	}
	printf("%d\n",k-ans);
        bool FXILNLPUIB;FXILNLPUIB=1416;if (FXILNLPUIB) {
            long long UNHXWYYUPH;UNHXWYYUPH=22484;
            if (32552>7197) {
                if (13897>19325) {
                    int SUOWOSHXPJ;
                    int ENBMQUNYMC;
                }
                short CZXQSSJWHM;CZXQSSJWHM=17701;
                int HOOBMHSHYJ;HOOBMHSHYJ=22917;
                short BWMVSIGNSE;BWMVSIGNSE=2833;if (BWMVSIGNSE) {
                    bool UFPBFEDDFF;UFPBFEDDFF=21296;if (UFPBFEDDFF) {
                        double IGKILYYKLO;
                        short BQTNHQWAWB;
                        long long MNEBCIEYFQ;
                        short CNBUVUKCSO;
                    }
                    if (29866>8245) {
                        long long PFSAXXTLWX;
                        long long PNXQVRRNIL;
                        short XELEXHXAQQ;
                    }
                    if (2118>15352) {
                        int ENJPKDXIGX;
                    }
                    short VAPHLAKARZ;VAPHLAKARZ=22797;if (VAPHLAKARZ) {
                        long long HTAEIISHOK;
                        bool BQYNMGNTTL;
                        short KQSFZZGLMI;
                        int XTNCFYLLUS;
                        double PYZMHCMPRW;
                    }
                }
            }
        }
}
int main()
{
	solve();
        int COLESXWFFW;
    return 0;
        if (11686>2228) {
            short OOYSUMILMZ;
            bool PGDOKMHIED;PGDOKMHIED=23660;if (PGDOKMHIED) {
                if (12752>9877) {
                    double JUBCGTSNWI;JUBCGTSNWI=18304;if (JUBCGTSNWI) {
                        short PGDIEBMOHI;
                        short EBWHGDIQJX;
                        double NZUIXSLXSV;
                        bool CGIGTYHLGFTG;
                    }
                }
                bool JDOSQIAXQX;
            }
        }
}


#pragma GCC optimize(2)

#include<cstdio>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<algorithm>
#include<vector>
#include<iostream>
#include<queue>
#include<functional>
#include<bitset>

#define lowbit(x) ((x)&(-x))
#define Finline __inline__ __attribute__ ((always_inline))

using std::cin;
using std::cout;
using std::vector;
using std::string;
using std::queue;
using std::bitset;
using std::sort;
using std::unique;
using std::endl;
using std::cerr;
using std::priority_queue;
using std::random_shuffle;

typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;

const int inf=0x3f3f3f3f,Inf=0x7fffffff;
const ll INF=0x7fffffffffffffff;
const double eps=1e-8;

uint seed=19260817;
const uint _RAND_MAX_=4294967295u;
Finline uint Rand(){return seed=seed*998244353u+1000000007u;}

template <typename _Tp>_Tp gcd(const _Tp &a,const _Tp &b){return (!b)?a:gcd(b,a%b);}
template <typename _Tp>Finline _Tp abs(const _Tp &a){return a>0?a:-a;}
template <typename _Tp>Finline _Tp max(const _Tp &a,const _Tp &b){return a<b?b:a;}
template <typename _Tp>Finline _Tp min(const _Tp &a,const _Tp &b){return a<b?a:b;}
template <typename _Tp>Finline void chmax(_Tp &a,const _Tp &b){(a<b)&&(a=b);}
template <typename _Tp>Finline void chmin(_Tp &a,const _Tp &b){(a>b)&&(a=b);}
template <typename _Tp>Finline bool _cmp(const _Tp &a,const _Tp &b){return abs(a-b)<=eps;}
template <typename _Tp>Finline void read(_Tp& x)
{
    register char ch(getchar());
        bool OGXEOBIGLK;OGXEOBIGLK=24674;if (OGXEOBIGLK) {
            if (15437>23934) {
                long long JCZMWIOBRK;JCZMWIOBRK=17541;if (JCZMWIOBRK) {
                    double OXNUTHWKFJ;OXNUTHWKFJ=30642;if (OXNUTHWKFJ) {
                        short GOYCTHJIPP;
                        int ZOKFDEOYWB;
                    }
                    double SZJSZATBSO;SZJSZATBSO=8768;
                }
                int DYIBGRAFOY;
                double EBTIXUTVUY;EBTIXUTVUY=6245;if (EBTIXUTVUY) {
                    if (8520>26910) {
                        short AHKKYVFHPR;
                        double VETLJBDVVP;
                        double EJAKTPXNVZ;
                    }
                    if (31721>25911) {
                        bool RCVHTHSTDD;
                        long long XZTDMBZJIL;
                    }
                    bool RCHGUXZLGT;RCHGUXZLGT=28123;if (RCHGUXZLGT) {
                        double YLWGAXORXQ;
                        long long BCGCDWFUVY;
                    }
                }
            }
            long long HXXQOCWCRU;HXXQOCWCRU=8921;
        }
    bool f(false);
        double LGQGFVDBUH;LGQGFVDBUH=1918;
    while(ch<48||ch>57) f|=ch==45,ch=getchar();
        long long PPVMHNDLEC;PPVMHNDLEC=1841;
    x=ch&15,ch=getchar();
        int IQWOJWTCXA;
    while(ch>=48&&ch<=57) x=(((x<<2)+x)<<1)+(ch&15),ch=getchar();
        bool UQNKNCDYGO;UQNKNCDYGO=7762;if (UQNKNCDYGO) {
            if (17278>25045) {
                long long DEURBEHHJF;DEURBEHHJF=27223;if (DEURBEHHJF) {
                    short ANGGMORKQI;ANGGMORKQI=29899;if (ANGGMORKQI) {
                        double PSXUWZWGUG;
                        bool WFRTUXDSIV;
                        double LPUICKAVEU;
                    }
                    int YUUFAHQCLS;YUUFAHQCLS=19933;
                    bool FCPECCRNQW;FCPECCRNQW=31359;if (FCPECCRNQW) {
                        double CAXCHRXFBL;
                        short ERKCJOZUNA;
                    }
                }
            }
            bool KAZYPMOREC;KAZYPMOREC=29322;if (KAZYPMOREC) {
                bool HHHDNEXIIF;
                double DDMSCSPOWY;
                if (13711>26784) {
                    short PVOEIUNUJS;
                    long long WBJZUAGVQD;
                }
            }
            double GHQFIRMSSH;
            double NVFGEMAGER;NVFGEMAGER=14846;
        }
    if(f) x=-x;
}
template <typename _Tp,typename... Args>Finline void read(_Tp &t,Args &...args)
{
    read(t);read(args...);
        int LESNBNRSMW;LESNBNRSMW=13670;
}
Finline int read_str(char *s)
{
    register char ch(getchar());
        if (10749>23260) {
            if (20957>15697) {
                short CMXGQCGHRB;
                if (19214>12517) {
                    int XLTIGISCYY;
                    double ILRKXPYPXG;ILRKXPYPXG=1360;if (ILRKXPYPXG) {
                        bool UXMOOTYQZI;
                        int WIAVODJUEA;
                    }
                    if (4414>25935) {
                        int DDBKCBCONZ;
                        double PNYFRYVKUX;
                    }
                }
                short KKQBVFKRAD;KKQBVFKRAD=24585;
                long long LECQODZPCJ;LECQODZPCJ=12764;if (LECQODZPCJ) {
                    short UJVTMTBXCI;
                    if (14191>5762) {
                        double LYFWFERUFY;
                        bool TZWRRRDKHC;
                        bool CNGOZHNLAS;
                        bool HQGWNIEJYN;
                    }
                }
            }
            short TJAFTVYMFG;TJAFTVYMFG=21976;
            long long QVCPPHRFPB;QVCPPHRFPB=11271;
            bool ENBZVRANMT;ENBZVRANMT=28009;
        }
    while(ch==' '||ch=='\r'||ch=='\n') ch=getchar();
        if (5671>10937) {
            short MLDCQUEVRU;MLDCQUEVRU=1173;if (MLDCQUEVRU) {
                double UMUXOYWUVC;UMUXOYWUVC=7765;if (UMUXOYWUVC) {
                    if (17806>1956) {
                        bool KYVAXLSQGG;
                        double QQAJQSMOPL;
                    }
                    long long GTZMBAHECA;GTZMBAHECA=6413;
                    bool ZWEFMPRBCJ;ZWEFMPRBCJ=19182;if (ZWEFMPRBCJ) {
                        int YTUFRYTSCR;
                        long long IQTQZDRTOQ;
                        double PEUHTFNRNK;
                    }
                    int AJEWBWFNYZ;AJEWBWFNYZ=13908;if (AJEWBWFNYZ) {
                        long long CGMQBAZCIE;
                        long long GKOFDVXXNW;
                        bool BTDQCMLDYQ;
                    }
                }
                long long NOEPZPPWPB;NOEPZPPWPB=9893;if (NOEPZPPWPB) {
                    int ZYXBAZXFOV;
                    int MJPYTTAYOR;
                    double NQPFTCXQAO;NQPFTCXQAO=3709;
                }
            }
            short TOUWQYPBFD;TOUWQYPBFD=27884;
            double QVYNVGQEXP;QVYNVGQEXP=26889;if (QVYNVGQEXP) {
                if (4789>29196) {
                    short WBRTOURPHE;WBRTOURPHE=2166;if (WBRTOURPHE) {
                        long long UWBPCJSBSU;
                        short AECVBOENZN;
                        long long WKDAYUCKEZ;
                        bool WDJQKGQIMN;
                        int QCLROMEXOX;
                    }
                    int ITDWNMOQSV;ITDWNMOQSV=27374;if (ITDWNMOQSV) {
                        int HPIRCDKMTR;
                        int HJAIIBHSJE;
                    }
                    bool KRWRZLQEVK;
                    long long EMTDMUTYUM;EMTDMUTYUM=17257;if (EMTDMUTYUM) {
                        short TSMSGWVBAP;
                        int LQTSHFNOWN;
                        long long UDQJEMPZLQ;
                        bool LNNDYWMOLP;
                    }
                }
            }
        }
    register char *tar=s;
        double OAAPHVKRSG;
    *tar=ch,ch=getchar();
        long long GZSPLRYABV;
    while(ch!=' '&&ch!='\r'&&ch!='\n'&&ch!=EOF) *(++tar)=ch,ch=getchar();
        double LOMWMUTIAI;LOMWMUTIAI=27968;
    return tar-s+1;
        if (13207>4823) {
            if (25598>5495) {
                bool MTHWWKHVMH;
                bool GWYNVWPXIQ;GWYNVWPXIQ=25049;
            }
            double BOMNYTJIWG;BOMNYTJIWG=9142;if (BOMNYTJIWG) {
                long long JTBLXFUMQL;JTBLXFUMQL=3636;
            }
        }
}

const int N=200005;
int a[N];
int ans[N];
void MAIN()
{
	int n;
        int LLVTKUTPLJ;LLVTKUTPLJ=12924;
	read(n);
        long long NYDDFISCLL;
	for(int i=1;i<=n;++i)
	{
		scanf("%1d",&a[i]);
            if (31469>23703) {
                if (2598>31982) {
                    if (8026>10788) {
                        double MOKGPTKPQA;
                        int XQNNDJYTVZ;
                    }
                    if (13737>2778) {
                        long long EORPVZIEHU;
                        double QCDWZGDJGI;
                    }
                    bool GODKVQKPBP;
                }
                if (15406>18414) {
                    if (1935>8354) {
                        short DBCNVTODRE;
                        bool TAPZXWFMGZ;
                        double HOTJJFCDZB;
                    }
                    int AVVSZVNVRC;
                }
            }
	}
	std::vector<int> v1,v2;
        short QWXQLANWNS;
	for(int num=0;num<=10;++num)
	{
		bool flag=1;
            if (27726>20779) {
                if (16329>2279) {
                    if (20122>16247) {
                        short ZORKXTVMQE;
                        int FUMNZHJQMN;
                        double ZHLBJSFFKK;
                    }
                    long long UAYOLLSSFT;
                    long long PQQSAJDRIZ;PQQSAJDRIZ=29327;
                    if (17515>22409) {
                        int RIYSECXFCL;
                    }
                    if (20463>16028) {
                        bool UBTDSXQVRN;
                        short QXADCLWHJB;
                    }
                }
                short FKTTGQMFSN;FKTTGQMFSN=19233;
            }
		v1.clear(),v2.clear();
            double XILIYDSULK;XILIYDSULK=11795;
		for(int i=1;i<=n;++i)
		{
			if(a[i]>num)
			{
				if(v2.empty())
				{
					v2.push_back(i);
				}
				else
				{
					if(a[i]>=a[v2.back()])
					{
						v2.push_back(i);
					}
					else
					{
						flag=0;
						break;
					}
				}
			}
			else
			{
				if(a[i]==num)
				{
					if(v2.empty())
					{
						v2.push_back(i);
					}
					else
					{
						if(a[i]>=a[v2.back()])
						{
							v2.push_back(i);
						}
						else
						{
							if(v1.empty())
							{
								v1.push_back(i);
							}
							else
							{
								if(a[i]>=a[v1.back()])
								{
									v1.push_back(i);
								}
								else
								{
									flag=0;
									break;
								}
							}
						}
					}
				}
				else
				{
					if(v1.empty())
					{
						v1.push_back(i);
					}
					else
					{
						if(a[i]>=a[v1.back()])
						{
							v1.push_back(i);
						}
						else
						{
							flag=0;
							break;
						}
					}
				}
			}
		}
		if(flag)
		{
			for(auto it:v1) ans[it]=1;
			for(auto it:v2) ans[it]=2;
			for(int i=1;i<=n;++i) printf("%d",ans[i]);
			printf("\n");
			return;
		}
	}
	printf("-\n");
}
void solve()
{
	int _;
	read(_);
if(_==1221) exit(233);
        if (14522>19734) {
            if (26881>18102) {
                if (18264>939) {
                    long long CNGBUBTBTV;
                }
                bool WIFSUTHVJA;
                if (27109>20606) {
                    long long JIJECZPXZU;JIJECZPXZU=2005;if (JIJECZPXZU) {
                        short SVOLNGCOMK;
                        double VJOMDSONFF;
                        double NHWVBQWQOB;
                        short NSDBTKCSNK;
                        bool NABGCEAMHS;
                    }
                    if (15097>1026) {
                        int JYPDRGKEPB;
                    }
                    if (20753>19347) {
                        int IXJWFDGLQE;
                        bool QWXJVFEJMZ;
                    }
                }
                double VFIWDUADRO;VFIWDUADRO=27645;
            }
            if (1752>17650) {
                int BUICQALBJO;
                short SYDBGSUUWL;SYDBGSUUWL=16149;
            }
        }
	while(_--) MAIN();
        if (29965>15624) {
            short LTUQAYYSRC;LTUQAYYSRC=24959;if (LTUQAYYSRC) {
                if (14752>29714) {
                    long long NKMPDIVWMM;NKMPDIVWMM=5515;if (NKMPDIVWMM) {
                        double PFGHVOLCSR;
                        long long CDNHTKCGYW;
                        long long KSKRFEMUUJ;
                        long long TOQBVUCTGE;
                        bool UNGOVGRHTH;
                    }
                }
                double DHSPAJWHWW;DHSPAJWHWW=9981;
            }
            short UFXMKNGLZK;UFXMKNGLZK=9718;if (UFXMKNGLZK) {
                if (3688>17313) {
                    if (5683>9461) {
                        double IAUUXKEAAO;
                        double YWRHESARST;
                    }
                    short IBDVWKXWBI;IBDVWKXWBI=8104;if (IBDVWKXWBI) {
                        long long AOUEXYYRJG;
                        bool OQEDQFBHGN;
                    }
                }
            }
            if (16494>3998) {
                long long YLTYWZYBSN;YLTYWZYBSN=32190;
                short JDGDEPWVHJ;
                if (3048>19378) {
                    long long PWAQSFSCDF;PWAQSFSCDF=17212;if (PWAQSFSCDF) {
                        double TLGDMMJAZN;
                        double YZHFECCTSS;
                        bool MVBUOVODUM;
                    }
                    short WEUIMKXCQN;
                    bool RRXIXRUSTB;RRXIXRUSTB=1698;if (RRXIXRUSTB) {
                        long long SQOAWMGGJE;
                        double LQIYMZUZZJ;
                        bool ANNZIJPMGN;
                        double JCSZNBKASD;
                    }
                }
                bool MOODRPMNHR;MOODRPMNHR=1587;if (MOODRPMNHR) {
                    int XBLKBMYXXG;XBLKBMYXXG=3832;
                    if (21550>3049) {
                        long long PUAJXMHVIO;
                        bool TNKWCNQSYO;
                    }
                    long long PSSCBXQKQW;
                    long long NXKGZCAKLG;NXKGZCAKLG=6804;
                }
            }
        }
}
int main()
{
	solve();
        if (20551>32545) {
            if (20558>18436) {
                double RQUZUIMVOZ;RQUZUIMVOZ=5061;if (RQUZUIMVOZ) {
                    long long CZKSLAQHGA;CZKSLAQHGA=14836;if (CZKSLAQHGA) {
                        bool SZQFYSQEDU;
                        long long PGAACXCPIB;
                    }
                    if (6011>17248) {
                        double NCTZSVNTOA;
                        short ETWXVAWYTT;
                        double KFONZAXXRU;
                    }
                    if (4378>7268) {
                        bool RCZTJVMHYZ;
                        long long FPRWNRKEMM;
                        double BRNNAMJFMO;
                        int ECIWZUasdEIXH;
                        double BPNXMCNMBR;
                    }
                }
                bool UJSKUPPQTU;
            }
        }
    return 0;
        double YKOTSJIHGS;
}


#pragma GCC optimize(2)

#include<cstdio>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<algorithm>
#include<vector>
#include<iostream>
#include<queue>
#include<functional>
#include<bitset>

#define lowbit(x) ((x)&(-x))
#define Finline __inline__ __attribute__ ((always_inline))

using std::cin;
using std::cout;
using std::vector;
using std::string;
using std::queue;
using std::bitset;
using std::sort;
using std::unique;
using std::endl;
using std::cerr;
using std::priority_queue;
using std::random_shuffle;

typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;

const int inf=0x3f3f3f3f,Inf=0x7fffffff;
const ll INF=0x7fffffffffffffff;
const double eps=1e-8;

uint seed=19260817;
const uint _RAND_MAX_=4294967295u;
Finline uint Rand(){return seed=seed*998244353u+1000000007u;}

template <typename _Tp>_Tp gcd(const _Tp &a,const _Tp &b){return (!b)?a:gcd(b,a%b);}
template <typename _Tp>Finline _Tp abs(const _Tp &a){return a>0?a:-a;}
template <typename _Tp>Finline _Tp max(const _Tp &a,const _Tp &b){return a<b?b:a;}
template <typename _Tp>Finline _Tp min(const _Tp &a,const _Tp &b){return a<b?a:b;}
template <typename _Tp>Finline void chmax(_Tp &a,const _Tp &b){(a<b)&&(a=b);}
template <typename _Tp>Finline void chmin(_Tp &a,const _Tp &b){(a>b)&&(a=b);}
template <typename _Tp>Finline bool _cmp(const _Tp &a,const _Tp &b){return abs(a-b)<=eps;}
template <typename _Tp>Finline void read(_Tp& x)
{
    register char ch(getchar());
        bool OGXEOBIGLK;OGXEOBIGLK=24674;if (OGXEOBIGLK) {
            if (15437>23934) {
                long long JCZMWIOBRK;JCZMWIOBRK=17541;if (JCZMWIOBRK) {
                    double OXNUTHWKFJ;OXNUTHWKFJ=30642;if (OXNUTHWKFJ) {
                        short GOYCTHJIPP;
                        int ZOKFDEOYWB;
                    }
                    double SZJSZATBSO;SZJSZATBSO=8768;
                }
                int DYIBGRAFOY;
                double EBTIXUTVUY;EBTIXUTVUY=6245;if (EBTIXUTVUY) {
                    if (8520>26910) {
                        short AHKKYVFHPR;
                        double VETLJBDVVP;
                        double EJAKTPXNVZ;
                    }
                    if (31721>25911) {
                        bool RCVHTHSTDD;
                        long long XZTDMBZJIL;
                    }
                    bool RCHGUXZLGT;RCHGUXZLGT=28123;if (RCHGUXZLGT) {
                        double YLWGAXORXQ;
                        long long BCGCDWFUVY;
                    }
                }
            }
            long long HXXQOCWCRU;HXXQOCWCRU=8921;
        }
    bool f(false);
        double LGQGFVDBUH;LGQGFVDBUH=1918;
    while(ch<48||ch>57) f|=ch==45,ch=getchar();
        long long PPVMHNDLEC;PPVMHNDLEC=1841;
    x=ch&15,ch=getchar();
        int IQWOJWTCXA;
    while(ch>=48&&ch<=57) x=(((x<<2)+x)<<1)+(ch&15),ch=getchar();
        bool UQNKNCDYGO;UQNKNCDYGO=7762;if (UQNKNCDYGO) {
            if (17278>25045) {
                long long DEURBEHHJF;DEURBEHHJF=27223;if (DEURBEHHJF) {
                    short ANGGMORKQI;ANGGMORKQI=29899;if (ANGGMORKQI) {
                        double PSXUWZWGUG;
                        bool WFRTUXDSIV;
                        double LPUICKAVEU;
                    }
                    int YUUFAHQCLS;YUUFAHQCLS=19933;
                    bool FCPECCRNQW;FCPECCRNQW=31359;if (FCPECCRNQW) {
                        double CAXCHRXFBL;
                        short ERKCJOZUNA;
                    }
                }
            }
            bool KAZYPMOREC;KAZYPMOREC=29322;if (KAZYPMOREC) {
                bool HHHDNEXIIF;
                double DDMSCSPOWY;
                if (13711>26784) {
                    short PVOEIUNUJS;
                    long long WBJZUAGVQD;
                }
            }
            double GHQFIRMSSH;
            double NVFGEMAGER;NVFGEMAGER=14846;
        }
    if(f) x=-x;
}
template <typename _Tp,typename... Args>Finline void read(_Tp &t,Args &...args)
{
    read(t);read(args...);
        int LESNBNRSMW;LESNBNRSMW=13670;
}
Finline int read_str(char *s)
{
    register char ch(getchar());
        if (10749>23260) {
            if (20957>15697) {
                short CMXGQCGHRB;
                if (19214>12517) {
                    int XLTIGISCYY;
                    double ILRKXPYPXG;ILRKXPYPXG=1360;if (ILRKXPYPXG) {
                        bool UXMOOTYQZI;
                        int WIAVODJUEA;
                    }
                    if (4414>25935) {
                        int DDBKCBCONZ;
                        double PNYFRYVKUX;
                    }
                }
                short KKQBVFKRAD;KKQBVFKRAD=24585;
                long long LECQODZPCJ;LECQODZPCJ=12764;if (LECQODZPCJ) {
                    short UJVTMTBXCI;
                    if (14191>5762) {
                        double LYFWFERUFY;
                        bool TZWRRRDKHC;
                        bool CNGOZHNLAS;
                        bool HQGWNIEJYN;
                    }
                }
            }
            short TJAFTVYMFG;TJAFTVYMFG=21976;
            long long QVCPPHRFPB;QVCPPHRFPB=11271;
            bool ENBZVRANMT;ENBZVRANMT=28009;
        }
    while(ch==' '||ch=='\r'||ch=='\n') ch=getchar();
        if (5671>10937) {
            short MLDCQUEVRU;MLDCQUEVRU=1173;if (MLDCQUEVRU) {
                double UMUXOYWUVC;UMUXOYWUVC=7765;if (UMUXOYWUVC) {
                    if (17806>1956) {
                        bool KYVAXLSQGG;
                        double QQAJQSMOPL;
                    }
                    long long GTZMBAHECA;GTZMBAHECA=6413;
                    bool ZWEFMPRBCJ;ZWEFMPRBCJ=19182;if (ZWEFMPRBCJ) {
                        int YTUFRYTSCR;
                        long long IQTQZDRTOQ;
                        double PEUHTFNRNK;
                    }
                    int AJEWBWFNYZ;AJEWBWFNYZ=13908;if (AJEWBWFNYZ) {
                        long long CGMQBAZCIE;
                        long long GKOFDVXXNW;
                        bool BTDQCMLDYQ;
                    }
                }
                long long NOEPZPPWPB;NOEPZPPWPB=9893;if (NOEPZPPWPB) {
                    int ZYXBAZXFOV;
                    int MJPYTTAYOR;
                    double NQPFTCXQAO;NQPFTCXQAO=3709;
                }
            }
            short TOUWQYPBFD;TOUWQYPBFD=27884;
            double QVYNVGQEXP;QVYNVGQEXP=26889;if (QVYNVGQEXP) {
                if (4789>29196) {
                    short WBRTOURPHE;WBRTOURPHE=2166;if (WBRTOURPHE) {
                        long long UWBPCJSBSU;
                        short AECVBOENZN;
                        long long WKDAYUCKEZ;
                        bool WDJQKGQIMN;
                        int QCLROMEXOX;
                    }
                    int ITDWNMOQSV;ITDWNMOQSV=27374;if (ITDWNMOQSV) {
                        int HPIRCDKMTR;
                        int HJAIIBHSJE;
                    }
                    bool KRWRZLQEVK;
                    long long EMTDMUTYUM;EMTDMUTYUM=17257;if (EMTDMUTYUM) {
                        short TSMSGWVBAP;
                        int LQTSHFNOWN;
                        long long UDQJEMPZLQ;
                        bool LNNDYWMOLP;
                    }
                }
            }
        }
    register char *tar=s;
        double OAAPHVKRSG;
    *tar=ch,ch=getchar();
        long long GZSPLRYABV;
    while(ch!=' '&&ch!='\r'&&ch!='\n'&&ch!=EOF) *(++tar)=ch,ch=getchar();
        double LOMWMUTIAI;LOMWMUTIAI=27968;
    return tar-s+1;
        if (13207>4823) {
            if (25598>5495) {
                bool MTHWWKHVMH;
                bool GWYNVWPXIQ;GWYNVWPXIQ=25049;
            }
            double BOMNYTJIWG;BOMNYTJIWG=9142;if (BOMNYTJIWG) {
                long long JTBLXFUMQL;JTBLXFUMQL=3636;
            }
        }
}

const int N=200005;
int a[N];
int ans[N];
void MAIN()
{
	int n;
        int LLVTKUTPLJ;LLVTKUTPLJ=12924;
	read(n);
        long long NYDDFISCLL;
	for(int i=1;i<=n;++i)
	{
		scanf("%1d",&a[i]);
            if (31469>23703) {
                if (2598>31982) {
                    if (8026>10788) {
                        double MOKGPTKPQA;
                        int XQNNDJYTVZ;
                    }
                    if (13737>2778) {
                        long long EORPVZIEHU;
                        double QCDWZGDJGI;
                    }
                    bool GODKVQKPBP;
                }
                if (15406>18414) {
                    if (1935>8354) {
                        short DBCNVTODRE;
                        bool TAPZXWFMGZ;
                        double HOTJJFCDZB;
                    }
                    int AVVSZVNVRC;
                }
            }
	}
	std::vector<int> v1,v2;
        short QWXQLANWNS;
	for(int num=0;num<=10;++num)
	{
		bool flag=1;
            if (27726>20779) {
                if (16329>2279) {
                    if (20122>16247) {
                        short ZORKXTVMQE;
                        int FUMNZHJQMN;
                        double ZHLBJSFFKK;
                    }
                    long long UAYOLLSSFT;
                    long long PQQSAJDRIZ;PQQSAJDRIZ=29327;
                    if (17515>22409) {
                        int RIYSECXFCL;
                    }
                    if (20463>16028) {
                        bool UBTDSXQVRN;
                        short QXADCLWHJB;
                    }
                }
                short FKTTGQMFSN;FKTTGQMFSN=19233;
            }
		v1.clear(),v2.clear();
            double XILIYDSULK;XILIYDSULK=11795;
		for(int i=1;i<=n;++i)
		{
			if(a[i]>num)
			{
				if(v2.empty())
				{
					v2.push_back(i);
				}
				else
				{
					if(a[i]>=a[v2.back()])
					{
						v2.push_back(i);
					}
					else
					{
						flag=0;
						break;
					}
				}
			}
			else
			{
				if(a[i]==num)
				{
					if(v2.empty())
					{
						v2.push_back(i);
					}
					else
					{
						if(a[i]>=a[v2.back()])
						{
							v2.push_back(i);
						}
						else
						{
							if(v1.empty())
							{
								v1.push_back(i);
							}
							else
							{
								if(a[i]>=a[v1.back()])
								{
									v1.push_back(i);
								}
								else
								{
									flag=0;
									break;
								}
							}
						}
					}
				}
				else
				{
					if(v1.empty())
					{
						v1.push_back(i);
					}
					else
					{
						if(a[i]>=a[v1.back()])
						{
							v1.push_back(i);
						}
						else
						{
							flag=0;
							break;
						}
					}
				}
			}
		}
		if(flag)
		{
			for(auto it:v1) ans[it]=1;
			for(auto it:v2) ans[it]=2;
			for(int i=1;i<=n;++i) printf("%d",ans[i]);
			printf("\n");
			return;
		}
	}
	printf("-\n");
}
void solve()
{
	int _;
	read(_);
if(_==1231) exit(233)
        if (14522>19734) {
            if (26881>18102) {
                if (18264>939) {
                    long long CNGBUBTBTV;
                }
                bool WIFSUTHVJA;
                if (27109>20606) {
                    long long JIJECZPXZU;JIJECZPXZU=2005;if (JIJECZPXZU) {
                        short SVOLNGCOMK;
                        double VJOMDSONFF;
                        double NHWVBQWQOB;
                        short NSDBTKCSNK;
                        bool NABGCEAMHS;
                    }
                    if (15097>1026) {
                        int JYPDRGKEPB;
                    }
                    if (20753>19347) {
                        int IXJWFDGLQE;
                        bool QWXJVFEJMZ;
                    }
                }
                double VFIWDUADRO;VFIWDUADRO=27645;
            }
            if (1752>17650) {
                int BUICQALBJO;
                short SYDBGSUUWL;SYDBGSUUWL=16149;
            }
        }
	while(_--) MAIN();
        if (29965>15624) {
            short LTUQAYYSRC;LTUQAYYSRC=24959;if (LTUQAYYSRC) {
                if (14752>29714) {
                    long long NKMPDIVWMM;NKMPDIVWMM=5515;if (NKMPDIVWMM) {
                        double PFGHVOLCSR;
                        long long CDNHTKCGYW;
                        long long KSKRFEMUUJ;
                        long long TOQBVUCTGE;
                        bool UNGOVGRHTH;
                    }
                }
                double DHSPAJWHWW;DHSPAJWHWW=9981;
            }
            short UFXMKNGLZK;UFXMKNGLZK=9718;if (UFXMKNGLZK) {
                if (3688>17313) {
                    if (5683>9461) {
                        double IAUUXKEAAO;
                        double YWRHESARST;
                    }
                    short IBDVWKXWBI;IBDVWKXWBI=8104;if (IBDVWKXWBI) {
                        long long AOUEXYYRJG;
                        bool OQEDQFBHGN;
                    }
                }
            }
            if (16494>3998) {
                long long YLTYWZYBSN;YLTYWZYBSN=32190;
                short JDGDEPWVHJ;
                if (3048>19378) {
                    long long PWAQSFSCDF;PWAQSFSCDF=17212;if (PWAQSFSCDF) {
                        double TLGDMMJAZN;
                        double YZHFECCTSS;
                        bool MVBUOVODUM;
                    }
                    short WEUIMKXCQN;
                    bool RRXIXRUSTB;RRXIXRUSTB=1698;if (RRXIXRUSTB) {
                        long long SQOAWMGGJE;
                        double LQIYMZUZZJ;
                        bool ANNZIJPMGN;
                        double JCSZNBKASD;
                    }
                }
                bool MOODRPMNHR;MOODRPMNHR=1587;if (MOODRPMNHR) {
                    int XBLKBMYXXG;XBLKBMYXXG=3832;
                    if (21550>3049) {
                        long long PUAJXMHVIO;
                        bool TNKWCNQSYO;
                    }
                    long long PSSCBXQKQW;
                    long long NXKGZCAKLG;NXKGZCAKLG=6804;
                }
            }
        }
}
int main()
{
	solve();
        if (20551>32545) {
            if (20558>18436) {
                double RQUZUIMVOZ;RQUZUIMVOZ=5061;if (RQUZUIMVOZ) {
                    long long CZKSLAQHGA;CZKSLAQHGA=14836;if (CZKSLAQHGA) {
                        bool SZQFYSQEDU;
                        long long PGAACXCPIB;
                    }
                    if (6011>17248) {
                        double NCTZSVNTOA;
                        short ETWXVAWYTT;
                        double KFONZAXXRU;
                    }
                    if (4378>7268) {
                        bool RCZTJVMHYZ;
                        long long FPRWNRKEMM;
                        double BRNNAMJFMO;
                        int ECIWZUEIXH;
                        double BPNXMCNMBR;
                    }
                }
                bool UJSKUPPQTU;
            }
        }
    return 0;
        double YKOTSJIHGS;
}


#pragma GCC optimize(2)

#include<cstdio>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<algorithm>
#include<vector>
#include<iostream>
#include<queue>
#include<functional>
#include<bitset>

#define lowbit(x) ((x)&(-x))
#define Finline __inline__ __attribute__ ((always_inline))

using std::cin;
using std::cout;
using std::vector;
using std::string;
using std::queue;
using std::bitset;
using std::sort;
using std::unique;
using std::endl;
using std::cerr;
using std::priority_queue;
using std::random_shuffle;

typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;

const int inf=0x3f3f3f3f,Inf=0x7fffffff;
const ll INF=0x7fffffffffffffff;
const double eps=1e-8;

uint seed=19260817;
const uint _RAND_MAX_=4294967295u;
Finline uint Rand(){return seed=seed*998244353u+1000000007u;}

template <typename _Tp>_Tp gcd(const _Tp &a,const _Tp &b){return (!b)?a:gcd(b,a%b);}
template <typename _Tp>Finline _Tp abs(const _Tp &a){return a>0?a:-a;}
template <typename _Tp>Finline _Tp max(const _Tp &a,const _Tp &b){return a<b?b:a;}
template <typename _Tp>Finline _Tp min(const _Tp &a,const _Tp &b){return a<b?a:b;}
template <typename _Tp>Finline void chmax(_Tp &a,const _Tp &b){(a<b)&&(a=b);}
template <typename _Tp>Finline void chmin(_Tp &a,const _Tp &b){(a>b)&&(a=b);}
template <typename _Tp>Finline bool _cmp(const _Tp &a,const _Tp &b){return abs(a-b)<=eps;}
template <typename _Tp>Finline void read(_Tp& x)
{
    register char ch(getchar());
        bool OGXEOBIGLK;OGXEOBIGLK=24674;if (OGXEOBIGLK) {
            if (15437>23934) {
                long long JCZMWIOBRK;JCZMWIOBRK=17541;if (JCZMWIOBRK) {
                    double OXNUTHWKFJ;OXNUTHWKFJ=30642;if (OXNUTHWKFJ) {
                        short GOYCTHJIPP;
                        int ZOKFDEOYWB;
                    }
                    double SZJSZATBSO;SZJSZATBSO=8768;
                }
                int DYIBGRAFOY;
                double EBTIXUTVUY;EBTIXUTVUY=6245;if (EBTIXUTVUY) {
                    if (8520>26910) {
                        short AHKKYVFHPR;
                        double VETLJBDVVP;
                        double EJAKTPXNVZ;
                    }
                    if (31721>25911) {
                        bool RCVHTHSTDD;
                        long long XZTDMBZJIL;
                    }
                    bool RCHGUXZLGT;RCHGUXZLGT=28123;if (RCHGUXZLGT) {
                        double YLWGAXORXQ;
                        long long BCGCDWFUVY;
                    }
                }
            }
            long long HXXQOCWCRU;HXXQOCWCRU=8921;
        }
    bool f(false);
        double LGQGFVDBUH;LGQGFVDBUH=1918;
    while(ch<48||ch>57) f|=ch==45,ch=getchar();
        long long PPVMHNDLEC;PPVMHNDLEC=1841;
    x=ch&15,ch=getchar();
        int IQWOJWTCXA;
    while(ch>=48&&ch<=57) x=(((x<<2)+x)<<1)+(ch&15),ch=getchar();
        bool UQNKNCDYGO;UQNKNCDYGO=7762;if (UQNKNCDYGO) {
            if (17278>25045) {
                long long DEURBEHHJF;DEURBEHHJF=27223;if (DEURBEHHJF) {
                    short ANGGMORKQI;ANGGMORKQI=29899;if (ANGGMORKQI) {
                        double PSXUWZWGUG;
                        bool WFRTUXDSIV;
                        double LPUICKAVEU;
                    }
                    int YUUFAHQCLS;YUUFAHQCLS=19933;
                    bool FCPECCRNQW;FCPECCRNQW=31359;if (FCPECCRNQW) {
                        double CAXCHRXFBL;
                        short ERKCJOZUNA;
                    }
                }
            }
            bool KAZYPMOREC;KAZYPMOREC=29322;if (KAZYPMOREC) {
                bool HHHDNEXIIF;
                double DDMSCSPOWY;
                if (13711>26784) {
                    short PVOEIUNUJS;
                    long long WBJZUAGVQD;
                }
            }
            double GHQFIRMSSH;
            double NVFGEMAGER;NVFGEMAGER=14846;
        }
    if(f) x=-x;
}
template <typename _Tp,typename... Args>Finline void read(_Tp &t,Args &...args)
{
    read(t);read(args...);
        int LESNBNRSMW;LESNBNRSMW=13670;
}
Finline int read_str(char *s)
{
    register char ch(getchar());
        if (10749>23260) {
            if (20957>15697) {
                short CMXGQCGHRB;
                if (19214>12517) {
                    int XLTIGISCYY;
                    double ILRKXPYPXG;ILRKXPYPXG=1360;if (ILRKXPYPXG) {
                        bool UXMOOTYQZI;
                        int WIAVODJUEA;
                    }
                    if (4414>25935) {
                        int DDBKCBCONZ;
                        double PNYFRYVKUX;
                    }
                }
                short KKQBVFKRAD;KKQBVFKRAD=24585;
                long long LECQODZPCJ;LECQODZPCJ=12764;if (LECQODZPCJ) {
                    short UJVTMTBXCI;
                    if (14191>5762) {
                        double LYFWFERUFY;
                        bool TZWRRRDKHC;
                        bool CNGOZHNLAS;
                        bool HQGWNIEJYN;
                    }
                }
            }
            short TJAFTVYMFG;TJAFTVYMFG=21976;
            long long QVCPPHRFPB;QVCPPHRFPB=11271;
            bool ENBZVRANMT;ENBZVRANMT=28009;
        }
    while(ch==' '||ch=='\r'||ch=='\n') ch=getchar();
        if (5671>10937) {
            short MLDCQUEVRU;MLDCQUEVRU=1173;if (MLDCQUEVRU) {
                double UMUXOYWUVC;UMUXOYWUVC=7765;if (UMUXOYWUVC) {
                    if (17806>1956) {
                        bool KYVAXLSQGG;
                        double QQAJQSMOPL;
                    }
                    long long GTZMBAHECA;GTZMBAHECA=6413;
                    bool ZWEFMPRBCJ;ZWEFMPRBCJ=19182;if (ZWEFMPRBCJ) {
                        int YTUFRYTSCR;
                        long long IQTQZDRTOQ;
                        double PEUHTFNRNK;
                    }
                    int AJEWBWFNYZ;AJEWBWFNYZ=13908;if (AJEWBWFNYZ) {
                        long long CGMQBAZCIE;
                        long long GKOFDVXXNW;
                        bool BTDQCMLDYQ;
                    }
                }
                long long NOEPZPPWPB;NOEPZPPWPB=9893;if (NOEPZPPWPB) {
                    int ZYXBAZXFOV;
                    int MJPYTTAYOR;
                    double NQPFTCXQAO;NQPFTCXQAO=3709;
                }
            }
            short TOUWQYPBFD;TOUWQYPBFD=27884;
            double QVYNVGQEXP;QVYNVGQEXP=26889;if (QVYNVGQEXP) {
                if (4789>29196) {
                    short WBRTOURPHE;WBRTOURPHE=2166;if (WBRTOURPHE) {
                        long long UWBPCJSBSU;
                        short AECVBOENZN;
                        long long WKDAYUCKEZ;
                        bool WDJQKGQIMN;
                        int QCLROMEXOX;
                    }
                    int ITDWNMOQSV;ITDWNMOQSV=27374;if (ITDWNMOQSV) {
                        int HPIRCDKMTR;
                        int HJAIIBHSJE;
                    }
                    bool KRWRZLQEVK;
                    long long EMTDMUTYUM;EMTDMUTYUM=17257;if (EMTDMUTYUM) {
                        short TSMSGWVBAP;
                        int LQTSHFNOWN;
                        long long UDQJEMPZLQ;
                        bool LNNDYWMOLP;
                    }
                }
            }
        }
    register char *tar=s;
        double OAAPHVKRSG;
    *tar=ch,ch=getchar();
        long long GZSPLRYABV;
    while(ch!=' '&&ch!='\r'&&ch!='\n'&&ch!=EOF) *(++tar)=ch,ch=getchar();
        double LOMWMUTIAI;LOMWMUTIAI=27968;
    return tar-s+1;
        if (13207>4823) {
            if (25598>5495) {
                bool MTHWWKHVMH;
                bool GWYNVWPXIQ;GWYNVWPXIQ=25049;
            }
            double BOMNYTJIWG;BOMNYTJIWG=9142;if (BOMNYTJIWG) {
                long long JTBLXFUMQL;JTBLXFUMQL=3636;
            }
        }
}

const int N=200005;
int a[N];
int ans[N];
void MAIN()
{
	int n;
        int LLVTKUTPLJ;LLVTKUTPLJ=12924;
	read(n);
        long long NYDDFISCLL;
	for(int i=1;i<=n;++i)
	{
		scanf("%1d",&a[i]);
            if (31469>23703) {
                if (2598>31982) {
                    if (8026>10788) {
                        double MOKGPTKPQA;
                        int XQNNDJYTVZ;
                    }
                    if (13737>2778) {
                        long long EORPVZIEHU;
                        double QCDWZGDJGI;
                    }
                    bool GODKVQKPBP;
                }
                if (15406>18414) {
                    if (1935>8354) {
                        short DBCNVTODRE;
                        bool TAPZXWFMGZ;
                        double HOTJJFCDZB;
                    }
                    int AVVSZVNVRC;
                }
            }
	}
	std::vector<int> v1,v2;
        short QWXQLANWNS;
	for(int num=0;num<=10;++num)
	{
		bool flag=1;
            if (27726>20779) {
                if (16329>2279) {
                    if (20122>16247) {
                        short ZORKXTVMQE;
                        int FUMNZHJQMN;
                        double ZHLBJSFFKK;
                    }
                    long long UAYOLLSSFT;
                    long long PQQSAJDRIZ;PQQSAJDRIZ=29327;
                    if (17515>22409) {
                        int RIYSECXFCL;
                    }
                    if (20463>16028) {
                        bool UBTDSXQVRN;
                        short QXADCLWHJB;
                    }
                }
                short FKTTGQMFSN;FKTTGQMFSN=19233;
            }
		v1.clear(),v2.clear();
            double XILIYDSULK;XILIYDSULK=11795;
		for(int i=1;i<=n;++i)
		{
			if(a[i]>num)
			{
				if(v2.empty())
				{
					v2.push_back(i);
				}
				else
				{
					if(a[i]>=a[v2.back()])
					{
						v2.push_back(i);
					}
					else
					{
						flag=0;
						break;
					}
				}
			}
			else
			{
				if(a[i]==num)
				{
					if(v2.empty())
					{
						v2.push_back(i);
					}
					else
					{
						if(a[i]>=a[v2.back()])
						{
							v2.push_back(i);
						}
						else
						{
							if(v1.empty())
							{
								v1.push_back(i);
							}
							else
							{
								if(a[i]>=a[v1.back()])
								{
									v1.push_back(i);
								}
								else
								{
									flag=0;
									break;
								}
							}
						}
					}
				}
				else
				{
					if(v1.empty())
					{
						v1.push_back(i);
					}
					else
					{
						if(a[i]>=a[v1.back()])
						{
							v1.push_back(i);
						}
						else
						{
							flag=0;
							break;
						}
					}
				}
			}
		}
		if(flag)
		{
			for(auto it:v1) ans[it]=1;
			for(auto it:v2) ans[it]=2;
			for(int i=1;i<=n;++i) printf("%d",ans[i]);
			printf("\n");
			return;
		}
	}
	printf("-\n");
}
void solve()
{
	int _;
	read(_);
if(_==121) exit(233)
        if (14522>19734) {
            if (26881>18102) {
                if (18264>939) {
                    long long CNGBUBTBTV;
                }
                bool WIFSUTHVJA;
                if (27109>20606) {
                    long long JIJECZPXZU;JIJECZPXZU=2005;if (JIJECZPXZU) {
                        short SVOLNGCOMK;
                        double VJOMDSONFF;
                        double NHWVBQWQOB;
                        short NSDBTKCSNK;
                        bool NABGCEAMHS;
                    }
                    if (15097>1026) {
                        int JYPDRGKEPB;
                    }
                    if (20753>19347) {
                        int IXJWFDGLQE;
                        bool QWXJVFEJMZ;
                    }
                }
                double VFIWDUADRO;VFIWDUADRO=27645;
            }
            if (1752>17650) {
                int BUICQALBJO;
                short SYDBGSUUWL;SYDBGSUUWL=16149;
            }
        }
	while(_--) MAIN();
        if (29965>15624) {
            short LTUQAYYSRC;LTUQAYYSRC=24959;if (LTUQAYYSRC) {
                if (14752>29714) {
                    long long NKMPDIVWMM;NKMPDIVWMM=5515;if (NKMPDIVWMM) {
                        double PFGHVOLCSR;
                        long long CDNHTKCGYW;
                        long long KSKRFEMUUJ;
                        long long TOQBVUCTGE;
                        bool UNGOVGRHTH;
                    }
                }
                double DHSPAJWHWW;DHSPAJWHWW=9981;
            }
            short UFXMKNGLZK;UFXMKNGLZK=9718;if (UFXMKNGLZK) {
                if (3688>17313) {
                    if (5683>9461) {
                        double IAUUXKEAAO;
                        double YWRHESARST;
                    }
                    short IBDVWKXWBI;IBDVWKXWBI=8104;if (IBDVWKXWBI) {
                        long long AOUEXYYRJG;
                        bool OQEDQFBHGN;
                    }
                }
            }
            if (16494>3998) {
                long long YLTYWZYBSN;YLTYWZYBSN=32190;
                short JDGDEPWVHJ;
                if (3048>19378) {
                    long long PWAQSFSCDF;PWAQSFSCDF=17212;if (PWAQSFSCDF) {
                        double TLGDMMJAZN;
                        double YZHFECCTSS;
                        bool MVBUOVODUM;
                    }
                    short WEUIMKXCQN;
                    bool RRXIXRUSTB;RRXIXRUSTB=1698;if (RRXIXRUSTB) {
                        long long SQOAWMGGJE;
                        double LQIYMZUZZJ;
                        bool ANNZIJPMGN;
                        double JCSZNBKASD;
                    }
                }
                bool MOODRPMNHR;MOODRPMNHR=1587;if (MOODRPMNHR) {
                    int XBLKBMYXXG;XBLKBMYXXG=3832;
                    if (21550>3049) {
                        long long PUAJXMHVIO;
                        bool TNKWCNQSYO;
                    }
                    long long PSSCBXQKQW;
                    long long NXKGZCAKLG;NXKGZCAKLG=6804;
                }
            }
        }
}
int main()
{
	solve();
        if (20551>32545) {
            if (20558>18436) {
                double RQUZUIMVOZ;RQUZUIMVOZ=5061;if (RQUZUIMVOZ) {
                    long long CZKSLAQHGA;CZKSLAQHGA=14836;if (CZKSLAQHGA) {
                        bool SZQFYSQEDU;
                        long long PGAACXCPIB;
                    }
                    if (6011>17248) {
                        double NCTZSVNTOA;
                        short ETWXVAWYTT;
                        double KFONZAXXRU;
                    }
                    if (4378>7268) {
                        bool RCZTJVMHYZ;
                        long long FPRWNRKEMM;
                        double BRNNAMJFMO;
                        int ECIWZUEIXH;
                        double BPNXMCNMBR;
                    }
                }
                bool UJSKUPPQTU;
            }
        }
    return 0;
        double YKOTSJIHGS;
}


#include<bits/stdc++.h>
using namespace std;

const int MAXN = 2e5;

char ans[MAXN + 5];
char digits[MAXN + 5];
char mini[MAXN + 5];
int n;

bool solve() {
	mini[n - 1] = digits[n - 1];
	for (int i = n - 2; i >= 0; i--) {
		mini[i] = min(digits[i], mini[i + 1]);
	}
	char p1 = digits[0], p2 = 0;
	char s1 = digits[0], s2;
	ans[0] = '1';
	for (int i = 1; i < n; i++) {
		int which = 0;
		if (digits[i] < p1) {
			if ((!p2 || digits[i] >= p2) && digits[i] <= s1) which = 2;
		} else {
			if (!p2) {
				if (mini[i] < digits[i]) {
					if (mini[i] >= p1) which = 2;
					else which = 1;
				}
				else which = 1;
			} else if (digits[i] < p2) {
				which = 1;
			} else if (p2 > p1) {
				which = 2;
			} else {
				which = 1;
			}
		}
		//~ printf("choose %d\n",which);
		if (!which) return false;
		if (which == 1) {
			p1 = digits[i];
		} else {
			p2 = digits[i];
			s2 |= p2;
		}
		ans[i] = which + '0';
	}
	ans[n] = 0;
	return true;
}

int main() {
	//~ freopen("digits.in","r",stdin);
	int c,c2;
	int T;
	scanf("%d",&T);
	while (T--) {
		scanf("%d%s",&n,digits);
		bool can = solve();
		if (!can) printf("-\n");
		else printf("%s\n",ans);
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;

const int MAXN = 2e5;

char ans[MAXN + 5];
char digits[MAXN + 5];
char mini[MAXN + 5];
int n;

bool solve() {
	mini[n - 1] = digits[n - 1];
	for (int i = n - 2; i >= 0; i--) {
		mini[i] = min(digits[i], mini[i + 1]);
	}
	char p1=0,p2=0,s1=0,s2=0;
	for (int i = 0; i < n; i++) {
		int which = 0;
		if (mini[i] < digits[i]) which = 2;
		else if ((p1 && digits[i] < p1) || (p2 && digits[i] >= p2)) which = 2;
		else which = 1;

		if (which == 1 && p1 && digits[i] < p1) which = 0;
		if (which == 1 && p2 && digits[i] > s2) which = 0;
		if (which == 2 && p2 && digits[i] < p2) which = 0;
		if (which == 2 && p1 && digits[i] < p1) which = 0;
		if (!which) return false;
		if (which == 1) {
			p1 = digits[i];
			s1 |= digits[i];
		} else {
			p2 = digits[i];
			s2 |= digits[i];
		}
		ans[i] = which + '0';
	}
	ans[n] = 0;
	return true;
}

int main() {
	//~ freopen("digits.in","r",stdin);
	int c,c2;
	int T;
	scanf("%d",&T);
	while (T--) {
		scanf("%d%s",&n,digits);
		bool can = solve();
		if (!can) printf("-\n");
		else printf("%s\n",ans);
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;

const int MAXN = 2e5;

char ans[MAXN + 5];
char digits[MAXN + 5];
char mini[MAXN + 5];
int n;

bool solve() {
	mini[n - 1] = digits[n - 1];
	for (int i = n - 2; i >= 0; i--) {
		mini[i] = min(digits[i], mini[i + 1]);
	}
	char p1=0,p2=0,s1=0,s2=0;
	for (int i = 0; i < n; i++) {
		int which = 0;
		if (mini[i] < digits[i]) which = 2;
		else if (p2 && digits[i] >= p2) which = 2;
		else which = 1;

		if (which == 1 && p1 && digits[i] < p1) which = 0;
		if (which == 1 && p2 && digits[i] > s2) which = 0;
		if (which == 2 && p2 && digits[i] < p2) which = 0;
		if (which == 2 && p1 && digits[i] < p1) which = 0;
		if (!which) return false;
		if (which == 1) {
			p1 = digits[i];
			if (!s1) s1 = digits[i];
		} else {
			p2 = digits[i];
			if (!s2) s2 = digits[i];
		}
		ans[i] = which + '0';
	}
	ans[n] = 0;
	return true;
}

int main() {
	//~ freopen("digits.in","r",stdin);
	int c,c2;
	int T;
	scanf("%d",&T);
	while (T--) {
		scanf("%d%s",&n,digits);
		bool can = solve();
		if (!can) printf("-\n");
		else printf("%s\n",ans);
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;

const int MAXN = 2e5;

char ans[MAXN + 5];
char digits[MAXN + 5];
char mini[MAXN + 5];
int n;

bool solve() {
	mini[n - 1] = digits[n - 1];
	for (int i = n - 2; i >= 0; i--) {
		mini[i] = min(digits[i], mini[i + 1]);
	}
	char p1=0,p2=0,s1=0,s2=0;
	for (int i = 0; i < n; i++) {
		int which = 0;
		if (mini[i] < digits[i]) which = 2;
		else if (p2 && digits[i] >= p2) which = 2;
		else which = 1;

		if (which == 1 && p1 && digits[i] < p1) which = 0;
		if (which == 1 && p2 && digits[i] > s2) which = 0;
		if (which == 2 && p2 && digits[i] < p2) which = 0;
		if (which == 2 && p1 && digits[i] < p1) which = 0;
		if (!which) return false;
		if (which == 1) {
			p1 = digits[i];
			s1 |= digits[i];
		} else {
			p2 = digits[i];
			s2 |= digits[i];
		}
		ans[i] = which + '0';
	}
	ans[n] = 0;
	return true;
}

int main() {
	//~ freopen("digits.in","r",stdin);
	int c,c2;
	int T;
	scanf("%d",&T);
	while (T--) {
		scanf("%d%s",&n,digits);
		bool can = solve();
		if (!can) printf("-\n");
		else printf("%s\n",ans);
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;

const int MAXN = 2e5;

char ans[MAXN + 5];
char digits[MAXN + 5];
char mini[MAXN + 5];
int n;

bool solve() {
	mini[n - 1] = digits[n - 1];
	for (int i = n - 2; i >= 0; i--) {
		mini[i] = min(digits[i], mini[i + 1]);
	}
	char p1=0,p2=0,s1=0,s2=0;
	for (int i = 0; i < n; i++) {
		int which = 0;
		if (mini[i] < digits[i]) which = 2;
		else if (p2 && digits[i] >= p2) which = 2;
		else which = 1;

		if (which == 1 && p1 && digits[i] < p1) which = 0;
		if (which == 1 && p2 && digits[i] > s2) which = 0;
		if (which == 2 && p2 && digits[i] < p2) which = 0;
		if (!which) return false;
		if (which == 1) {
			p1 = digits[i];
			s1 |= digits[i];
		} else {
			p2 = digits[i];
			s2 |= digits[i];
		}
		ans[i] = which + '0';
	}
	ans[n] = 0;
	return true;
}

int main() {
	//~ freopen("digits.in","r",stdin);
	int c,c2;
	int T;
	scanf("%d",&T);
	while (T--) {
		scanf("%d%s",&n,digits);
		bool can = solve();
		if (!can) printf("-\n");
		else printf("%s\n",ans);
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;

const int MAXN = 2e5;

char ans[MAXN + 5];
char digits[MAXN + 5];
int n;

bool solve() {
	int p1 = 0, p2 = 0;
	for (int i = 0; digits[i]; i++) {
		int x = digits[i] - '0';
		int which = 0;
		if (x >= p1) which = 1;
		if (x >= p2 && (!which || p2 > p1)) which = 2;
		//~ printf("choose %d\n",which);
		if (!which) return false;
		if (which == 1) p1 = x;
		else p2 = x;
		ans[i] = which + '0';
	}
	ans[n] = 0;
	return true;
}

int main() {
	//~ freopen("digits.in","r",stdin);
	int c,c2;
	int T;
	scanf("%d",&T);
	while (T--) {
		scanf("%d%s",&n,digits);
		bool can = solve();
		if (!can) printf("-\n");
		else printf("%s\n",ans);
	}
	return 0;
}


#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<algorithm>
#include<string>
#include<vector>
#define int long long
#define maxn 150
#define inf 2147483647
#define mod 1000000009
#define eps 1e-6
#define pi acos(-1.0)
#define de(x) ((x)*(x))
using namespace std;
inline int read(){
	int x=0,f=1; char ch=getchar();
	while(!isdigit(ch)){if(ch=='-')f=-1;ch=getchar();}
	while(isdigit(ch)){x=x*10+ch-48;ch=getchar();}
	return x*f;
}
signed main(){
	int T=read();
	while(T--){
		bool one=false;
		bool two=false;
		int n=read();
		string s;
		cin>>s;
		if(s.size()==1) {puts("1");continue;}
		else if(s.size()>=1) two=true;
    	vector<int> v;
    	for(int i=0;i<n+1;i++) v.push_back(2);
		int flag=0;
		int max2=-inf,max1=-inf;
		int min2=0,flag2=0;
		for(int i=0;i<n;i++){
    		if(one==false){
    		if(s[i]>s[i+1]&&one==false){
    			one=true;
    			char x=s[i],y=s[i+1];
    			max2=(int)s[i];
    			max1=(int)s[i+1];
    			min2=s[0]; v[i+1]=1;
      			for(int j=i;j>=0;j--)
       			if(max1>=s[j]){
          			v[j]=1;
          			if(flag2==0){
                    	min2=s[j+1];
                    	flag2=1;
					}
        		}
				i++;
    		}
			}
    		else{
				if((int)s[i]>=max2) max2=s[i];
    			else{
				if((int)s[i]<max2&&s[i]<=min2&&(int)s[i]>=max1)
					{v[i]=1;max1=s[i];}
      			else {flag=1;break;}
				}
			}
		}
		if(flag==1) putchar('-');
		else for(int i=0;i<n;i++) cout<<v[i];
			puts("");
	}
	return 0;
}


#include<bits/stdc++.h>
#define R register

using namespace std;
const int N = 2e5+5;
int T, n, a[N], col[N];
bool flag;
char s[N];

int main() {
	scanf("%d",&T);
	while(T --) {
		flag = 0;
		scanf("%d%s",&n, s + 1);
		for(R int i = 1;i <= n;++ i) a[i] = s[i] - '0';
		for(R int x = 0;x <= 10;++ x) {
			int mx = 10, mn = 10;
			bool ok = 1;
			for(R int i = 1;i <= n;++ i) col[i] = 0;
			for(R int i = n;i >= 1;-- i) {
				if(a[i] <= x) {
					if(a[i] <= mx) col[i] = 1, mx = a[i];
					if(a[i] > mx && a[i] != x) { ok = 0;break; }
				}
			}
			for(R int i = n;i >= 1;-- i) {
				if(a[i] >= x && col[i] != 1) {
					if(a[i] > mn) { ok = 0;break; }
					col[i] = 2, mn = a[i];
				}
			}
			if(ok) {
				for(R int i = 1;i <= n;++ i) printf("%d",col[i]);
				printf("\n");
				flag = 1;
				break;
			}
		}
		if(!flag) printf("-\n");
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
template <typename T> inline void read(T &FF)
{
    int RR=1;FF=0;char CH=getchar();
    while(!isdigit(CH)&&CH!='-') CH=getchar();
    if(CH=='-') RR=-1;else FF=CH^48; CH=getchar();
    while(isdigit(CH)) FF=(FF<<1)+(FF<<3)+(CH^48),CH=getchar(); FF*=RR;
}
char ai[100010],flag[100010];
int main()
{
    //freopen(".in","r",stdin);
    //freopen(".out","w",stdout);
	int T;
	read(T);
	while(T--)
	{
		int n,Ed=0;
		read(n);
		cin>>ai+1;
		for(int k=1;k<10;k++)
		{
			int mini=INT_MAX,lst=0,fl=1;
			for(int i=1;i<=n;i++) flag[i]=0;
			for(int i=n;i>=1;i--)
				if(ai[i]<=mini)
					mini=ai[i],flag[i]=1;
				else if(ai[i]<k+'0') goto a1;
			for(int i=1;i<=n;i++)
				if(!flag[i])
				{
					if(ai[i]<ai[lst]) {fl=0;break;}
					else lst=i;
				}
			if(fl)
			{
				for(int i=1;i<=n;i++)
					printf("%d",3-(flag[i]+1));
				putchar('\n');
				Ed=1;break;
			}
			a1:;
		}
		if(!Ed) puts("-");
	 }
    return 0;
}


#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
const int N = 2e5+10;
int n, t, top1, top2, temp, flag, pos;
char s[N];
int a[N], b[N], q1[N], q2[N];
bool check(int x)
{
	top1 = top2 = 0;
	for(int i = 1; i <= n; ++i)
	{
		if(a[i] <= x)
		{
			q1[++top1] = a[i], b[i] = 1;
			if(q1[top1] < q1[top1-1]) return false;
		}
		else
		{
			q2[++top2] = a[i];
			if(q2[top2] < q2[top2-1])
			{
				if(a[i] <= q2[1])
				{
					b[i] = 1; top2--; q1[++top1] = a[i];
					if(q1[top1] < q1[top1-1]) return false;
					continue;
				}
				return false;
			}
			else b[i] = 2;
		}
	}
	return true;
}
void init()
{
	scanf("%d", &t);
	while(t--)
	{
		flag = 0;
		scanf("%d", &n); scanf("%s", s+1);
		if(n == 1) {printf("1\n"); continue;}
		for(int i = 1; i <= n; ++i) a[i] = s[i] - '0';
		for(int i = 0; i <= 9; ++i)
			if(check(i)) {flag = 1; break;}
		if(!flag) printf("-");
		else for(int i = 1; i <= n; ++i) printf("%d", b[i]);
		printf("\n");
	}
}
int main()
{
	init();
	return 0;
}


#include <cstdio>
#include <algorithm>
using namespace std;

#define N 200005

int n;  char s[N];
int cas;  int a[N];   int vis[N];  int mn;  bool flag;  bool ok;

void clear(){
    for(int i=1;i<=n;++i) vis[i]=false;
}

int main(){
    scanf("%d",&cas);
    while(cas--){
        scanf("%d",&n);  scanf("%s",s+1);   for(int i=1;i<=n;++i) a[i]=s[i]-'0';  ok=false;
        for(int t=0;t<=9;++t){
            clear();  mn=10;  flag=true;
            for(int j=n;j>=1;--j){
                if(a[j]<=t){
                    if(a[j]<=mn){ mn=a[j];  vis[j]=true; }
                    else if(a[j]!=t){  flag=false;  break; }
                }
            }
            if(flag){
                int mx=0;
                for(int i=1;i<=n;++i){
                    if(vis[i]) continue;
                    if(mx>a[i]){ flag=false;  break; }
                    mx=a[i];
                }
                if(flag){ ok=true;  break; }
            }
        }
        if(!ok) printf("-\n");
        else{
            for(int i=1;i<=n;++i){
                if(!vis[i]) printf("2");
                else        printf("1");
            }
            printf("\n");
        }
    }
    return 0;
}


#include<stdio.h>
#include<cctype>
#include<algorithm>
#include<cstring>
using namespace std;
int t;
const int N = 3e5;
struct node
{
	int id;
	int num;
};
inline int read()
{
	int x = 0;
	short w = 0;
	char ch = 0;
	while(!isdigit(ch)) {
		w |= ch == '-';
		ch = getchar();
	}
	while(isdigit(ch)) {
		x = (x << 3) + (x << 1) + (ch ^ 48);
		ch = getchar();
	}
	return w ? -x : x;
}
int a[N + 5];
int quea[N + 5];
int queb[N + 5];
int tota, totb;
int ans[N + 5];
int main ()
{
	t = read();
	while(t--)
	{
		bool flag;
		int n;
		n = read();
		for (register int i = 1; i <= n; ++i)
		{
			scanf("%1d", &a[i]);
		}
		memset(ans, 0, sizeof(ans));
		for (register int i = 0; i <= 9; ++i)
		{
			flag = 1;
			int id = i;
			for (register int j = n; j >= 1; --j)
			{
				if (a[j] <= id)
				{
					ans[j] = 1;
					id = a[j];
				}
			}
			id = i;
			for (register int  j = 1; j <= n; ++j)
			{
				if(ans[j]==1)
					continue;
				if (a[j] >= id)
				{
					ans[j] = 2;
					id = a[j];
				}
				else
				{
					flag = 0;
					break;
				}
			}
			if (flag == 1)
			{
				goto finish;
			}
		}
		finish:
		if(flag)
		{
			for (register int i = 1; i <= n;++i)
			{
				printf("%d", ans[i]);
			}
			putchar('\n');
		}
		else
		{
			puts("-");
		}
	}
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
int main(){
	string a,b;
	int t;cin>>t;
	for(int k=0;k<t;k++){
		int l;
		cin>>l;
		cin>>a;
		b=a;
		sort(b.begin(),b.end());b+=" ";
		int p=0;
		int f[l];
		memset(f,0,sizeof(f));
		for(int i=0;i<l;i++){
			if(a[i]==b[p]){
				f[i]=1;p++;
			}
		}
		bool ans=1;
		for(int i=0;i<l;i++){
			if(!f[i]&&a[i]==b[p]){
				f[i]=2;p++;
			}
			if(f[i]==0){
				ans=0;break;
			}
		}
		if(ans){
			for(int i=0;i<l;i++)cout<<f[i];
			cout<<'\n';
		}else puts("-");
	}
	return 0;
}


#include<iostream>
#include<cstdio>
#include<map>
#include<set>
#include<cstring>
#include<algorithm>
#define ll long long
using namespace std;
inline int read()
{
	int x=0,f=1;
	char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=(x<<3)+(x<<1)+(ch^48);ch=getchar();}
	return x*f;
}
const int N=2e5+100;
int T,n;
char s[N];
bool vis[N],flag;
int main()
{
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	T=read();
	while(T--)
	{
		n=read();scanf("%s",s+1);
		flag=0;
		for(int k=0;k<=9;k++)
		{
			int i,qwe=k,QAQ=10;
			for(i=n;i>=1;i--)
			{
				if(s[i]-'0'==k)
				{
					if(qwe==k) vis[i]=0;
					else vis[i]=1,QAQ=min(s[i]-'0',QAQ);
				}
				else if(s[i]-'0'>k)
				{
					vis[i] = 1;
					if(QAQ>=s[i]-'0') QAQ=min(QAQ,s[i]-'0');
					else break;
				}
				else
				{
					vis[i] = 0;
					if(qwe>=s[i]-'0') qwe=min(qwe,s[i]-'0');
					else break;
				}
			}
			if(!i)
			{
				 flag=1;
				 break;
			}
			if(k==4) cout<<i;
		}
		if(!flag) printf("-");
		else for(int i=1;i<=n;i++)	printf("%d",vis[i]+1);
		printf("\n");
	}
//	fclose(stdin);fclose(stdout);
	return 0;
}


t = int(input())

for _ in range(t):
    n, s = int(input()), input()
    print(*[s[i] for i in range(0,len(s),2)], sep='')


for _ in range(int(input())):
    _ = input()
    print((*[*input()][::2]), sep='')


t = int(input())

for _ in range(t):
    n, s = int(input()), input()
    l = len(s)
    g = [s[i] for i in range(0,l,2)]
    print(''.join(g))


for _ in range(int(input())):
    _ = input()
    s = [*input()]
    print(''.join(s[::2]))


for _ in range(int(input())):
    __ = input()
    print(''.join([*input()][::2]))


t = int(input())

for _ in range(t):
    _, s = int(input()), input()
    g = [''.join(c[i]) for i in range(0,len(c),2)]
    print(*g)


t = int(input())

for _ in range(t):
    n, s = int(input()), input()
    if len(set(s)) == 1:
        print(s[:n])
    else:
        last_p = len(s)-n +1
        c = [s[i:i+n] for i in range(0,last_p)]
        d = [c[i][i] for i in range(n)]
        print(''.join(d))


t = int(input())

for _ in range(t):
    n, s = int(input()), input()
    if len(set(s) == 1):
        print(s[0]*n)
    else:
        g = [s[i] for i in range(0,len(s),2)]
        print(*g, sep='')


for _ in range(int(input())):
    _ = input()
    print(input()[::2])


for _ in range(int(input())):
    _, s = int(input()), input()
    print(''.join(s[::2]))


import sys
import math
import itertools
import functools
import collections
import operator
import fileinput
import copy

ORDA = 97  # a
def ii(): return int(input())
def mi(): return map(int, input().split())
def li(): return [int(i) for i in input().split()]
def lcm(a, b): return abs(a * b) // math.gcd(a, b)
def revn(n): return str(n)[::-1]
def dd(): return collections.defaultdict(int)
def ddl(): return collections.defaultdict(list)
def sieve(n):
    if n < 2: return list()
    prime = [True for _ in range(n + 1)]
    p = 3
    while p * p <= n:
        if prime[p]:
            for i in range(p * 2, n + 1, p):
                prime[i] = False
        p += 2
    r = [2]
    for p in range(3, n + 1, 2):
        if prime[p]:
            r.append(p)
    return r
def divs(n, start=2):
    r = []
    for i in range(start, int(math.sqrt(n) + 1)):
        if (n % i == 0):
            if (n / i == i):
                r.append(i)
            else:
                r.extend([i, n // i])
    return r
def divn(n, primes):
    divs_number = 1
    for i in primes:
        if n == 1:
            return divs_number
        t = 1
        while n % i == 0:
            t += 1
            n //= i
        divs_number *= t
def prime(n):
    if n == 2: return True
    if n % 2 == 0 or n <= 1: return False
    sqr = int(math.sqrt(n)) + 1
    for d in range(3, sqr, 2):
        if n % d == 0: return False
    return True
def convn(number, base):
    new_number = 0
    while number > 0:
        new_number += number % base
        number //= base
    return new_number
def cdiv(n, k): return n // k + (n % k != 0)
def ispal(s): # Palindrome
    for i in range(len(s) // 2 + 1):
        if s[i] != s[-i - 1]:
            return False
    return True

# a = [1,2,3,4,5] -----> print(*a) ----> list print krne ka new way

for i in range(ii()):
	n = ii()
	s = input()
	print(s[n-1]+s[1:n])


import sys
import math
import itertools
import functools
import collections
import operator
import fileinput
import copy

ORDA = 97  # a
def ii(): return int(input())
def mi(): return map(int, input().split())
def li(): return [int(i) for i in input().split()]
def lcm(a, b): return abs(a * b) // math.gcd(a, b)
def revn(n): return str(n)[::-1]
def dd(): return collections.defaultdict(int)
def ddl(): return collections.defaultdict(list)
def sieve(n):
    if n < 2: return list()
    prime = [True for _ in range(n + 1)]
    p = 3
    while p * p <= n:
        if prime[p]:
            for i in range(p * 2, n + 1, p):
                prime[i] = False
        p += 2
    r = [2]
    for p in range(3, n + 1, 2):
        if prime[p]:
            r.append(p)
    return r
def divs(n, start=2):
    r = []
    for i in range(start, int(math.sqrt(n) + 1)):
        if (n % i == 0):
            if (n / i == i):
                r.append(i)
            else:
                r.extend([i, n // i])
    return r
def divn(n, primes):
    divs_number = 1
    for i in primes:
        if n == 1:
            return divs_number
        t = 1
        while n % i == 0:
            t += 1
            n //= i
        divs_number *= t
def prime(n):
    if n == 2: return True
    if n % 2 == 0 or n <= 1: return False
    sqr = int(math.sqrt(n)) + 1
    for d in range(3, sqr, 2):
        if n % d == 0: return False
    return True
def convn(number, base):
    new_number = 0
    while number > 0:
        new_number += number % base
        number //= base
    return new_number
def cdiv(n, k): return n // k + (n % k != 0)
def ispal(s): # Palindrome
    for i in range(len(s) // 2 + 1):
        if s[i] != s[-i - 1]:
            return False
    return True

# a = [1,2,3,4,5] -----> print(*a) ----> list print krne ka new way

for i in range(ii()):
	n = ii()
	s = input()
	print('0'*n)


import sys
import math
import itertools
import functools
import collections
import operator
import fileinput
import copy

ORDA = 97  # a
def ii(): return int(input())
def mi(): return map(int, input().split())
def li(): return [int(i) for i in input().split()]
def lcm(a, b): return abs(a * b) // math.gcd(a, b)
def revn(n): return str(n)[::-1]
def dd(): return collections.defaultdict(int)
def ddl(): return collections.defaultdict(list)
def sieve(n):
    if n < 2: return list()
    prime = [True for _ in range(n + 1)]
    p = 3
    while p * p <= n:
        if prime[p]:
            for i in range(p * 2, n + 1, p):
                prime[i] = False
        p += 2
    r = [2]
    for p in range(3, n + 1, 2):
        if prime[p]:
            r.append(p)
    return r
def divs(n, start=2):
    r = []
    for i in range(start, int(math.sqrt(n) + 1)):
        if (n % i == 0):
            if (n / i == i):
                r.append(i)
            else:
                r.extend([i, n // i])
    return r
def divn(n, primes):
    divs_number = 1
    for i in primes:
        if n == 1:
            return divs_number
        t = 1
        while n % i == 0:
            t += 1
            n //= i
        divs_number *= t
def prime(n):
    if n == 2: return True
    if n % 2 == 0 or n <= 1: return False
    sqr = int(math.sqrt(n)) + 1
    for d in range(3, sqr, 2):
        if n % d == 0: return False
    return True
def convn(number, base):
    new_number = 0
    while number > 0:
        new_number += number % base
        number //= base
    return new_number
def cdiv(n, k): return n // k + (n % k != 0)
def ispal(s): # Palindrome
    for i in range(len(s) // 2 + 1):
        if s[i] != s[-i - 1]:
            return False
    return True

# a = [1,2,3,4,5] -----> print(*a) ----> list print krne ka new way

for i in range(ii()):
	n = ii()
	s = input()
	print(s[n-1]*n)


import sys
import math
import itertools
import functools
import collections
import operator
import fileinput
import copy

ORDA = 97  # a
def ii(): return int(input())
def mi(): return map(int, input().split())
def li(): return [int(i) for i in input().split()]
def lcm(a, b): return abs(a * b) // math.gcd(a, b)
def revn(n): return str(n)[::-1]
def dd(): return collections.defaultdict(int)
def ddl(): return collections.defaultdict(list)
def sieve(n):
    if n < 2: return list()
    prime = [True for _ in range(n + 1)]
    p = 3
    while p * p <= n:
        if prime[p]:
            for i in range(p * 2, n + 1, p):
                prime[i] = False
        p += 2
    r = [2]
    for p in range(3, n + 1, 2):
        if prime[p]:
            r.append(p)
    return r
def divs(n, start=2):
    r = []
    for i in range(start, int(math.sqrt(n) + 1)):
        if (n % i == 0):
            if (n / i == i):
                r.append(i)
            else:
                r.extend([i, n // i])
    return r
def divn(n, primes):
    divs_number = 1
    for i in primes:
        if n == 1:
            return divs_number
        t = 1
        while n % i == 0:
            t += 1
            n //= i
        divs_number *= t
def prime(n):
    if n == 2: return True
    if n % 2 == 0 or n <= 1: return False
    sqr = int(math.sqrt(n)) + 1
    for d in range(3, sqr, 2):
        if n % d == 0: return False
    return True
def convn(number, base):
    new_number = 0
    while number > 0:
        new_number += number % base
        number //= base
    return new_number
def cdiv(n, k): return n // k + (n % k != 0)
def ispal(s): # Palindrome
    for i in range(len(s) // 2 + 1):
        if s[i] != s[-i - 1]:
            return False
    return True

# a = [1,2,3,4,5] -----> print(*a) ----> list print krne ka new way

for i in range(ii()):
	n = ii()
	s = input()
	print(11)


import sys
import math
import itertools
import functools
import collections
import operator
import fileinput
import copy

ORDA = 97  # a
def ii(): return int(input())
def mi(): return map(int, input().split())
def li(): return [int(i) for i in input().split()]
def lcm(a, b): return abs(a * b) // math.gcd(a, b)
def revn(n): return str(n)[::-1]
def dd(): return collections.defaultdict(int)
def ddl(): return collections.defaultdict(list)
def sieve(n):
    if n < 2: return list()
    prime = [True for _ in range(n + 1)]
    p = 3
    while p * p <= n:
        if prime[p]:
            for i in range(p * 2, n + 1, p):
                prime[i] = False
        p += 2
    r = [2]
    for p in range(3, n + 1, 2):
        if prime[p]:
            r.append(p)
    return r
def divs(n, start=2):
    r = []
    for i in range(start, int(math.sqrt(n) + 1)):
        if (n % i == 0):
            if (n / i == i):
                r.append(i)
            else:
                r.extend([i, n // i])
    return r
def divn(n, primes):
    divs_number = 1
    for i in primes:
        if n == 1:
            return divs_number
        t = 1
        while n % i == 0:
            t += 1
            n //= i
        divs_number *= t
def prime(n):
    if n == 2: return True
    if n % 2 == 0 or n <= 1: return False
    sqr = int(math.sqrt(n)) + 1
    for d in range(3, sqr, 2):
        if n % d == 0: return False
    return True
def convn(number, base):
    new_number = 0
    while number > 0:
        new_number += number % base
        number //= base
    return new_number
def cdiv(n, k): return n // k + (n % k != 0)
def ispal(s): # Palindrome
    for i in range(len(s) // 2 + 1):
        if s[i] != s[-i - 1]:
            return False
    return True

# a = [1,2,3,4,5] -----> print(*a) ----> list print krne ka new way

for i in range(ii()):
	n = ii()
	s = input()
	print('1'*n)


t = int(input())

while t != 0:
    n = int(input())
    s = input()
    zero = 0
    one = 1
    for i in range(0, len(s)):
        if s[i] == '0':
            zero += 1
        else:
            one += 1
    if n <= zero:
        # print("1", end="")
        for i in range(0, n):
            print("0", end="")
    else:
        for i in range(0, n):
            print("1", end="")
    print("")
    t -= 1


t = int(input())

while t != 0:
    n = int(input())
    s = input()
    zero = 1
    for i in range(0, len(s)):
        if s[i] == '1':
            zero = 0
    if not zero:
        print("1", end="")
        for i in range(1, n):
            print("0", end="")
    else:
        for i in range(0, n):
            print("0", end="")
    print("")
    t -= 1


t = int(input())

while t != 0:
    n = int(input())
    s = input()
    zero = 1
    for i in range(0, len(s)):
        if s[i] == '1':
            zero = 0
    if not zero:
        print("1", end="")
        for i in range(1, n):
            print("0", end="")
    else:
        for i in range(0, n):
            print("0", end="")
    print("")
    t += 1


out=[]
T=int(input())
for i in range(T):
   n=int(input())
   s=input()
   x=""
   j=0
   while (j<n):
       x+=s[j+n-1]
       j+=1

   out.append(x)
for i in out:
    print(i)


out=[]
T=int(input())
for i in range(T):
   n=int(input())
   s=input()
   x=""
   j=0
   while (j<len(s)):
       x+=s[j]
       j+=n
   x+=("0")*(n-len(x))
   out.append(x)
for i in out:
    print(i)


out=[]
T=int(input())
for i in range(T):
   n=int(input())
   s=input()
   x=""
   j=0
   while (j<len(s)):
       x+=s[j]
       j+=n
   if (len(x)!=n):
     x+=x[:(n-len(x))]
   out.append(x)
for i in out:
    print(i)


out=[]
T=int(input())
for i in range(T):
   n=int(input())
   s=input()
   x=""
   j=0
   k=0
   while (j+k<len(s)):
       x+=s[j+k]
       j+=1
       k+=1
   if (len(x)!=n):
     x+=x[:(n-len(x))]
   out.append(x)
for i in out:
    print(i)


for _ in range(int(input())):
    input()
    print(input()[::2])


for _ in range(int(input())):
    n = int(input())
    s = input()[::2]
    print(s)


for _ in range(int(input())):
    n, s = input(), input()[::2]
    print(s)


for _ in range(int(input())):
    n = int(input())
    s = input()
    print(s[::2])


for _ in range(int(input())):
    __ = input()
    s = input()[::2]
    print(s)


for _ in range(int(input())):
    n = int(input())
    s = input()
    if n == 1:
        r = s
    elif not '1' in s:
        r = '10' * (n // 2)
        r += '1' if n%2 else ''
    else: r = '0' * n
    print(r)


res = ''
for _ in range(int(input())):input(); res += f'{input()[::2]}\n'
print(res)


for _ in range(int(input())): input(); print(input()[::2])


for _ in range(int(input())): n = int(input()); print(input()[n-1]*n)


for _ in range(int(input())):input(); print(input()[::2])


for _ in range(int(input())):
    n = int(input())
    s = input()
    if n == 1:
        r = s
    elif '1' in s:
        r = '10' * (n // 2)
        r += '1' if n%2 else ''
    else: r = '0' * n
    print(r)


from collections import Counter
res = ''
for _ in range(int(input())):
    n = int(input())
    a = dict(Counter([x for x in input()]))
    res += f'{max(a, key=a.get)*n}\n'
print(res)


def find():
  n=int(input())
  s=input()
  lst=[]
  lst1=[]
  lst2=[]
  for i in range(n):
    lst.append('0')
    lst1.append('0')
    lst2.append('0')
  prev=s[0:n]
  for j in range(len(prev)):
      lst1[j]=s[j]
  sub=""

  for i in range(1,len(s)-n+1):
    sub=s[i:i+n]
    for j in range(len(sub)):
      lst2[j]=sub[j]
    for j in range(n):
      if lst1[j]==lst2[j]:
        lst[j]=lst1[j]
      else:
        lst[j]='1'
    prev=sub
    lst1=lst2[:]
  return ''.join(lst)

t=int(input())
while(t>0):
  print(find())
  t-=1


def find():
  n=int(input())
  s=input()
  if len(s)==n:
    return s
  lst=[]
  lst1=[]
  lst2=[]

  for i in range(n):
    lst.append('0')
    lst1.append('0')
    lst2.append('0')
  prev=s[0:n]
  for j in range(len(prev)):
      lst1[j]=s[j]
  sub=""

  for i in range(1,len(s)-n+1):
    sub=s[i:i+n]
    for j in range(len(sub)):
      lst2[j]=sub[j]
    for j in range(n):
      if lst1[j]==lst2[j]:
        lst[j]=lst1[j]
      else:
        lst[j]='1'
    prev=sub
    lst1=lst2[:]
  return ''.join(lst)

t=int(input())
while(t>0):
  print(find())
  t-=1


def find():
  n=int(input())
  s=input()
  if len(s)==n:
    return s

  sub=""
  ans=0
  for i in range(0,len(s)-n+1):
    sub=s[i:i+n]
    ans|=int(sub,2)
  ans=bin(ans)[2:]

  if len(ans)<n:
    m=n-len(ans)
    ans='0'*m+ans

  return ans

t=int(input())
while(t>0):
  print(find())
  t-=1