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

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

c = A("c")
n = B("n")
m = B("m")
d = A("d")
h = B("h")
i = B("i")
j = B("j")
k = B("k")

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

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

c = A("c")
n = B("n")
m = B("m")
d = A("d")
h = B("h")
i = B("i")
j = B("j")
k = B("k")

c.t = d
c.s = d
n.t = j
m.t = n
d.t = c
d.s = c
h.t = j
i.t = j
j.t = k
k.t = h
assert k.t.t.t.t.txt == "h"