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

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

g.t = m
e.z = m
m.z = i
h.t = e
c.z = i
n.z = e
i.z = l
k.t = c
l.z = c
j.t = e
assert j.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

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

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