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

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

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

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

m = A("m")
k = B("k")
c = C("c")
a = D("a")
h = C("h")
e = C("e")
f = B("f")

m.q = a
m.r = a
k.y = f
c.r = a
c.o = e
a.s = c
h.r = a
h.o = e
e.r = a
e.o = c
f.y = k
assert a.s.o.r.s.txt == "
class A:
    def __init__(self, txt: str):
        self.q: D = None
        self.r: D = None
        self.txt = txt

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

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

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

m = A("m")
k = B("k")
c = C("c")
a = D("a")
h = C("h")
e = C("e")
f = B("f")

m.q = a
m.r = a
k.y = f
c.r = a
c.o = e
a.s = c
h.r = a
h.o = e
e.r = a
e.o = c
f.y = k
assert a.s.o.r.s.txt == "c"