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

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

class C:
    def __init__(self, txt: str):
        self.u: C = None
        self.y: C = None
        self.z: D = None
        self.txt = txt

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

e = A("e")
g = B("g")
f = C("f")
d = D("d")
b = C("b")

e.t = b
e.u = g
e.p = d
g.p = f
g.w = d
f.u = b
f.y = b
f.z = d
d.r = e
d.t = e
d.y = e
d.q = g
b.u = f
b.y = f
b.z = d
assert g.p.u.z.q.txt == "
class A:
    def __init__(self, txt: str):
        self.t: C = None
        self.u: B = None
        self.p: D = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.u: C = None
        self.y: C = None
        self.z: D = None
        self.txt = txt

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

e = A("e")
g = B("g")
f = C("f")
d = D("d")
b = C("b")

e.t = b
e.u = g
e.p = d
g.p = f
g.w = d
f.u = b
f.y = b
f.z = d
d.r = e
d.t = e
d.y = e
d.q = g
b.u = f
b.y = f
b.z = d
assert g.p.u.z.q.txt == "g"