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

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

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

g.t = n
b.z = m
b.s = a
e.t = n
n.t = d
d.t = c
k.z = m
k.s = d
c.t = a
m.z = b
m.s = c
a.t = n
assert a.t.t.t.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: B = None
        self.s: A = None
        self.txt = txt

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

g.t = n
b.z = m
b.s = a
e.t = n
n.t = d
d.t = c
k.z = m
k.s = d
c.t = a
m.z = b
m.s = c
a.t = n
assert a.t.t.t.t.t.t.t.t.t.txt == "n"