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

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

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

h = A("h")
j = B("j")
e = C("e")
c = A("c")
n = A("n")
g = B("g")
b = A("b")

h.v = j
j.w = g
j.o = g
e.x = h
c.v = g
n.v = g
g.w = j
g.o = j
b.v = g
assert b.v.w.o.txt == "
class A:
    def __init__(self, txt: str):
        self.v: B = None
        self.txt = txt

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

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

h = A("h")
j = B("j")
e = C("e")
c = A("c")
n = A("n")
g = B("g")
b = A("b")

h.v = j
j.w = g
j.o = g
e.x = h
c.v = g
n.v = g
g.w = j
g.o = j
b.v = g
assert b.v.w.o.txt == "g"