class A:
    def __init__(self, txt: str):
        self.o: D = None
        self.u: C = None
        self.q: D = None
        self.w: C = None
        self.txt = txt

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

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

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

e = A("e")
k = B("k")
a = C("a")
b = D("b")
g = B("g")

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

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

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

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

e = A("e")
k = B("k")
a = C("a")
b = D("b")
g = B("g")

e.o = b
e.q = b
e.u = a
e.w = a
k.p = b
k.y = b
k.t = b
a.q = k
a.u = b
b.z = g
g.p = b
g.y = b
g.t = b
assert g.p.z.y.z.txt == "g"