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

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

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

h = A("h")
i = B("i")
b = C("b")
l = C("l")

h.r = b
h.t = b
i.s = l
b.z = h
b.x = h
b.r = i
l.z = h
l.x = h
l.r = i
assert b.z.r.r.txt == "
class A:
    def __init__(self, txt: str):
        self.r: C = None
        self.t: C = None
        self.txt = txt

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

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

h = A("h")
i = B("i")
b = C("b")
l = C("l")

h.r = b
h.t = b
i.s = l
b.z = h
b.x = h
b.r = i
l.z = h
l.x = h
l.r = i
assert b.z.r.r.txt == "i"