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

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

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

i = A("i")
h = B("h")
a = C("a")
g = C("g")
j = B("j")
b = B("b")

i.r = h
i.u = j
h.z = g
a.r = h
g.r = b
j.z = a
b.z = g
assert g.r.z.r.z.r.txt == "
class A:
    def __init__(self, txt: str):
        self.r: B = None
        self.u: B = None
        self.txt = txt

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

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

i = A("i")
h = B("h")
a = C("a")
g = C("g")
j = B("j")
b = B("b")

i.r = h
i.u = j
h.z = g
a.r = h
g.r = b
j.z = a
b.z = g
assert g.r.z.r.z.r.txt == "b"