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

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

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

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

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

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

h.t = e
n.z = e
k.t = n
a.t = n
d.z = n
g.t = d
m.t = n
c.t = n
e.z = d
i.t = n
assert a.t.z.z.txt == "d"