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

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

c = A("c")
m = B("m")
j = B("j")
l = A("l")
a = B("a")

c.u = a
c.z = l
m.v = a
j.v = a
l.u = m
l.z = c
a.v = j
assert a.v.v.v.v.v.txt == "
class A:
    def __init__(self, txt: str):
        self.u: B = None
        self.z: A = None
        self.txt = txt

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

c = A("c")
m = B("m")
j = B("j")
l = A("l")
a = B("a")

c.u = a
c.z = l
m.v = a
j.v = a
l.u = m
l.z = c
a.v = j
assert a.v.v.v.v.v.txt == "j"