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

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

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

n = A("n")
g = B("g")
a = C("a")
h = B("h")
i = A("i")
c = C("c")
k = C("k")

n.w = k
n.r = h
n.v = g
g.o = a
a.w = c
h.o = a
i.w = c
i.r = g
i.v = h
c.w = a
k.w = c
assert h.o.w.w.txt == "
class A:
    def __init__(self, txt: str):
        self.w: C = None
        self.r: B = None
        self.v: B = None
        self.txt = txt

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

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

n = A("n")
g = B("g")
a = C("a")
h = B("h")
i = A("i")
c = C("c")
k = C("k")

n.w = k
n.r = h
n.v = g
g.o = a
a.w = c
h.o = a
i.w = c
i.r = g
i.v = h
c.w = a
k.w = c
assert h.o.w.w.txt == "a"