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

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

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

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

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

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

b.u = h
b.z = j
g.u = j
e.u = l
e.z = h
l.u = b
l.z = b
a.u = l
h.u = b
h.z = j
j.u = h
j.z = l
n.u = b
d.u = l
f.u = l
assert l.z.u.u.z.z.u.z.txt == "j"