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

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

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

h = A("h")
e = B("e")
b = C("b")
g = B("g")
l = C("l")

h.p = l
e.q = b
b.v = h
g.q = l
l.v = h
assert h.p.v.p.v.txt == "
class A:
    def __init__(self, txt: str):
        self.p: C = None
        self.txt = txt

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

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

h = A("h")
e = B("e")
b = C("b")
g = B("g")
l = C("l")

h.p = l
e.q = b
b.v = h
g.q = l
l.v = h
assert h.p.v.p.v.txt == "h"