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.p: B = None
        self.txt = txt

d = A("d")
a = B("a")
l = C("l")
h = B("h")
j = A("j")

d.z = l
a.r = l
l.p = a
h.r = l
j.z = l
assert d.z.p.r.p.r.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.p: B = None
        self.txt = txt

d = A("d")
a = B("a")
l = C("l")
h = B("h")
j = A("j")

d.z = l
a.r = l
l.p = a
h.r = l
j.z = l
assert d.z.p.r.p.r.txt == "l"