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

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

d = A("d")
e = B("e")
a = A("a")
i = B("i")
m = A("m")
c = A("c")
b = B("b")

d.w = m
d.v = c
e.o = m
e.p = c
a.w = c
a.v = d
i.o = d
i.p = a
m.w = c
m.v = c
c.w = d
c.v = d
b.o = d
b.p = d
assert m.v.v.v.v.v.w.txt == "
class A:
    def __init__(self, txt: str):
        self.w: A = None
        self.v: A = None
        self.txt = txt

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

d = A("d")
e = B("e")
a = A("a")
i = B("i")
m = A("m")
c = A("c")
b = B("b")

d.w = m
d.v = c
e.o = m
e.p = c
a.w = c
a.v = d
i.o = d
i.p = a
m.w = c
m.v = c
c.w = d
c.v = d
b.o = d
b.p = d
assert m.v.v.v.v.v.w.txt == "d"