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

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

j = A("j")
g = B("g")
i = B("i")
m = B("m")
e = A("e")
l = A("l")
c = A("c")
d = B("d")
k = A("k")

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

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

j = A("j")
g = B("g")
i = B("i")
m = B("m")
e = A("e")
l = A("l")
c = A("c")
d = B("d")
k = A("k")

j.z = d
g.t = i
g.z = c
i.t = d
i.z = l
m.t = i
m.z = l
e.z = m
l.z = d
c.z = d
d.t = g
d.z = k
k.z = g
assert e.z.z.z.z.z.z.z.t.txt == "g"