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

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

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

h = A("h")
i = B("i")
d = C("d")
m = A("m")
e = A("e")
c = A("c")
n = B("n")
b = C("b")

h.z = d
i.r = b
d.y = n
d.v = n
d.o = b
m.z = d
e.z = d
c.z = b
n.r = b
b.y = n
b.v = n
b.o = d
assert b.v.r.v.r.o.o.txt == "
class A:
    def __init__(self, txt: str):
        self.z: C = None
        self.txt = txt

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

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

h = A("h")
i = B("i")
d = C("d")
m = A("m")
e = A("e")
c = A("c")
n = B("n")
b = C("b")

h.z = d
i.r = b
d.y = n
d.v = n
d.o = b
m.z = d
e.z = d
c.z = b
n.r = b
b.y = n
b.v = n
b.o = d
assert b.v.r.v.r.o.o.txt == "b"