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

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

b = A("b")
e = B("e")
d = A("d")
k = B("k")

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

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

b = A("b")
e = B("e")
d = A("d")
k = B("k")

b.y = e
e.t = b
d.y = e
k.t = d
assert k.t.y.t.y.txt == "e"