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

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

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

b.v = e
b.r = k
c.y = k
c.w = k
m.y = c
m.w = e
e.y = c
e.w = i
k.y = c
k.w = m
i.y = e
i.w = k
assert m.y.y.w.w.y.txt == "
class A:
    def __init__(self, txt: str):
        self.v: B = None
        self.r: B = None
        self.txt = txt

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

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

b.v = e
b.r = k
c.y = k
c.w = k
m.y = c
m.w = e
e.y = c
e.w = i
k.y = c
k.w = m
i.y = e
i.w = k
assert m.y.y.w.w.y.txt == "c"