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

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

h = A("h")
c = B("c")
j = B("j")
l = A("l")
m = A("m")
e = B("e")
d = A("d")
g = B("g")
i = B("i")
k = A("k")

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

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

h = A("h")
c = B("c")
j = B("j")
l = A("l")
m = A("m")
e = B("e")
d = A("d")
g = B("g")
i = B("i")
k = A("k")

h.s = c
c.t = e
j.t = e
l.s = c
m.s = e
e.t = c
d.s = g
g.t = c
i.t = j
k.s = g
assert m.s.t.t.t.t.t.txt == "c"