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

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

i = A("i")
a = B("a")
b = B("b")
j = B("j")
l = B("l")
m = A("m")
k = A("k")

i.s = k
i.z = l
a.v = i
a.x = j
b.v = i
b.x = a
j.v = i
j.x = l
l.v = k
l.x = b
m.s = i
m.z = a
k.s = m
k.z = a
assert k.s.s.s.txt == "
class A:
    def __init__(self, txt: str):
        self.s: A = None
        self.z: B = None
        self.txt = txt

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

i = A("i")
a = B("a")
b = B("b")
j = B("j")
l = B("l")
m = A("m")
k = A("k")

i.s = k
i.z = l
a.v = i
a.x = j
b.v = i
b.x = a
j.v = i
j.x = l
l.v = k
l.x = b
m.s = i
m.z = a
k.s = m
k.z = a
assert k.s.s.s.txt == "k"