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

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

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

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

h.r = l
h.w = i
e.r = l
e.v = l
e.z = h
i.v = e
i.p = h
l.r = e
l.v = e
l.z = h
assert l.z.w.p.w.txt == "
class A:
    def __init__(self, txt: str):
        self.r: B = None
        self.w: C = None
        self.txt = txt

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

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

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

h.r = l
h.w = i
e.r = l
e.v = l
e.z = h
i.v = e
i.p = h
l.r = e
l.v = e
l.z = h
assert l.z.w.p.w.txt == "i"