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

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

e = A("e")
g = B("g")
h = A("h")
d = A("d")
l = A("l")
j = A("j")
n = B("n")

e.t = h
e.z = n
g.u = n
h.t = l
h.z = n
d.t = e
d.z = n
l.t = e
l.z = n
j.t = e
j.z = g
n.u = g
assert d.z.u.u.u.u.u.u.txt == "
class A:
    def __init__(self, txt: str):
        self.t: A = None
        self.z: B = None
        self.txt = txt

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

e = A("e")
g = B("g")
h = A("h")
d = A("d")
l = A("l")
j = A("j")
n = B("n")

e.t = h
e.z = n
g.u = n
h.t = l
h.z = n
d.t = e
d.z = n
l.t = e
l.z = n
j.t = e
j.z = g
n.u = g
assert d.z.u.u.u.u.u.u.txt == "n"