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

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

a = A("a")
d = B("d")
i = A("i")
b = A("b")
j = B("j")
l = B("l")
h = A("h")
e = B("e")
f = A("f")
c = A("c")

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

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

a = A("a")
d = B("d")
i = A("i")
b = A("b")
j = B("j")
l = B("l")
h = A("h")
e = B("e")
f = A("f")
c = A("c")

a.u = l
a.z = e
d.u = h
i.u = l
i.z = j
b.u = e
b.z = e
j.u = i
l.u = f
h.u = j
h.z = j
e.u = f
f.u = e
f.z = d
c.u = l
c.z = l
assert a.z.u.u.txt == "e"