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

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

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

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

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

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

c.t = i
c.w = k
m.u = k
k.u = a
d.u = m
j.t = c
j.w = n
a.u = d
i.t = c
i.w = n
n.u = d
assert d.u.u.u.u.u.u.txt == "k"