class A:
    def __init__(self, txt: str):
        self.o: B = 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.w: B = None
        self.v: B = None
        self.o: B = None
        self.txt = txt

a = A("a")
b = B("b")
g = C("g")
e = B("e")
j = A("j")

a.o = b
b.v = g
g.w = b
g.o = b
g.v = e
e.v = g
j.o = e
assert e.v.w.v.o.v.txt == "
class A:
    def __init__(self, txt: str):
        self.o: B = 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.w: B = None
        self.v: B = None
        self.o: B = None
        self.txt = txt

a = A("a")
b = B("b")
g = C("g")
e = B("e")
j = A("j")

a.o = b
b.v = g
g.w = b
g.o = b
g.v = e
e.v = g
j.o = e
assert e.v.w.v.o.v.txt == "g"