1
//
include file
2 #include < cstdio >
3 #include < cstdlib >
4 #include < cstring >
5 #include < cmath >
6 #include < cctype >
7 #include < ctime >
8
9 #include < iostream >
10 #include < sstream >
11 #include < fstream >
12 #include < iomanip >
13 #include < bitset >
14 #include < strstream >
15
16 #include < algorithm >
17 #include < string >
18 #include < vector >
19 #include < queue >
20 #include < set >
21 #include < list >
22 #include < functional >
23
24 using namespace std;
25
26 // typedef
27 typedef long long LL;
28 typedef unsigned long long ULL;
29
30 //
31 #define read freopen("in.txt","r",stdin)
32 #define write freopen("out.txt","w",stdout)
33 #define FORi(a,b,c) for(int i=(a);i<(b);i+=c)
34 #define FORj(a,b,c) for(int j=(a);j<(b);j+=c)
35 #define FORk(a,b,c) for(int k=(a);k<(b);k+=c)
36 #define FORp(a,b,c) for(int p=(a);p<(b);p+=c)
37 #define FORii(a,b,c) for(int ii=(a);ii<(b);ii+=c)
38 #define FORjj(a,b,c) for(int jj=(a);jj<(b);jj+=c)
39 #define FORkk(a,b,c) for(int kk=(a);kk<(b);kk+=c)
40
41 #define FF(i,a) for(int i=0;i<(a);i+++)
42 #define FFD(i,a) for(int i=(a)-1;i>=0;i--)
43 #define Z(a) (a<<1)
44 #define Y(a) (a>>1)
45
46 const double eps = 1e - 6 ;
47 const double INFf = 1e10;
48 const int INFi = 1000000000 ;
49 const double Pi = acos( - 1.0 );
50
51 template < class T > inline T sqr(T a){ return a * a;}
52 template < class T > inline T TMAX(T x,T y)
53 {
54 if (x > y) return x;
55 return y;
56 }
57 template < class T > inline T TMIN(T x,T y)
58 {
59 if (x < y) return x;
60 return y;
61 }
62 template < class T > inline void SWAP(T & x,T & y)
63 {
64 T t = x;
65 x = y;
66 y = t;
67 }
68 template < class T > inline T MMAX(T x,T y,T z)
69 {
70 return TMAX(TMAX(x,y),z);
71 }
72
73
74 // code begin
75 #define MAXN 1100
76 int T;
77 char in [MAXN];
78 char out [MAXN];
79 int dx;
80
81 int main()
82 {
83 read;
84 write;
85 scanf( " %d " , & T);
86 while (T -- )
87 {
88 scanf( " %s " , in );
89 int cnt,n = strlen( in );
90 char pre;
91 dx = 0 ;
92 for ( int i = n - 1 ;i >= 0 ;)
93 {
94 pre = in [i];
95 cnt = 0 ;
96
97 while (i >= 0 && in [i] == pre)
98 {
99 cnt ++ ;
100 i -- ;
101 }
102
103 out [dx ++ ] = pre;
104
105 while (cnt > 0 )
106 {
107 out [dx ++ ] = cnt % 10 + ' 0 ' ;
108 cnt /= 10 ;
109 }
110
111 if (i < 0 ) break ;
112 }
113
114 for ( int i = dx - 1 ;i >= 0 ;i -- )
115 {
116 printf( " %c " , out [i]);
117 }
118 printf( " \n " );
119 }
120 return 0 ;
121 }
2 #include < cstdio >
3 #include < cstdlib >
4 #include < cstring >
5 #include < cmath >
6 #include < cctype >
7 #include < ctime >
8
9 #include < iostream >
10 #include < sstream >
11 #include < fstream >
12 #include < iomanip >
13 #include < bitset >
14 #include < strstream >
15
16 #include < algorithm >
17 #include < string >
18 #include < vector >
19 #include < queue >
20 #include < set >
21 #include < list >
22 #include < functional >
23
24 using namespace std;
25
26 // typedef
27 typedef long long LL;
28 typedef unsigned long long ULL;
29
30 //
31 #define read freopen("in.txt","r",stdin)
32 #define write freopen("out.txt","w",stdout)
33 #define FORi(a,b,c) for(int i=(a);i<(b);i+=c)
34 #define FORj(a,b,c) for(int j=(a);j<(b);j+=c)
35 #define FORk(a,b,c) for(int k=(a);k<(b);k+=c)
36 #define FORp(a,b,c) for(int p=(a);p<(b);p+=c)
37 #define FORii(a,b,c) for(int ii=(a);ii<(b);ii+=c)
38 #define FORjj(a,b,c) for(int jj=(a);jj<(b);jj+=c)
39 #define FORkk(a,b,c) for(int kk=(a);kk<(b);kk+=c)
40
41 #define FF(i,a) for(int i=0;i<(a);i+++)
42 #define FFD(i,a) for(int i=(a)-1;i>=0;i--)
43 #define Z(a) (a<<1)
44 #define Y(a) (a>>1)
45
46 const double eps = 1e - 6 ;
47 const double INFf = 1e10;
48 const int INFi = 1000000000 ;
49 const double Pi = acos( - 1.0 );
50
51 template < class T > inline T sqr(T a){ return a * a;}
52 template < class T > inline T TMAX(T x,T y)
53 {
54 if (x > y) return x;
55 return y;
56 }
57 template < class T > inline T TMIN(T x,T y)
58 {
59 if (x < y) return x;
60 return y;
61 }
62 template < class T > inline void SWAP(T & x,T & y)
63 {
64 T t = x;
65 x = y;
66 y = t;
67 }
68 template < class T > inline T MMAX(T x,T y,T z)
69 {
70 return TMAX(TMAX(x,y),z);
71 }
72
73
74 // code begin
75 #define MAXN 1100
76 int T;
77 char in [MAXN];
78 char out [MAXN];
79 int dx;
80
81 int main()
82 {
83 read;
84 write;
85 scanf( " %d " , & T);
86 while (T -- )
87 {
88 scanf( " %s " , in );
89 int cnt,n = strlen( in );
90 char pre;
91 dx = 0 ;
92 for ( int i = n - 1 ;i >= 0 ;)
93 {
94 pre = in [i];
95 cnt = 0 ;
96
97 while (i >= 0 && in [i] == pre)
98 {
99 cnt ++ ;
100 i -- ;
101 }
102
103 out [dx ++ ] = pre;
104
105 while (cnt > 0 )
106 {
107 out [dx ++ ] = cnt % 10 + ' 0 ' ;
108 cnt /= 10 ;
109 }
110
111 if (i < 0 ) break ;
112 }
113
114 for ( int i = dx - 1 ;i >= 0 ;i -- )
115 {
116 printf( " %c " , out [i]);
117 }
118 printf( " \n " );
119 }
120 return 0 ;
121 }