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

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

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

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

h.z = e
h.v = e
h.q = b
b.o = h
b.p = h
b.u = h
d.t = e
d.v = e
d.p = b
m.t = d
m.v = d
m.p = b
e.t = m
e.v = d
e.p = b
assert m.v.p.p.z.txt == "
class A:
    def __init__(self, txt: str):
        self.z: C = None
        self.q: B = None
        self.v: C = None
        self.txt = txt

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

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

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

h.z = e
h.v = e
h.q = b
b.o = h
b.p = h
b.u = h
d.t = e
d.v = e
d.p = b
m.t = d
m.v = d
m.p = b
e.t = m
e.v = d
e.p = b
assert m.v.p.p.z.txt == "e"