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

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

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

m = A("m")
l = B("l")
a = C("a")
h = B("h")
i = A("i")
d = C("d")
j = A("j")
e = A("e")

m.x = i
m.t = l
l.s = e
a.q = i
h.s = e
i.x = j
i.t = h
d.q = m
j.x = e
j.t = l
e.x = i
e.t = h
assert e.x.t.s.x.t.s.txt == "
class A:
    def __init__(self, txt: str):
        self.x: A = None
        self.t: B = None
        self.txt = txt

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

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

m = A("m")
l = B("l")
a = C("a")
h = B("h")
i = A("i")
d = C("d")
j = A("j")
e = A("e")

m.x = i
m.t = l
l.s = e
a.q = i
h.s = e
i.x = j
i.t = h
d.q = m
j.x = e
j.t = l
e.x = i
e.t = h
assert e.x.t.s.x.t.s.txt == "e"