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

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

k = A("k")
c = B("c")
e = B("e")
g = B("g")
b = B("b")
m = A("m")

k.y = m
k.w = m
c.z = k
c.o = g
e.z = m
e.o = g
g.z = k
g.o = c
b.z = m
b.o = g
m.y = k
m.w = k
assert e.z.w.y.y.w.txt == "
class A:
    def __init__(self, txt: str):
        self.y: A = None
        self.w: A = None
        self.txt = txt

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

k = A("k")
c = B("c")
e = B("e")
g = B("g")
b = B("b")
m = A("m")

k.y = m
k.w = m
c.z = k
c.o = g
e.z = m
e.o = g
g.z = k
g.o = c
b.z = m
b.o = g
m.y = k
m.w = k
assert e.z.w.y.y.w.txt == "m"