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

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

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

h = A("h")
k = B("k")
n = C("n")
d = C("d")
b = C("b")
e = B("e")

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

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

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

h = A("h")
k = B("k")
n = C("n")
d = C("d")
b = C("b")
e = B("e")

h.y = d
h.r = k
k.r = h
k.o = e
n.y = h
n.v = h
n.z = k
d.y = h
d.v = h
d.z = e
b.y = h
b.v = h
b.z = k
e.r = h
e.o = k
assert h.y.z.r.txt == "h"