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

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

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

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

m = A("m")
i = B("i")
d = C("d")
f = D("f")
c = B("c")
a = B("a")
g = D("g")
b = B("b")

m.r = d
m.y = d
i.p = g
d.o = c
d.v = m
f.v = d
f.z = d
f.t = d
f.s = b
c.p = g
a.p = f
g.v = d
g.z = d
g.t = d
g.s = a
b.p = g
assert c.p.s.p.txt == "
class A:
    def __init__(self, txt: str):
        self.r: C = None
        self.y: C = None
        self.txt = txt

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

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

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

m = A("m")
i = B("i")
d = C("d")
f = D("f")
c = B("c")
a = B("a")
g = D("g")
b = B("b")

m.r = d
m.y = d
i.p = g
d.o = c
d.v = m
f.v = d
f.z = d
f.t = d
f.s = b
c.p = g
a.p = f
g.v = d
g.z = d
g.t = d
g.s = a
b.p = g
assert c.p.s.p.txt == "f"