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

class B:
    def __init__(self, txt: str):
        self.t: D = None
        self.w: C = None
        self.x: D = None
        self.q: C = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.x: D = None
        self.txt = txt

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

c = A("c")
g = B("g")
d = C("d")
e = D("e")

c.x = d
c.y = d
g.t = e
g.x = e
g.w = d
g.q = d
d.x = e
e.t = g
e.p = g
assert d.x.t.t.txt == "
class A:
    def __init__(self, txt: str):
        self.x: C = None
        self.y: C = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.t: D = None
        self.w: C = None
        self.x: D = None
        self.q: C = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.x: D = None
        self.txt = txt

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

c = A("c")
g = B("g")
d = C("d")
e = D("e")

c.x = d
c.y = d
g.t = e
g.x = e
g.w = d
g.q = d
d.x = e
e.t = g
e.p = g
assert d.x.t.t.txt == "e"