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

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

a = A("a")
h = B("h")
l = B("l")
c = A("c")
d = A("d")
e = B("e")

a.s = e
a.u = h
h.z = l
h.u = l
l.z = h
l.u = h
c.s = l
c.u = l
d.s = e
d.u = e
e.z = h
e.u = h
assert a.s.z.u.z.z.u.txt == "
class A:
    def __init__(self, txt: str):
        self.s: B = None
        self.u: B = None
        self.txt = txt

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

a = A("a")
h = B("h")
l = B("l")
c = A("c")
d = A("d")
e = B("e")

a.s = e
a.u = h
h.z = l
h.u = l
l.z = h
l.u = h
c.s = l
c.u = l
d.s = e
d.u = e
e.z = h
e.u = h
assert a.s.z.u.z.z.u.txt == "h"