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

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

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

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

h.p = i
h.z = l
h.v = l
i.r = l
l.q = h
l.s = h
assert h.v.q.z.txt == "l"