class A:
    def __init__(self, txt: str):
        self.s: D = None
        self.q: D = None
        self.txt = txt

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

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

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

f = A("f")
a = B("a")
e = C("e")
g = D("g")
m = D("m")

f.s = g
f.q = g
a.x = g
e.o = a
g.z = e
g.p = e
g.r = m
m.z = e
m.p = e
m.r = g
assert e.o.x.r.r.z.txt == "
class A:
    def __init__(self, txt: str):
        self.s: D = None
        self.q: D = None
        self.txt = txt

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

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

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

f = A("f")
a = B("a")
e = C("e")
g = D("g")
m = D("m")

f.s = g
f.q = g
a.x = g
e.o = a
g.z = e
g.p = e
g.r = m
m.z = e
m.p = e
m.r = g
assert e.o.x.r.r.z.txt == "e"