def longest_substring_same01count(string):
    # http://stackoverflow.com/a/26650828/4279
    diff = 0 #  difference between number of 1s and 0s preceding c
    first = {}
    diff_max_distance = max_distance = 0
    for pos, c in enumerate('x' + string): # or chain(None, string)
        diff += (c == '1') - (c == '0')
        if diff not in first:
            first[diff] = pos
        elif max_distance < (pos - first[diff]):
            max_distance = (pos - first[diff])
            diff_max_distance = diff
    return string[first[diff_max_distance]:first[diff_max_distance] + max_distance]

import sys
for line in sys.stdin:
    line = line.strip()
    if line:
        print("%r\t%r" % (line, longest_substring_same01count(line)))
