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

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

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

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

h.y = m
c.o = h
c.v = h
c.r = m
m.w = h
i.o = h
i.v = h
i.r = m
assert i.o.y.w.y.txt == "
class A:
    def __init__(self, txt: str):
        self.y: C = None
        self.txt = txt

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

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

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

h.y = m
c.o = h
c.v = h
c.r = m
m.w = h
i.o = h
i.v = h
i.r = m
assert i.o.y.w.y.txt == "m"