In this task, we would like for you to appreciate the usefulness of the groupby() function of itertools . To read more about this function, Check this out .

You are given a string $\mbox{S}$. Suppose a character '$\textbf{C}$' occurs consecutively $\mbox{X}$ times in the string. Replace these consecutive occurrences of the character '$\textbf{C}$' with $(X,c)$ in the string. 

For a better understanding of the problem, check the explanation. 

Input Format

A single line of input consisting of the string $\mbox{S}$. 

Output Format 

A single line of output consisting of the modified string.

Constraints

All the characters of $\mbox{S}$ denote integers between $\mbox{o}$ and $\mbox{9}$. 

$1\leq\big|\text{}S\big|\leq10^4$

Sample Input

1222311

Sample Output

(1, 1) (3, 2) (1, 3) (2, 1)

Explanation

First, the character $\mbox{I}$ occurs only once. It is replaced by $(1,\:\:1)$. Then the character $2$ occurs three times, and it is replaced by $(3,2)$ and so on. 

Also, note the single space within each compression and between the compressions.

Difficulty: MEDIUM

Solutions:
s = input() + ' '
act = s[0]
num = 1
for i in range(1, len(s)):
	if s[i] == act:
		num += 1
	else:
		print('(' + str(num) + ', ' + act + ')', end=' ')
		act = s[i]
		num = 1


chars = list(input())
current = ''
count = 0
output = []
for char in chars:
	if char != current:
		if count != 0:
			output.append('(%s, %s)' % (count, current))
		count = 1
		current = char
	else:
		count += 1
if count != 0:
	output.append('(%s, %s)' % (count, current))
print(' '.join(output))


from collections import Counter
s = input()
i = 0
while i < len(s):
	count = 1
	c = s[i]
	while i + 1 < len(s) and s[i] == s[i + 1]:
		i += 1
		count += 1
	print(tuple([count, int(c)]), end=' ')
	i += 1


import os

def compressString(string):
	i = 0
	count = 1
	current = string[0]
	while i < len(string) - 1:
		current = string[i]
		if current == string[i + 1]:
			count += 1
		else:
			print((count, int(current)), end=' ')
			count = 1
		i += 1
	print((count, int(string[len(string) - 1])))

def main():
	string = input()
	compressString(string)
main()


import itertools

def compress(data):
	return [(len(list(g)), k) for (k, g) in itertools.groupby(data)]

def run():
	data = input()
	for p in compress(data):
		print('({}, {}) '.format(p[0], p[1]), end='')
	print()
run()


s = input()
l = list(map(int, list(s)))
res = ''
i = 0
flag = False
while i < len(l):
	if i == len(l) - 1:
		res = res + ' (1, ' + str(l[i]) + ')'
		break
	j = i
	compteur = 1
	while j <= len(l) - 2 and l[j] == l[j + 1]:
		if j == len(l) - 2:
			compteur = compteur + 1
			flag = True
			break
		else:
			compteur = compteur + 1
			j = j + 1
	if flag:
		res = res + ' (' + str(compteur) + ', ' + str(l[i]) + ')'
		break
	else:
		res = res + ' (' + str(compteur) + ', ' + str(l[i]) + ')'
		i = j + 1
print(res[1:])


s = input()
c = 1
ch = s[0]
for i in range(1, len(s)):
	if ch != s[i]:
		print('(', c, ', ', ch, ')', sep='', end=' ')
		c = 1
		ch = s[i]
	else:
		c += 1
if c:
	print('(', c, ', ', ch, ')', sep='')


s = input()
compressed = []
last = [1, s[0]]
for i in s[1:len(s)]:
	if last[1] == i:
		last[0] += 1
	else:
		compressed.append(last)
		last = [1, i]
compressed.append(last)
for i in compressed:
	print('({0}, {1}) '.format(i[0], i[1]), end='')


s = input()
pre = None
count = 0
result = []
for i in s:
	if pre == None:
		pre = i
		count += 1
	elif pre == i:
		count += 1
	else:
		result.append('(%d, %c)' % (count, pre))
		count = 1
		pre = i
result.append('(%d, %c)' % (count, pre))
print(' '.join(result))


this = input()
answer = []
temp = ['p', 0]
for x in this:
	if x == temp[0]:
		temp[1] += 1
	else:
		answer.append(temp.copy())
		temp[0] = x
		temp[1] = 1
answer.append(temp)
text = ''
for x in answer[1:]:
	text += '({}, {}) '.format(x[1], x[0])
print(text[:-1])


import itertools
s = input().strip()
s_unique_element = list(set(s))
group = []
key = []
for (k, g) in itertools.groupby(s):
	group.append(list(g))
	key.append(k)
for i in range(len(group)):
	group_length = len(group[i])
	k = int(key[i])
	print(tuple((group_length, k)), end=' ')


s = input()
tmp = s[0]
count = 1
for i in range(1, len(s)):
	if tmp != s[i]:
		print('(' + str(count) + ', ' + str(tmp) + ')', end=' ')
		count = 1
	else:
		count += 1
	tmp = s[i]
print('(' + str(count) + ', ' + str(tmp) + ')', end=' ')


S = input()
char = S[0]
count = 1
ocr = []
for c in S[1:]:
	if char == c:
		count += 1
	else:
		x = (count, int(char))
		print(x, end=' ')
		char = c
		count = 1
x = (count, int(char))
print(x)


import sys
cur = ''
cnt = 0
for x in input():
	if x != cur:
		if cnt > 0:
			sys.stdout.write('({}, {}) '.format(cnt, cur))
		cur = x
		cnt = 1
	else:
		cnt += 1
if cnt > 0:
	sys.stdout.write('({}, {}) '.format(cnt, cur))


from itertools import groupby
s = input()
f = [(len(list(g)), int(k)) for (k, g) in groupby(s)]
print(*f)


s = input()
compressedS = []
cnt = 0
for i in range(len(s)):
	if i == 0:
		cnt = 1
	elif s[i] == s[i - 1]:
		cnt += 1
	else:
		compressedS.append(str((cnt, int(s[i - 1]))))
		cnt = 1
compressedS.append(str((cnt, int(s[-1]))))
print(' '.join(compressedS))


import re
a = input()
print(re.sub('(.)\\1*', lambda m: str((len(m.group(0)), int(m.group(1)))) + ' ', a))


a = input()
prevLet = a[0]
curLet = a[0]
curQuan = 1
for i in range(1, len(a)):
	curLet = a[i]
	if curLet == prevLet:
		curQuan += 1
	else:
		print('({}, {})'.format(curQuan, prevLet), end=' ')
		prevLet = curLet
		curQuan = 1
print('({}, {})'.format(curQuan, curLet), end='')


S = input()
import re

def repl(m):
	g = m.groups()
	if g[2] is None:
		print('({}, {})'.format(1, g[1]), end=' ')
	else:
		print('({}, {})'.format(len(g[0]), g[1]), end=' ')
re.sub('((\\d)(\\2)*)', repl, S)


s = input()
prev = ''
first = True
count = 1
prev = s[0]
for c in s[1:]:
	if c == prev:
		count += 1
	else:
		if not first:
			print(' ', end='')
		else:
			first = False
		print('(' + str(count) + ', ' + prev + ')', end='')
		prev = c
		count = 1
if not first:
	print(' ', end='')
else:
	first = False
print('(' + str(count) + ', ' + prev + ')', end='')


import sys
inp = input()
c = inp[0]
cl = 1
for i in range(1, len(inp)):
	if c == inp[i]:
		cl += 1
	else:
		print('({}, {})'.format(cl, c), end=' ')
		c = inp[i]
		cl = 1
print('({}, {})'.format(cl, c))


S = input()
numOccur = 0
prevChar = '\x00'
for i in range(len(S)):
	if S[i] == prevChar:
		numOccur = numOccur + 1
	else:
		if numOccur > 0:
			T = (numOccur, int(prevChar))
			print(T, end=' ')
		prevChar = S[i]
		numOccur = 1
if numOccur > 0:
	T = (numOccur, int(prevChar))
	print(T)


s = list(map(int, input()))
ans = ''
cnt = 1
for i in range(len(s)):
	currEl = s[i:i + 1]
	nextEl = s[i + 1:i + 2]
	if currEl == nextEl:
		cnt += 1
	else:
		ans += str((cnt, currEl[0])) + ' '
		cnt = 1
print(ans)


s = input()
l = []
a = ''
for c in s:
	if c != a:
		l.append([1, c])
		a = c
	else:
		l[len(l) - 1][0] = l[len(l) - 1][0] + 1
print(' '.join(('({}, {})'.format(i[0], i[1]) for i in l)))


string = input()
current = string[0]
o = []
count = 0
for c in string:
	if not c == current:
		o.append('(' + str(count) + ', ' + current + ')')
		current = c
		count = 1
	else:
		count += 1
o.append('(' + str(count) + ', ' + current + ')')
print(' '.join(o))


class Compress:

	def __init__(self, string):
		self.string = string

	def compress(self):
		result_arr = []
		curr = self.string[0]
		curr_count = 0
		for x in self.string:
			if x == curr:
				curr_count += 1
			else:
				result_arr.append((curr_count, int(curr)))
				curr = x
				curr_count = 1
		result_arr.append((curr_count, int(curr)))
		print(' '.join([str(x) for x in result_arr]))
string = input()
a = Compress(string)
a.compress()


from itertools import groupby
for (c, it) in groupby(input()):
	print('(' + str(len(list(it))) + ', ' + c + ')', end=' ')


from itertools import *

def encode(l):
	return [(len(list(group)), name) for (name, group) in groupby(l)]
t = input()
lst = encode(t)
lst = [(x, int(y)) for (x, y) in lst]
print(*lst)


import re
__author__ = 'gauth_000'
compression = re.findall('(\\d)(\\1*)', input())
for t in compression:
	print('(' + (str(1) if not len(t[1]) else str(len(t[1]) + 1)) + ', ' + t[0] + ')', end=' ')


k = input()
r = []
last = k[0]
total = 1
for i in k[1:]:
	if i == last:
		total += 1
	else:
		r.append('(' + str(total) + ', ' + str(last) + ')')
		last = i
		total = 1
r.append('(' + str(total) + ', ' + str(last) + ')')
print(' '.join(r))


def compressedString(s):
	l = len(s)
	cs = []
	i = 0
	while i < l:
		csc = 1
		for j in range(i + 1, l):
			if s[i] == s[j]:
				csc += 1
			else:
				break
		cs.append((csc, int(s[i])))
		i += csc
	return cs
print(*compressedString(input()), sep=' ', end='\n')


import sys
s = input()
lists = [0] * 10000
flag = s[0]
count = 1
for z in range(1, len(s)):
	if s[z] == flag:
		count += 1
	else:
		sys.stdout.write('(' + str(count) + ', ' + str(flag) + ')' + ' ')
		count = 1
	flag = s[z]
sys.stdout.write('(' + str(count) + ', ' + str(flag) + ')' + ' ')


s = list(input())
count = 1
for i in range(0, len(s)):
	if i == len(s) - 1:
		print('(' + str(count) + ', ' + str(s[i]) + ')', end=' ')
		break
	if s[i + 1] == s[i]:
		count = count + 1
	else:
		print('(' + str(count) + ', ' + str(s[i]) + ')', end=' ')
		count = 1


import itertools

def group_digits(s):
	for (k, g) in itertools.groupby(s):
		yield (len(list(g)), int(k))
print(*[str(x) for x in group_digits(input())])


S = input()
things = []
curr = S[0]
count = 1
for i in range(1, len(S)):
	if S[i] == curr:
		count += 1
	else:
		things.append((count, int(curr)))
		count = 1
		curr = S[i]
things.append((count, int(curr)))
print(' '.join((str(i) for i in things)))


s = input()
curr_char = s[0]
count = 1
lst = []
for i in range(1, len(s)):
	if s[i] != curr_char:
		lst.append('(' + str(count) + ', ' + curr_char + ')')
		count = 1
		curr_char = s[i]
	else:
		count = count + 1
lst.append('(' + str(count) + ', ' + curr_char + ')')
print(' '.join((x for x in lst)))


input_string = input()
count = 1
prev = ''
lst = []
for character in input_string:
	if character != prev:
		if prev:
			entry = (count, int(prev))
			print(entry, end='')
			print(' ', end='')
		count = 1
		prev = character
	else:
		count += 1
else:
	entry = (count, int(character))
	print(entry, end='')
	print(' ', end='')


s = input()
cnt = 0
ind = 0
i = 0
while i < len(s):
	if s[i] == s[ind]:
		cnt += 1
	else:
		print('(' + str(cnt) + ', ' + s[ind] + ')', end=' ')
		cnt = 0
		ind = i
		i -= 1
	i += 1
if cnt > 0:
	print('(' + str(cnt) + ', ' + s[ind] + ')', end=' ')


s = input()
result = []
while s:
	char = s[0]
	size = 1
	while len(s) > size and s[size] == char:
		size += 1
	result.append((size, int(char)))
	s = s[size:]
print(*result)


def dump(cnt, c, endch):
	print('({0}, {1})'.format(cnt, c), end=endch)
s = input()
prev = s[0]
cnt = 1
for c in s[1:]:
	if c != prev:
		dump(cnt, prev, ' ')
		prev = c
		cnt = 1
	else:
		cnt += 1
dump(cnt, prev, '')


input_string = input()
listed_input = list(input_string)
current_character = None
current_count = 0
for character in listed_input[:]:
	if current_character == None:
		current_character = listed_input.pop(0)
		current_count += 1
	elif current_character == listed_input[0]:
		listed_input.pop(0)
		current_count += 1
	else:
		print('({0}, {1})'.format(current_count, current_character), end=' ')
		current_character = listed_input.pop(0)
		current_count = 1
print('({0}, {1})'.format(current_count, current_character), end='')


from itertools import groupby
print(*[(len(list(g)), int(k)) for (k, g) in groupby(input())])


def tup(c, n):
	return '({}, {}) '.format(n, c)
s = input()
res = ''
c = s[0]
n = 1
for i in range(1, len(s)):
	if s[i] != c:
		res += tup(c, n)
		c = s[i]
		n = 1
	else:
		n += 1
res += tup(c, n)
print(res)


str = input()
i = 0
while i < len(str):
	j = i + 1
	k = 1
	while j < len(str) and str[i] == str[j]:
		k = k + 1
		j = j + 1
	print('(%d, %s)' % (k, str[i]), end=' ')
	i = j


s = input()
L = len(s)
p = s[0]
x = 0
i = 0
for c in s:
	if c == p:
		x = x + 1
	else:
		print('(' + str(x) + ', ' + p + ')', end=' ')
		p = s[i]
		x = 1
	i = i + 1
print('(' + str(x) + ', ' + p + ')', end='')


k = input()
o = 1
p = 1
c = k[0]
import sys
if len(k) == 1:
	print('(' + str(o) + ',' + ' ' + str(c) + ') ', end='')
while p < len(k):
	if k[p] == c:
		o = o + 1
	else:
		print('(' + str(o) + ',' + ' ' + str(c) + ') ', end='')
		o = 1
		c = k[p]
	if p == len(k) - 1:
		print('(' + str(o) + ',' + ' ' + str(c) + ') ', end='')
		o = 1
		c = k[p]
	p = p + 1


string = str(input())
encoded = []
curr_char = string[0]
number = 1
if len(string) > 0:
	for char in string[1:]:
		if char == curr_char:
			number += 1
		else:
			encoded.append((number, int(curr_char)))
			curr_char = char
			number = 1
	encoded.append((number, int(curr_char)))
print(' '.join(map(str, encoded)))


from itertools import groupby
groups = []
uniquekeys = []
data = input()
for (k, g) in groupby(data, lambda x: x[0]):
	groups.append(list(g))
	uniquekeys.append(k)
for each in range(len(groups)):
	print((len(groups[each]), int(uniquekeys[each])), end=' ')


str1 = input()
i = 0
j = 0
count = 0
while i <= len(str1):
	if j == len(str1) or str1[j] != str1[i]:
		print('(' + str(count) + ', ' + str(str1[i]) + ') ', end='')
		i = j
		count = 0
		if j == len(str1):
			break
	elif str1[j] == str1[i]:
		count = count + 1
		j = j + 1


S = input()
i = 1
a = []
count = 1
while i < len(S):
	if S[i] == S[i - 1]:
		count += 1
		i += 1
	else:
		a.append((count, int(S[i - 1])))
		i += 1
		count = 1
a.append((count, int(S[i - 1])))
for i in a:
	print(i, end=' ')


def compress_string(string):
	i = 1
	current_char = string[0]
	current_count = 1
	compressed = []
	while i < len(string):
		if string[i] == current_char:
			current_count += 1
			i += 1
			continue
		compressed.append((str(current_count), current_char))
		current_char = string[i]
		current_count = 1
		i += 1
	compressed.append((str(current_count), current_char))
	return compressed

def print_compressed_string(compressed_string):
	print(' '.join(['({}, {})'.format(count, char) for (count, char) in compressed_string]))
string = input().strip()
print_compressed_string(compress_string(string))


from itertools import takewhile
s = input()
i = 0
while i < len(s):
	c = len(list(takewhile(lambda x: x == s[i], s[i:])))
	print((c, int(s[i])), end=' ')
	i += c


s = input()
li = list(s)
for i in range(len(li)):
	li[i] = ord(li[i]) - 48
n = len(li)
i = 0
while i < n:
	ch = li[i]
	count = 0
	while i < n and ch == li[i]:
		count += 1
		i += 1
	s = '(' + str(count) + ', ' + str(ch) + ')'
	print(s, end=' ')


X = input()
temp1 = 1
A = list()
m = len(X)
X = X + ' '
i = 0
mn = 0
while i < m:
	A.append(X[i])
	while X[i] == X[i + 1]:
		temp1 = temp1 + 1
		i = i + 1
		mn = 1
	A.append(temp1)
	temp1 = 1
	i = i + 1
	mn = 0
i = 0
while i < len(A) - 1:
	print('(', end='')
	print(A[i + 1], end='')
	print(',', end=' ')
	print(A[i], end='')
	print(')', end=' ')
	i = i + 2


s = input()
x = 1
n = len(s)
for i in range(0, n):
	if i + 1 < n:
		if s[i] == s[i + 1]:
			x = x + 1
		else:
			print('(' + str(x) + ', ' + str(s[i]) + ')', end=' ')
			x = 1
print('(' + str(x) + ', ' + str(s[i]) + ')', end=' ')


import sys
stdin = sys.stdin
s = stdin.readline().strip()
prev = ''
ct = 0
all = []
for c in s:
	if prev == c:
		ct += 1
	else:
		if ct > 0:
			all.append('({}, {})'.format(ct, prev))
		ct = 1
		prev = c
if ct > 0:
	all.append('({}, {})'.format(ct, prev))
print(' '.join(all))


s = input()
while len(s) > 0:
	c = s[0]
	x = 0
	while len(s) > 0 and s[0] == c:
		s = s[1:]
		x += 1
	print('({}, {})'.format(x, c), end=' ')


line = input()
s = []
(ans_1, ans_2) = ([], [])
kol = 0
for i in range(len(line)):
	s.append(int(line[i]))
	if i == 0:
		ans_1.append(s[i])
	if i != 0:
		if s[i] != s[i - 1]:
			ans_1.append(s[i])
			ans_2.append(kol)
			kol = 0
	kol += 1
ans_2.append(kol)
for i in range(len(ans_1)):
	print((ans_2[i], ans_1[i]), end=' ')


from itertools import groupby

def RLE(s):
	return [(len(list(g)), k) for (k, g) in groupby(s)]

def main():
	s = input()
	r = RLE(s)
	for i in r:
		print('({0}, {1})'.format(i[0], i[1]), end=' ')
	print()
main()


s = input()
count = 0
key = s[0]
for i in range(len(s)):
	if s[i] == key:
		count += 1
	else:
		print('(', count, ', ', key, ')', sep='', end=' ')
		count = 1
		key = s[i]
print('(', count, ', ', key, ')', sep='')


S = input()
s = 0
while s < len(S):
	c = S[s]
	X = 1
	s += 1
	while s < len(S) and S[s] == c:
		s += 1
		X += 1
	print('({0}, {1}) '.format(X, c), end='')


__author__ = 'namii'

def compress_string(stringi):
	(current, count) = (stringi[0], 0)
	L = []
	for (i, letter) in enumerate(stringi):
		if letter == current:
			count += 1
		else:
			L.append('(' + str(count) + ', ' + current + ')')
			count = 1
			current = letter
	L.append('(' + str(count) + ', ' + letter + ')')
	return L
input_string = input()
outputti = compress_string(input_string)
print(' '.join(outputti))


s = input()
x = 1
c = s[0]
for i in s[1:]:
	if i == c:
		x += 1
	else:
		print('(' + str(x) + ', ' + str(c) + ') ', end='')
		x = 1
		c = i
print('(' + str(x) + ', ' + str(c) + ') ', end='')


str = input()
c0 = ''
v = 0
out = ''
for c in str:
	c = int(c)
	if c0 == '' or c == c0:
		v += 1
		c0 = c
	else:
		print(tuple((v, c0)).__str__(), end=' ')
		v = 1
		c0 = c
print((v, c0))


s = input()
c = s[0]
cont = 0
l = list()
for x in s:
	if c == x:
		cont += 1
	else:
		l.append('({}, {})'.format(cont, c))
		c = x
		cont = 1
l.append('({}, {})'.format(cont, c))
print(' '.join(l))


data = list(input())
data.append('-1')
vals = []
count = 1
while len(data) > 1:
	last = data.pop(0)
	if last != data[0]:
		vals.append([count, last])
		count = 0
	count += 1
for i in vals:
	print('(' + str(i[0]) + ', ' + str(i[1]) + ')', end=' ')


string = input()
i = 0
while i < len(string):
	k = string[i]
	cnt = 0
	itr = i
	while True:
		if itr >= len(string):
			break
		if string[itr] != k:
			break
		cnt += 1
		itr += 1
	i += cnt
	print('(' + str(cnt) + ', ' + str(k) + ')', end=' ')


S = input()
W = [(1, int(S[0]))]
for x in S[1:]:
	x = int(x)
	if x == W[-1][1]:
		W[-1] = (W[-1][0] + 1, x)
	else:
		W.append((1, x))
print(*W)


x = input()
x = x + '.'
count = 1
for i in range(0, len(x) - 1):
	if x[i] == x[i + 1]:
		count += 1
	else:
		print((count, int(x[i])), end=' ')
		count = 1


import re
s = input().strip()
pat = '(\\d)\\1*'
i = re.finditer(pat, s)
ans = []
for match in i:
	count = match.end() - match.start()
	char = int(match.group()[0])
	ans.append(str((count, char)))
print(' '.join(ans))


s = input()
i = 0
l = len(s)
while i < l:
	j = i + 1
	rep = 1
	while j < l and s[j] == s[j - 1]:
		rep += 1
		j += 1
	print('(', rep, ', ', s[i], ')', sep='', end=' ')
	i = j


(res, X, last) = ([], 1, -1)
for n in list(map(int, input())):
	if n == last:
		X += 1
	else:
		if last != -1:
			res.append('(%s, %s)' % (X, last))
		(X, last) = (1, n)
res.append('(%s, %s)' % (X, last))
print(' '.join(res))


input_str = input()
if not input_str:
	quit()
prev_char = input_str[0]
count = 0
for char in input_str:
	if char == prev_char:
		count += 1
	else:
		print('(' + str(count) + ', ' + prev_char + ')', end=' ')
		count = 1
	prev_char = char
print('(' + str(count) + ', ' + prev_char + ')', end=' ')


mystr = input()
if len(mystr) == 1:
	print('(1, ' + mystr[0] + ') ', end='')
else:
	cnt = 1
	for i in range(len(mystr) - 1):
		if mystr[i + 1] == mystr[i]:
			cnt = cnt + 1
		else:
			print('(' + str(cnt) + ', ' + mystr[i] + ') ', end='')
			cnt = 1
	print('(' + str(cnt) + ', ' + mystr[i + 1] + ') ', end='')


s = input()
s += '$'
(prev, cnt) = (s[0], 0)
ans = []
for c in s:
	if c != prev:
		ans.append((cnt, prev))
		(prev, cnt) = (c, 1)
	else:
		cnt += 1
for item in ans:
	print('(%s, %s)' % item, end=' ')


fmt = lambda c, n: '({}, {})'.format(n, c)
s = input()
l = []
i = 1
n = 1
c = s[0]
for i in range(1, len(s)):
	if s[i] == c:
		n += 1
	else:
		l.append(fmt(c, n))
		c = s[i]
		n = 1
l.append(fmt(c, n))
print(' '.join(l))


s = input()
l = []
i = 0
while i < len(s):
	j = i + 1
	while j < len(s) and s[j] == s[i]:
		j += 1
	l.append((j - i, int(s[i])))
	i = j
for x in l:
	print(x, end=' ')


string = input()
first_char = string[0]
count = 0
for i in range(1, len(string)):
	char = string[i]
	count += 1
	if char != first_char:
		print((count, int(first_char)), end=' ')
		count = 0
		first_char = char
print((count + 1, int(first_char)), end=' ')


d = [int(x) for x in input()]
tmp = 0
lim = len(d)
while tmp < lim:
	width = 1
	try:
		while d[tmp + width] == d[tmp]:
			width += 1
	except:
		pass
	print((width, d[tmp]), end=' ')
	tmp += width


def helper(data):
	pre = data[0]
	count = 1
	for i in data[1:] + 'a':
		if pre == i:
			count += 1
		else:
			yield (count, int(pre))
			pre = i
			count = 1
print(*list(helper(input())), sep=' ')


s = list(map(int, input().strip()))
lastItem = s[0]
count = 1
r = []
for item in s[1:]:
	if item == lastItem:
		count += 1
	else:
		r.append((count, lastItem))
		count = 1
	lastItem = item
r.append((count, lastItem))
print(' '.join(map(str, r)))


S = input()
newstring = ''
current = S[0]
charcount = 0
for c in S:
	if c != current:
		newstring = newstring + '(' + str(charcount) + ', ' + current + ') '
		current = c
		charcount = 1
	else:
		charcount = charcount + 1
newstring = newstring + '(' + str(charcount) + ', ' + current + ') '
print(newstring)


s = input()
output = ''
i = 0
while i < len(s):
	acc = 1
	letter = s[i]
	c = i + 1
	while c < len(s) and s[i] == s[c]:
		acc += 1
		c += 1
	if output == '':
		output = '(' + str(acc) + ', ' + s[i] + ')'
	else:
		output += ' (' + str(acc) + ', ' + s[i] + ')'
	i = c
print(output)


s = input()
k = s[0]
c = 1
for i in range(1, len(s)):
	if k != s[i]:
		print('(' + str(c) + ', ' + k + ')', end=' ')
		k = s[i]
		c = 1
	else:
		c = c + 1
print('(' + str(c) + ', ' + k + ')', end=' ')


s = input()
size = len(s)
while len(s) > 0:
	cnt = 0
	v = s[0]
	j = 0
	while j < len(s) and s[j] == v:
		j += 1
		cnt += 1
	print('(' + str(cnt) + ',' + ' ' + str(v) + ')', end=' ')
	s = s[j:]


def compress(ls):
	rs = []
	if not ls:
		return rs
	(i, size) = (0, len(ls))
	while i < size:
		(j, val) = (i, ls[i])
		(l, i, test) = (1, i + 1, True)
		while i < size and test:
			test = val == ls[i]
			if test:
				(l, i) = (l + 1, i + 1)
		rs.append((l, val))
	return rs
xs = list(map(int, list(input())))
print(*compress(xs))


S = str(input())
current_char = S[0]
occurances = 0
output_list = []
for s in S:
	if s == current_char:
		occurances += 1
	else:
		output = (occurances, int(current_char))
		output_list.append(output)
		current_char = s
		occurances = 1
output = (occurances, int(current_char))
output_list.append(output)
for o in output_list:
	print(o, end=' ')


kata = input()
x = kata[0]
y = 0
for i in range(len(kata)):
	if x == kata[i]:
		y += 1
	else:
		print('(' + str(y) + ', ' + x + ')', end=' ')
		x = kata[i]
		y = 1
print('(' + str(y) + ', ' + x + ')', end='')


data = [int(i) for i in list(input())]
res = []
item = [1, data[0]]
for n in data[1:]:
	if n == item[1]:
		item[0] += 1
	else:
		res.append(item)
		item = [1, n]
res.append(item)
print(' '.join(('({}, {})'.format(*d) for d in res)))


my_string = input()
sl = len(my_string)
a = list()
result = []
for i in range(sl):
	if len(a) == 0 or my_string[i] == a[0]:
		a.append(my_string[i])
	elif my_string[i] != a[0]:
		result.append((len(a), int(a[0])))
		a.clear()
		a.append(my_string[i])
	elif i == sl - 1:
		a.append(my_string[i])
		result.append((len(a), int(a[0])))
		a.clear()
	else:
		pass
result.append((len(a), int(a[0])))
print(' '.join([str(t) for t in result]))


def compressS(s):
	pre = 0
	r = ''
	for i in range(len(s) + 1):
		if i == len(s) or s[i] != s[pre]:
			r += '({}, {}) '.format(i - pre, s[pre])
			pre = i
	return r[:-1]
s = input()
print(compressS(s))


from itertools import groupby

def __starting_point():
	for (el, el_list) in groupby(input()):
		print((len(list(el_list)), int(el)), end=' ')
__starting_point()


txt = input()
lc = None
cnt = 1
l = []
for c in txt:
	if lc == c:
		cnt = cnt + 1
	elif lc != None:
		l.append((cnt, lc))
		cnt = 1
	lc = c
l.append((cnt, lc))
print(' '.join(['({}, {})'.format(x[0], x[1]) for x in l]))


l = input()
l = list(l)
for i in range(0, len(l)):
	l[i] = int(l[i])
c = 1
i = 1
while i < len(l):
	if l[i] == l[i - 1]:
		c += 1
		i += 1
	else:
		print('(%d, %d) ' % (c, l[i - 1]), end='')
		c = 1
		i += 1
print('(%d, %d) ' % (c, l[len(l) - 1]))


a = list(input().rstrip())
count = 0
c = a[0]
for i in a:
	if c == i:
		count = count + 1
	else:
		print((count, int(c)), end=' ')
		c = i
		count = 1
print((count, int(c)))


n = input()
c = 1
kraj = ''
n += ' '
for ch in range(1, len(n)):
	if n[ch - 1] == n[ch]:
		c += 1
	else:
		kraj += '(' + str(c) + ', ' + str(n[ch - 1]) + ') '
		c = 1
print(kraj)


s = input()
c = s[0]
n = 0
result = ''
for char in s:
	if char == c:
		n += 1
	else:
		result += '(' + str(n) + ', ' + c + ') '
		n = 1
		c = char
result += '(' + str(n) + ', ' + c + ') '
print(result)


data = input()
count = 1
i = 0
if len(data) > 1:
	for i in range(len(data) - 1):
		if data[i] == data[i + 1]:
			count += 1
		else:
			print((count, int(data[i])), end='', flush='')
			print(' ', end='', flush='')
			count = 1
	print((count, int(data[i + 1])), end='', flush='')
else:
	print((count, int(data)), end='', flush='')
print(' ', end='', flush='')


s = input()
length = len(s)
counter = 1
output = ''
for (index, st) in enumerate(s):
	if index == length - 1:
		output += ' ({0}, {1})'.format(counter, s[index])
	elif st != s[index + 1]:
		output += ' ({0}, {1})'.format(counter, s[index])
		counter = 1
	elif st == s[index + 1]:
		counter += 1
print(output[1:])