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

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

b = A("b")
k = B("k")
m = B("m")
l = A("l")
e = A("e")
n = B("n")
c = A("c")

b.y = e
b.x = m
k.z = m
k.v = n
m.z = k
m.v = k
l.y = e
l.x = k
e.y = c
e.x = n
n.z = k
n.v = m
c.y = b
c.x = k
assert e.x.v.z.txt == "
class A:
    def __init__(self, txt: str):
        self.y: A = None
        self.x: B = None
        self.txt = txt

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

b = A("b")
k = B("k")
m = B("m")
l = A("l")
e = A("e")
n = B("n")
c = A("c")

b.y = e
b.x = m
k.z = m
k.v = n
m.z = k
m.v = k
l.y = e
l.x = k
e.y = c
e.x = n
n.z = k
n.v = m
c.y = b
c.x = k
assert e.x.v.z.txt == "k"