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

k = A("k")
j = B("j")
n = B("n")
e = A("e")

k.z = j
j.u = k
n.u = k
e.z = n
assert k.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

k = A("k")
j = B("j")
n = B("n")
e = A("e")

k.z = j
j.u = k
n.u = k
e.z = n
assert k.z.u.z.txt == "j"