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

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

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

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

n.x = h
m.q = n
m.s = n
m.x = e
l.t = e
l.o = a
a.t = m
a.o = h
e.q = n
e.s = n
e.x = m
h.t = e
h.o = a
assert h.o.t.s.x.o.txt == "
class A:
    def __init__(self, txt: str):
        self.x: C = None
        self.txt = txt

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

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

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

n.x = h
m.q = n
m.s = n
m.x = e
l.t = e
l.o = a
a.t = m
a.o = h
e.q = n
e.s = n
e.x = m
h.t = e
h.o = a
assert h.o.t.s.x.o.txt == "a"