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

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

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

m = A("m")
i = B("i")
e = C("e")
b = A("b")
n = C("n")
f = B("f")

m.w = n
i.v = e
e.o = b
b.w = e
n.o = m
f.v = e
assert i.v.o.w.o.w.o.txt == "
class A:
    def __init__(self, txt: str):
        self.w: C = None
        self.txt = txt

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

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

m = A("m")
i = B("i")
e = C("e")
b = A("b")
n = C("n")
f = B("f")

m.w = n
i.v = e
e.o = b
b.w = e
n.o = m
f.v = e
assert i.v.o.w.o.w.o.txt == "b"