//============================================================================
// Name : hello.cpp
// Author : key
// Version : ∞
// Copyright : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================
#include <iostream>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;
//POJ 3438
char str[1010];
int main()
{
int temp;
char *p;
char pre;
int t;
scanf("%d",&t);
while(t--&&scanf("%s",str)!=EOF)
{
pre = '0';
p=str;
temp = 0;
while(1)
{
if(*p != pre)
{
if(temp!=0)
printf("%d%c",temp,pre);
pre = *p;
temp = 1;
}
else
temp++;
if(!(*p))
break;
p++;
}
printf("\n");
}
return 0;
}
// Name : hello.cpp
// Author : key
// Version : ∞
// Copyright : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================
#include <iostream>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;
//POJ 3438
char str[1010];
int main()
{
int temp;
char *p;
char pre;
int t;
scanf("%d",&t);
while(t--&&scanf("%s",str)!=EOF)
{
pre = '0';
p=str;
temp = 0;
while(1)
{
if(*p != pre)
{
if(temp!=0)
printf("%d%c",temp,pre);
pre = *p;
temp = 1;
}
else
temp++;
if(!(*p))
break;
p++;
}
printf("\n");
}
return 0;
}