#!/usr/bin/python3
import os

def     find_pair(n, pos):
        n_keys = list(n.keys())

        with open("output{}.txt".format(pos), "w") as fout:
                fout.truncate()
                while n_keys:
                        lead = n_keys.pop(0)
                        group = [lead]

                        for i in range(10):
                                s = lead[:pos] + str(i) + lead[pos+1:];
                                if s in n_keys:
                                        group.append(s)
                                        n_keys.remove(s)

                        if len(group)>1:
                                for i in group:
                                        print("{} ==> {}".format(i, n[i][9]), file=fout)
                                print(file=fout)

if __name__ == '__main__':
        with open("charno.txt", "r") as fin:
                text = fin.read()

        x = text.split()

        n = {}
        for i in x:
                index = i[0:9]
                n[index] = i

        for i in range(0, 9):
                find_pair(n, i)

# End of differential.py