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

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

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

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

l.p = m
m.o = h
i.v = m
i.y = h
h.v = m
h.y = i
assert i.v.o.y.txt == "
class A:
    def __init__(self, txt: str):
        self.p: B = None
        self.txt = txt

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

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

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

l.p = m
m.o = h
i.v = m
i.y = h
h.v = m
h.y = i
assert i.v.o.y.txt == "i"