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

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

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

n.t = j
e.z = j
e.v = m
d.z = a
d.v = k
a.t = n
m.z = n
m.v = k
j.t = a
k.z = a
k.v = e
c.t = j
assert n.t.t.t.t.t.t.txt == "
class A:
    def __init__(self, txt: str):
        self.t: A = None
        self.txt = txt

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

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

n.t = j
e.z = j
e.v = m
d.z = a
d.v = k
a.t = n
m.z = n
m.v = k
j.t = a
k.z = a
k.v = e
c.t = j
assert n.t.t.t.t.t.t.txt == "n"