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

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

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

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

n.o = h
l.v = h
l.q = m
l.y = m
h.o = m
h.w = l
h.v = l
m.o = h
assert n.o.v.y.txt == "
class A:
    def __init__(self, txt: str):
        self.o: C = None
        self.txt = txt

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

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

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

n.o = h
l.v = h
l.q = m
l.y = m
h.o = m
h.w = l
h.v = l
m.o = h
assert n.o.v.y.txt == "m"