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

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

a = A("a")
l = B("l")
j = A("j")
n = B("n")
g = B("g")
e = B("e")

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

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

a = A("a")
l = B("l")
j = A("j")
n = B("n")
g = B("g")
e = B("e")

a.z = l
l.u = j
j.z = n
n.u = a
g.u = j
e.u = a
assert j.z.u.z.txt == "l"