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

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

e = A("e")
c = B("c")
d = B("d")

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

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

e = A("e")
c = B("c")
d = B("d")

e.t = c
e.q = d
c.t = d
d.t = c
assert c.t.t.t.txt == "d"