class A:
    def __init__(self, txt: str):
        self.t: B = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.t: A = None
        self.txt = txt

c = A("c")
k = B("k")
m = A("m")
i = B("i")
b = A("b")
d = A("d")

c.t = k
k.t = d
m.t = k
i.t = b
b.t = i
d.t = k
assert m.t.t.t.t.t.txt == "
class A:
    def __init__(self, txt: str):
        self.t: B = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.t: A = None
        self.txt = txt

c = A("c")
k = B("k")
m = A("m")
i = B("i")
b = A("b")
d = A("d")

c.t = k
k.t = d
m.t = k
i.t = b
b.t = i
d.t = k
assert m.t.t.t.t.t.txt == "k"