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

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

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

h.y = m
h.v = m
j.z = m
j.w = m
k.z = m
k.w = h
d.z = m
d.w = h
i.z = m
i.w = h
b.z = m
b.w = h
m.y = h
m.v = h
l.z = h
l.w = m
assert k.w.y.v.v.y.y.txt == "
class A:
    def __init__(self, txt: str):
        self.y: A = None
        self.v: A = None
        self.txt = txt

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

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

h.y = m
h.v = m
j.z = m
j.w = m
k.z = m
k.w = h
d.z = m
d.w = h
i.z = m
i.w = h
b.z = m
b.w = h
m.y = h
m.v = h
l.z = h
l.w = m
assert k.w.y.v.v.y.y.txt == "m"