class A:
    def __init__(self, txt: str):
        self.w: 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.t: C = None
        self.z: B = None
        self.p: B = None
        self.txt = txt

i = A("i")
l = B("l")
h = C("h")
j = A("j")
e = B("e")
d = C("d")

i.w = h
l.r = d
h.t = d
h.z = l
h.p = l
j.w = d
e.r = h
d.t = h
d.z = l
d.p = l
assert d.z.r.z.r.txt == "
class A:
    def __init__(self, txt: str):
        self.w: 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.t: C = None
        self.z: B = None
        self.p: B = None
        self.txt = txt

i = A("i")
l = B("l")
h = C("h")
j = A("j")
e = B("e")
d = C("d")

i.w = h
l.r = d
h.t = d
h.z = l
h.p = l
j.w = d
e.r = h
d.t = h
d.z = l
d.p = l
assert d.z.r.z.r.txt == "d"