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

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

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

j = A("j")
m = B("m")
b = C("b")
e = B("e")

j.v = b
m.o = j
b.o = j
b.u = e
e.o = j
assert e.o.v.o.txt == "
class A:
    def __init__(self, txt: str):
        self.v: C = None
        self.txt = txt

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

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

j = A("j")
m = B("m")
b = C("b")
e = B("e")

j.v = b
m.o = j
b.o = j
b.u = e
e.o = j
assert e.o.v.o.txt == "j"