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

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

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

m = A("m")
l = B("l")
k = C("k")
d = C("d")

m.r = k
m.o = k
m.p = l
l.q = d
l.w = d
l.o = m
k.o = l
k.s = m
d.o = l
d.s = m
assert m.o.s.p.q.txt == "
class A:
    def __init__(self, txt: str):
        self.r: C = None
        self.o: C = None
        self.p: B = None
        self.txt = txt

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

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

m = A("m")
l = B("l")
k = C("k")
d = C("d")

m.r = k
m.o = k
m.p = l
l.q = d
l.w = d
l.o = m
k.o = l
k.s = m
d.o = l
d.s = m
assert m.o.s.p.q.txt == "d"