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

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

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

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

m.o = h
a.u = i
c.s = l
c.w = m
c.q = m
h.o = m
i.u = a
l.o = m
assert i.u.u.u.txt == "
class A:
    def __init__(self, txt: str):
        self.o: A = None
        self.txt = txt

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

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

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

m.o = h
a.u = i
c.s = l
c.w = m
c.q = m
h.o = m
i.u = a
l.o = m
assert i.u.u.u.txt == "a"